Beispiel #1
0
 def conflict_programs(self):
     return db.session.query(Program)\
             .filter_by(channel_id=self.channel_id)\
             .filter(db.or_(
                 db.and_(Program.start_dt<self.start_dt, Program.end_dt>self.start_dt),
                 db.and_(Program.start_dt<self.end_dt, Program.end_dt>self.end_dt)
                 ))\
             .all()
Beispiel #2
0
    def get_mapped_programs(self,
            rating_threshold=7,
            rate_num_threshold=100,
            show_all=False,
            end_after_now=True):
        exp = db.session.query(Program) \
                .filter(db.and_(
                    Program.extra_id==ProgramExtra.id,
                    ProgramExtra.douban_movie_id==DoubanMovie.douban_movie_id,
                    DoubanMovie.rating>=rating_threshold,
                    DoubanMovie.rate_num>=rate_num_threshold))

        now = datetime.now()
        if not show_all:
            exp = exp.filter(Program.datenum>=now.strftime('%Y%m%d'))

        if end_after_now:
            exp = exp.filter(Program.end_dt>=now)

        return exp.all()