-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API changes for listing/marking source conversation items that have been seen by journalists #5513
Conversation
1c3e733
to
ee10a74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did a first pass
Not sure how the API is going to look once you're done, but just as a reminder, we were also considering updating the current replies and submissions endpoints as an option:
"replies": [
{
"filename": <filename>,
...
"seen_by": [<journalist_uuid>, ]
},
{
"filename": <filename>,
...
"seen_by": [<journalist_uuid>, ]
},
]
"submissions": [
{
"is_read": <is_read>,
"filename": <filename>,
...
"seen_by": [<journalist_uuid>, ]
"opened_by": [<journalist_uuid>, ]
},
{
"is_read": <is_read>,
"filename": <filename>,
...
"seen_by": [<journalist_uuid>, ]
"opened_by": [<journalist_uuid>, ]
},
] |
just a thought, we could rename "is_read" to "downloaded_from_web" |
ee10a74
to
3d13faf
Compare
That is already present, as suggested in the test plan. Look at the |
I know we've been playing pretty fast and loose with the API and versioning (at least it's mostly been additions 😐 ), but |
078a022
to
ecfe91f
Compare
This pull request introduces 2 alerts when merging ecfe91f into 3d13faf - view on LGTM.com new alerts:
|
ecfe91f
to
b16332e
Compare
This pull request introduces 2 alerts when merging b16332e into 3d13faf - view on LGTM.com new alerts:
|
b16332e
to
5bdc7e0
Compare
This pull request introduces 1 alert when merging 5bdc7e0 into 3d13faf - view on LGTM.com new alerts:
|
d24f4dd
to
c98374b
Compare
This pull request introduces 3 alerts when merging c98374b into 3d13faf - view on LGTM.com new alerts:
|
c98374b
to
38e866c
Compare
Add new API endpoint for listing or marking source conversation items that have been seen by a journalist. Add utility method to mark a heterogeneous collection of Submission and Reply objects seen. Add Submission.is_file and Submission.is_message to encapsulate the characterization based on filename.
With the addition of journalist_app.utils.mark_seen, it can replace the helper methods in tests/utils/db_helper.py, and the ad hoc logic to mark things seen in journalist_app/col.py.
38e866c
to
3542b67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first pass through the code - going to start manually testing
@@ -212,7 +211,23 @@ def __init__(self, source: Source, filename: str) -> None: | |||
def __repr__(self) -> str: | |||
return '<Submission %r>' % (self.filename) | |||
|
|||
def to_json(self) -> 'Dict[str, Union[str, int, bool]]': | |||
@property | |||
def is_file(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought about doing this myself in #5505 but the pr was already so large. nice change.
def to_json(self) -> "Dict[str, Union[str, int, bool]]": | ||
seen_by = { | ||
f.journalist.uuid for f in SeenFile.query.filter(SeenFile.file_id == self.id) | ||
if f.journalist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see, so this won't include the fact that there is a deleted journalist who saw a file. gonna keep reviewing and will cycle back to this. could be an issue because we still send "deleted" uuids for replies when journalists are deleted. this takes a different course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not. I didn't see any way for sensible inclusion of those records in seen_by
here. We do have Submission.seen
, which will reflect those, and until we start keeping deleted journalists around, we can't distinguish between the records for the submission in the seen tables anyway, so since the only purpose of those rows at this point is establishing the global seen state, I thought Submission.seen
the right answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also replies we have to worry about which don't have a global seen state, but I definitely see why you made this choice. Agreed that implementing #5467 + global user account for data migration will make this work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replies do have a global seen state: if one exists, its creator has seen it. SeenReply
can tell us who else has seen it, but only if journalist_id
is not null, so again, I didn't see any point in including records where it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detailed test plan checks out, functionality matches expectations. Visual review of the diff was smooth, as well. As discussion during review indicates, we should queue up some "v2" refinements for the API.
Status
Ready for review
Description of Changes
Add new API endpoint for listing or marking source conversation items that have been seen by a journalist.
Add utility method to mark a heterogeneous collection of Submission and Reply objects seen.
Add Submission.is_file and Submission.is_message to encapsulate the characterization based on filename.
Fixes #5475.
Testing
Run the dev server with
make dev
.Get an API token as the
journalist
user:List current submissions:
All should have a
seen_by
property, currently an empty list.Mark a message seen:
Replace the UUID with one from one of the messages in the response from the
/submissions
endpoint, of course.Mark the same message seen again. There should be no error.
Retrieve
/submissions
again. The message'sseen_by
list should now contain your journalist account's UUID.Visit the source of that message in the journalist interface. The message you marked should not be listed in bold text. Clicking "Select unread" should not select that message.
Visit the source list in the journalist interface. Select the source of the message you marked and click "Download Unread". The zip file you receive should not contain the seen message.
Via the source interface, upload a file, then retrieve
/submissions
again, and mark the file seen:Replace the UUID with that of the file you just uploaded, of course.
Repeat the checks in the journalist interface that you performed for a seen message, confirming that the file you marked seen is always considered read.
Get another API token, this time as the
dellsberg
journalist account.Retrieve the list of all replies:
Mark one of them read:
Hit
/replies
again and confirm that thedellsberg
account UUID appears in the reply'sseen_by
list.Deployment
Depends on the database changes in #5505.
Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made non-trivial code changes: