-
Notifications
You must be signed in to change notification settings - Fork 19
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
multi ffqs fix #581
multi ffqs fix #581
Changes from 11 commits
a223a32
8da634e
a8409b7
60a84f1
321ce4d
6084b95
b781035
8ffe0a6
a2908e4
9102276
101667d
34cda80
c0c97c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,10 @@ def upsert_session(self, session): | |
{doupdateset} | ||
""", | ||
tuple([getattr(session, attr) for attr in self.COLS])) | ||
cur.execute("SELECT * FROM ag.vioscreen_sessions " | ||
"WHERE sessionId = %s", (session.sessionId,)) | ||
rows = cur.fetchall() | ||
print("Upserted rows:", rows) | ||
ayobi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return cur.rowcount == 1 | ||
|
||
def get_session(self, sessionId): | ||
|
@@ -168,12 +172,12 @@ def get_unfinished_sessions(self): | |
|
||
return not_in_vioscreen_sessions + incomplete_sessions | ||
|
||
def get_ffq_status_by_sample(self, sample_uuid): | ||
"""Obtain the FFQ status for a given sample | ||
def get_ffq_status_by_source(self, source_uuid): | ||
"""Obtain the FFQ status for a given source | ||
|
||
Parameters | ||
---------- | ||
sample_uuid : UUID4 | ||
source_uuid : UUID4 | ||
The UUID to check the status of | ||
|
||
Returns | ||
|
@@ -190,17 +194,17 @@ def get_ffq_status_by_sample(self, sample_uuid): | |
FROM ag.vioscreen_sessions AS vs | ||
JOIN ag.vioscreen_registry AS vr | ||
ON vs.username=vr.vio_id | ||
WHERE sample_id=%s""", (sample_uuid, )) | ||
WHERE source_id=%s""", (source_uuid, )) | ||
res = cur.fetchall() | ||
if len(res) == 0: | ||
return (False, False, None) | ||
elif len(res) == 1: | ||
status = res[0][0] | ||
is_complete = status == 'Finished' | ||
is_taken = status in ('Started', 'Review', 'Finished') | ||
return (is_complete, is_taken, status) | ||
else: | ||
raise ValueError("A sample should not have multiple FFQs") | ||
results = [] | ||
for status in res: | ||
is_complete = status[0] == 'Finished' | ||
is_taken = status[0] in ('Started', 'Review', 'Finished') | ||
results.append((is_complete, is_taken, status[0])) | ||
return results | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't changing the return value from a tuple to a list of tuples will break the code that uses this function? The unit tests work fine because they test the function in isolation, but is this still working when you try to run a sample summary report through microsetta-admin? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true, it does break. So, if the user has taken multiple FFQs for a particular sample, we'd probably need to change the columns for ffq-taken and ffq-complete to indicate which ffq they've taken and if that one was taken/complete? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's overkill for the sake of this particular function. If a sample (or source) is associated with more than one FFQ, let's return the one (and it's taken/complete statuses) that's temporally nearest to the sample collection date. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, in my latest commit I get the closest sample collection data in |
||
|
||
def get_missing_ffqs(self): | ||
"""The set of valid sessions which lack FFQ data | ||
|
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.
Given the change from sample to source, I think it makes sense to move this code block into the if statement on Line 51 (
if source is not None and source_type == Source.SOURCE_TYPE_HUMAN
). Additionally, it makes sense to harmonize what they're doing. For example,get_ffq_status_by_source
could returnTrue, True
butvio_id
could be None.I'd suggest first looking for a match including
sample_id
since a good chunk of historical data will include that. Failing an exact match withsample_id
you can fall back to a match on source.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.
So you're saying it'd be better to change
if source is not None and source_type == Source.SOURCE_TYPE_HUMAN
to first check for asample_id
match then fall back on source? Or when trying to getvio_id
? I have the latter to commit now.