Skip to content

Commit

Permalink
fix(analysis): safeguard query when there's only one subject
Browse files Browse the repository at this point in the history
  • Loading branch information
ttngu207 committed Dec 13, 2024
1 parent 0910695 commit fef4465
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion aeon/dj_pipeline/analysis/block_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ def make(self, key):
rfid2subj_map = {
int(lab_id): subj_name
for subj_name, lab_id in zip(
*(subject.SubjectDetail.proj("lab_id") & f"subject in {tuple(subject_names)}").fetch(
*(subject.SubjectDetail.proj("lab_id")
& f"subject in {tuple(list(subject_names) + [''])}").fetch(
"subject", "lab_id"
),
strict=False,
Expand Down
8 changes: 5 additions & 3 deletions aeon/dj_pipeline/scripts/update_in_patch_rfid_timestamps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def update_in_patch_rfid_timestamps(block_key):
rfid2subj_map = {
int(lab_id): subj_name
for subj_name, lab_id in zip(
*(subject.SubjectDetail.proj("lab_id") & f"subject in {tuple(subject_names)}").fetch(
*(subject.SubjectDetail.proj("lab_id")
& f"subject in {tuple(list(subject_names) + [''])}").fetch(
"subject", "lab_id"
),
strict=False,
Expand Down Expand Up @@ -66,8 +67,9 @@ def update_in_patch_rfid_timestamps(block_key):

def main():
"""Update in_patch_rfid_timestamps for all blocks that are missing it."""
block_keys = BlockSubjectAnalysis & (
BlockSubjectAnalysis.Patch & "in_patch_rfid_timestamps IS NULL"
block_keys = (
BlockSubjectAnalysis
& (BlockSubjectAnalysis.Patch & "in_patch_rfid_timestamps IS NULL")
).fetch("KEY")
for block_key in block_keys:
try:
Expand Down

0 comments on commit fef4465

Please sign in to comment.