def get_report_data(self): report_data={} today=self.report_date report_data["report_date"]=self.report_date today_pre=datetime.strptime(self.report_date,"%Y-%m-%d")-timedelta(days=1) if datetime.strptime(self.report_date,"%Y-%m-%d")<=datetime.today(): apps_dict=AppIdListActive(today).get() report_data["apps_action"]=[] for appid,app_info in apps_dict.items(): appid_report=DateReport_APPID(today,appid).get() appid_des=AppIdDes(appid).get(True) if appid_des is None: appid_des= "" if appid_report is not None: app_info_out={} app_info_out["app_id"]=appid app_info_out["active_user"]=appid_report["active_user"] app_info_out["total_download"]=appid_report["total_download"] app_info_out["total_install"]=appid_report["total_install"] app_info_out["total_impression"]=appid_report["total_impression"] app_info_out["total_click"]=appid_report["total_click"] if "auto_install" in appid_report: app_info_out["auto_install"]=appid_report["auto_install"] else: app_info_out["auto_install"]=0 if "manual_install" in appid_report: app_info_out["manual_install"]=appid_report["manual_install"] else: app_info_out["manual_install"]=0 if "auto_conversion" in appid_report: app_info_out["auto_conversion"]=appid_report["auto_conversion"] else: app_info_out["auto_conversion"]=0 app_info_out["auto_rev"]=0 if "auto_rev" in appid_report: if appid_report["auto_rev"] is not None: app_info_out["auto_rev"]=appid_report["auto_rev"] app_info_out["r_rev"]=0 if "rob_rev" in appid_report: if appid_report["rob_rev"] is not None: app_info_out["r_rev"]=round(appid_report["rob_rev"],1) if "manual_conversion" in appid_report: app_info_out["manual_conversion"]=appid_report["manual_conversion"] else: app_info_out["manual_conversion"]=0 app_info_out["manual_rev"]=0 if "manual_rev" in appid_report: if appid_report["manual_rev"] is not None: app_info_out["manual_rev"]=appid_report["manual_rev"] app_info_out["total_conversion"]=app_info_out["manual_conversion"]+app_info_out["auto_conversion"] app_info_out["rev"]=round(app_info_out["manual_rev"]+app_info_out["auto_rev"],1) app_info_out["description"]=appid_des if appid_report["active_user"]>0: app_info_out["cdr"]=round(appid_report["total_install"]*100.0/appid_report["active_user"],2) else: app_info_out["cdr"]=-1 report_data["apps_action"].append(app_info_out) if len(report_data["apps_action"])<len(apps_dict): report_data["notice"]="Sorry, the data has not been prepared, you can active the data preparation by click the button and come back later (around 10 minutes)" return report_data
from Entity.appidreport import AppIdListActive,AppIdReport from datetime import datetime,timedelta from Entity.revenuereport import DailyRevenue from Entity.offer import OfferActiveList if __name__ == '__main__': today=datetime.today().strftime("%Y-%m-%d") today_pre=(datetime.today()-timedelta(days=1)).strftime("%Y-%m-%d") #if today_pre not in DailyRevenue().get(): DailyRevenue(today_pre).get() apps_dict=AppIdListActive(today).get() for appid,app_info in apps_dict.items(): AppIdReport(appid,today).get() print appid OfferActiveList(today).get()