예제 #1
0
    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
예제 #2
0
def main(account_id):
    Log("info", "getting keyword performance from the api", "", account_id)

    report = Report(account_id, "", options)

    df = report.createDfWithAllDateRanges(account_id)

    if functions.dfIsEmpty(df):
        return

    # print df[df.google_id=="309491001346"].cpc_bid

    # remember column headers are as per the download here
    df["keyword_id"] = df.apply(lambda row: functions.addIdToDf(
        account_id, row["Keyword ID"], row["Ad group ID"]),
                                axis=1)
    df["id"] = df["keyword_id"]

    df = addParentId(df, account_id)  # our UUID from the keywords table

    df = report.basicProcessing(df)

    df = reportSpecificProcessing(df)

    report.writeToEntitiesTable(df, report, account_id)

    report.writeToPerformanceTable(df, report, account_id)
def main(account_id):
    Log("info", "getting campaign performance from the api", "", account_id)

    report = Report(account_id, "", options)

    df = report.createDfWithAllDateRanges(account_id)

    if functions.dfIsEmpty(df):
        return

    # remember column headers are as per the download here
    df["campaign_id"] = df.apply(
        lambda row: functions.addIdToDf(account_id, row["Campaign ID"]),
        axis=1)
    df["id"] = df["campaign_id"]

    df = report.basicProcessing(df)

    report.writeToEntitiesTable(df, report, account_id)

    report.writeToPerformanceTable(df, report, account_id)
def main(account_id):
    Log("info", "getting search query performance from the api", "",
        account_id)

    report = Report(account_id, "", options)

    df = report.createDfWithAllDateRanges(account_id)

    if functions.dfIsEmpty(df):
        return

    df = df.groupby(['Search term', 'date_range'], as_index=False).sum()

    df["search_query_id"] = df.apply(
        lambda row: functions.addIdToDf(account_id, row["Search term"]),
        axis=1)
    df["id"] = df["search_query_id"]

    df = report.basicProcessing(df)

    report.writeToEntitiesTable(df, report, account_id)
    report.writeToPerformanceTable(df, report, account_id)

    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
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"])