Skip to content

Commit

Permalink
Several times, have seen a random failure in testing - a nonsense SQL…
Browse files Browse the repository at this point in the history
… complaint about a count() call (that works 99.9% of the time). Replace with SQLAlchemy `.first()` seems to fix.
  • Loading branch information
pbugni committed Oct 23, 2024
1 parent fb5112e commit 2f56cf7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions portal/models/qb_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def _sync_timeline(self):

completed = QBT.query.filter(QBT.user_id == self.user.id).filter(
QBT.research_study_id == self.research_study_id).filter(
QBT.status == OverallStatus.completed).count()
self.at_least_one_completed = completed > 0
QBT.status == OverallStatus.completed).with_entities(QBT.id).first()
self.at_least_one_completed = completed is not None

# Obtain withdrawal date if applicable
withdrawn = QBT.query.filter(QBT.user_id == self.user.id).filter(
Expand Down

0 comments on commit 2f56cf7

Please sign in to comment.