def main(account_id): Log("info", "getting account performance reports from the api", "", account_id) report = Report(account_id, "last_30_days", options) report.createAccountDirectory() report.createReportDirectory() report.downloadReport(account_id, options["where_string"]) df = report.convertCsvToDataframe() df = report.basicProcessing(df) df = reportSpecificProcessing(df, account_id) # for col in df.columns: # print col # return deleteExitingData(account_id, options["performance_table_name"]) report.writeDataframeToTable(df, options["performance_table_name"])
def main(self, account_id): if (Settings()).envvars["APP_DEBUG"] == "true": return 1 date_range = self.getDateRange() report = Report(account_id, date_range, options) report.createAccountDirectory() report.createReportDirectory() try: report.downloadReport(account_id, options["where_string"]) except requests.exceptions.ConnectionError: print("NO INTERNET CONNECTION") if Settings().envvars["APP_ENV"] == 'production': raise return 1000 except TransportError: print("NO INTERNET CONNECTION") if Settings().envvars["APP_ENV"] == 'production': raise return 1000 df = report.convertCsvToDataframe() df['Cost'] = df['Cost'] / 1000000 df = df.sort_values('Day') df = df.reset_index() return df
def main(account_id): Log("info", "getting ad performance from the api", "", account_id) settings = Settings() for date_range in settings.date_ranges: report = Report(account_id, date_range, options) report.createAccountDirectory() report.createReportDirectory() report.downloadReport(account_id, options["where_string"]) df = report.convertCsvToDataframe() if functions.dfIsEmpty(df): continue df = report.basicProcessing(df) df = reportSpecificProcessing(df, date_range, account_id) deleteExitingData(account_id, date_range, 'ad_performance_reports') report.writeDataframeToTable(df, 'ad_performance_reports') deleteExitingData(account_id, date_range, 'advert_performance') report.writeDataframeToTable(df, 'advert_performance') if functions.dfIsEmpty(df): return if 'advert_id' not in df.columns: Log('error', 'advert_id not in df columns', df.columns, account_id) return df["id"] = df["advert_id"] df = addParentId(df, account_id) # our UUID from the adverts table report.writeToEntitiesTable( df, report, account_id) # add the final date range data to adverts