Skip to content

Commit

Permalink
Create sequence diagram describing PERS workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jonavellecuerdo committed Apr 29, 2024
1 parent 6fbc940 commit 0cd4531
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions docs/publication_email_requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Publication Email Request Service (PERS)

The following are sequence diagrams describing the workflow for sending publication email requests with this service. At high-level the steps involved are:

1. Import citations for authors
2. Create publication email requests
3. Review and (optionally) update emails
4. Send emails to Liaisons

## Import citations for authors

```mermaid
sequenceDiagram
autonumber
participant user as User
participant pers as Publication Email Request Service <br> (PERS)
participant elements as Symplectic Elements
participant pers_db as PERS Database
user ->> pers: Select option to import citations
pers ->> user: Request user input for author's Element's ID
user -->> pers: Respond with selected author's Element's ID
pers ->> elements: Send GET request to Elements API <br>to retrieve author data <br> "<ELEMENTS_ENDPOINT>users/{author_id}
elements -->> pers: Author data XML string <br> ("Email", "First Name", "Last Name", "MIT ID", "DLC", "Start Date", "End Date")
pers ->> pers: Parse XML string to AuthorRecord
pers ->> pers_db: Upsert record to 'Author' table
pers ->> elements: Send GET request to Elements API <br> to retrieve author's publications <br> <ELEMENTS_ENDPOINT>users/{author_id}/publications?&detail=full
elements -->> pers: Author publications XML string
pers ->> pers: Parse XML string to list of key-value pairs <br> for *qualifying* publications <br>(publication IDs and titles)
Note over pers, elements: As PERS parses through the author publications XML string, <br> it runs a series of preliminary checks to determine if the publication meets the criteria <br> for an email request. If checks pass, the publication is added to a list.
loop For every publication
pers ->> elements: Send GET request to Elements API <br> to retrieve publication data <br> <ELEMENTS_ENDPOINT>publications/{publication_id}
elements -->> pers: Publication citation data XML string
pers ->> pers: Parse XML string to PublicationRecord
pers -->> pers: Run checks on publication <br> 1.PublicationRecord is citable <br> 2. PublicationRecord has required identifiers <br> (MIT ID, Publication ID)
pers ->> pers_db: Check if any records in the 'Email' table linked to the publication have been sent <br> (i.e., `PublicationRecord.id in Email.publications and Email.date_sent is not None`)
pers ->> pers_db: Check if a record exists in the 'Publication' table where `Publication.id = PublicationRecord.id`.
pers ->> pers_db: Upsert record to the 'Publication' table
end
```

## Create publication email requests

```mermaid
sequenceDiagram
autonumber
participant user as User
participant pers as Publication Email Request Service <br> (PERS)
participant elements as Symplectic Elements
participant pers_db as PERS Database
user ->> pers: Select from list of unsent citations <br> (records from 'Publications' table)
loop For all authors linked to the selected publications
pers ->> pers_db: Get records from the 'Publication' table where `Publication.id in selected list AND Publication.author = author.id`
pers ->> pers_db: Get records from the 'Publication' table where `Publication.email.date_sent = Null`.
pers_db -->> pers: Unsent record(s) from 'Publication' table
pers ->> pers_db: Get the author from the unsent records
pers_db -->> pers: Record from 'Author' table
pers ->> pers_db: Get records from 'Email' table where `Email.author = author AND Email.date_sent = Null"
pers_db -->> pers: Record(s) from 'Email' table
break if author has more than one (>1) unsent email
pers ->> user: Raise error
end
alt: single (1) unsent email exists for author
pers ->> pers: Rebuild citations list in email
pers ->> pers_db: Update record in 'Email' table
else no (0) unsent email exists for author
pers ->> pers: Create email for author
pers ->> pers_db: Add record to 'Email' table
end
end

0 comments on commit 0cd4531

Please sign in to comment.