def get_next(self): if self.filter: filter = ' and ' + SQL_PHOTO_FILTER else: filter = '' query = '''select t1.id from photo t1 where t1.time_taken > %%s %s order by t1.time_taken asc limit 1''' % filter return Photo(worm.query_for_value(query, (self._time_taken, )))
def get_voted_photos(self, filter=False): if filter: filter = ' and ' + SQL_PHOTO_FILTER else: filter = '' return worm.query_for_value(''' select count(t1.*) from photo t1 where exists (select * from photo_score s where s.photo = t1.id)''' + filter)
def get_photo_count(self): if self._filter: filter = ' and ' + SQL_PHOTO_FILTER else: filter = '' return worm.query_for_value(''' select count(t1.*) from photo t1 where substring(t1.time_taken from 1 for 7) = %%s %s''' % filter, (self._month, ))
def get_voted_photos(self, filter = False): if filter: filter = ' and ' + SQL_PHOTO_FILTER else: filter = '' return worm.query_for_value(''' select count(t1.*) from photo t1 where exists (select * from photo_score s where s.photo = t1.id)''' + filter)
def get_photo_count(self): if self._filter: filter = ' and ' + SQL_PHOTO_FILTER else: filter = '' return worm.query_for_value( ''' select count(t1.*) from photo t1 where substring(t1.time_taken from 1 for 7) = %%s %s''' % filter, (self._month, ))
def count(self, kind): return worm.query_for_value('select count(*) from ' + kind)