def get_quality(self, now): """ get iamge numbers by copyright """ year = now.split('-')[0] month = int(now.split('-')[1]) if int(month / 7) == 0: count = '01' if int(month / 7) == 1: count = '07' sql = "select count(*) as image_num, quality_level from \ (select image_info_%s%s.id, image_info_%s%s.has_copyright, \ image_profile.quality_level from image_info_%s%s join \ image_profile on image_info_%s%s.id = image_profile.image_id \ where image_info_%s%s.create_time like \'%s\') \ as b where has_copyright = 1 group by quality_level"\ %(year, count, year, count, year, count, year, count, year, count, now.split(' ')[0] + '%') print sql try: with session_cpu_ic() as session: results = session.execute(sql).fetchall() if results is not None: return results except Exception as e: self.logger.exception("get_quality %s" % str(e))
def get_result(self, now): """ get image number by source name """ year = now.split('-')[0] month = int(now.split('-')[1]) if int(month/7) == 0: count = '01' if int(month/7) == 1: count = '07' sql = "select imagenum, source_name from (select count(*) as \ imagenum, source_name from image_info_%s%s\ where create_time > \'%s\' and status =3 group by source_name) as image_num order \ by imagenum desc limit 100"\ %(year, count ,now) print sql #sql = "select imagenum, source_name from (select count(*) as \ # imagenum, source_name from image_info_%s%s\ # where create_time between \'2017-05-13 00:00:00\' and \'2017-05-14 00:00:00\'\ # and status =3 group by source_name) as image_num order \ # by imagenum desc limit 100"\ # %(year, month) #print sql try: with session_cpu_ic() as session: results = session.execute(sql).fetchall() if results is not None: return results except Exception as e: self.logger.exception("get_results %s" % str(e))
def get_result(self, now): """ get image numbers by cluster number """ sql = "select count(*) as cluster_num, valid_count from image_cluster_profile\ where create_time > \'%s\' group by valid_count" % (now) print sql try: with session_cpu_ic() as session: results = session.execute(sql).fetchall() if results is not None: return results except Exception as e: self.logger.exception("get_results %s" % str(e))
def get_result(self, now): """ get image numbers by copyright """ year = now.split('-')[0] month = int(now.split('-')[1]) month = '0' + str(int(month / 6) + 1) sql = "select count(*) AS image_num, has_copyright from image_info_%s%s\ group by has_copyright where create_time like \'%s\'"\ %(year, month, now.split(' ')[0] + '%') try: with session_cpu_ic() as session: results = session.execute(sql).fetchall() if results is not None: return results except Exception as e: self.logger.exception("get_results %s" % str(e))