Skip to content

Commit

Permalink
fix submission page error for extended end date (#85)
Browse files Browse the repository at this point in the history
* fix submission page error for extended end date
  • Loading branch information
VineetBala-AOT authored Sep 12, 2024
1 parent d02057d commit 5d8fab4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions met-api/src/met_api/models/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,20 @@ def get_open(cls, survey_id) -> Survey:
"""Get an open survey."""
now = local_datetime().date() # Get the current PST date without the timestamp

end_date = (
db.session.query(Engagement.end_date)
.join(Survey, Engagement.id == Survey.engagement_id)
.filter(Survey.id == survey_id)
.first()
)
# Calculate the threshold time (8 hours after the end_date)
extended_end_date = Engagement.end_date + timedelta(days=1, hours=8)
extended_end_date = end_date[0] + timedelta(days=1, hours=8)

survey: Survey = db.session.query(Survey).filter_by(id=survey_id) \
.join(Engagement) \
.filter(or_(Engagement.status_id == Status.Published.value, Engagement.status_id == Status.Closed.value)) \
.filter(and_(func.date(Engagement.start_date) <= now, local_datetime() <= extended_end_date)) \
.filter(and_(func.date(Engagement.start_date) <= now,
local_datetime().replace(tzinfo=None) <= extended_end_date)) \
.join(EngagementStatus) \
.first()
return survey
Expand Down

0 comments on commit 5d8fab4

Please sign in to comment.