Skip to content

Commit

Permalink
add night filter for image redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronwmorris committed Sep 3, 2024
1 parent a436e31 commit 88f7e9d
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions indi_allsky/flask/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,22 @@ def dispatch_request(self):


def getLatestImage(self, camera_id, night=None):
latest_image_entry = self.model.query\
.join(self.model.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.order_by(self.model.createDate.desc())\
.first()
if isinstance(night, type(None)):
latest_image_entry = self.model.query\
.join(self.model.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.order_by(self.model.createDate.desc())\
.first()
else:
# filter based on night
night_bool = bool(int(night))

latest_image_entry = self.model.query\
.join(self.model.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(self.model.night == night_bool)\
.order_by(self.model.createDate.desc())\
.first()


return latest_image_entry
Expand Down Expand Up @@ -485,11 +496,22 @@ def dispatch_request(self):


def getLatestImage(self, camera_id, night=None):
latest_image_entry = self.model.query\
.join(self.model.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.order_by(self.model.createDate.desc())\
.first()
if isinstance(night, type(None)):
latest_image_entry = self.model.query\
.join(self.model.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.order_by(self.model.createDate.desc())\
.first()
else:
# filter based on night
night_bool = bool(int(night))

latest_image_entry = self.model.query\
.join(self.model.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(self.model.night == night_bool)\
.order_by(self.model.createDate.desc())\
.first()


return latest_image_entry
Expand Down

0 comments on commit 88f7e9d

Please sign in to comment.