Esempio n. 1
0
    def __init__(self, path_to_bq, client_name, placement, login, password,
                 params_for_report_dict, path_to_save):
        self.path_to_save = path_to_save
        self.email_password = password
        self.email_user = login
        self.placement = placement
        self.client_name = client_name
        self.bq = BigQuery(path_to_bq)
        self.data_set_id = f"{client_name}_Email_{placement}"
        """
        params_for_report_dict: {"REPORT": [{"type": "STRING", "description": "desk", "param": "Impressions"}, 
                                            {"type": "FLOAT", "description": "desk", "param": "clicks"}]}
        """

        self.report_dict = {}
        for report_name, params in params_for_report_dict.items():
            self.report_dict.setdefault(report_name, {})
            for element in params:
                self.report_dict[report_name].update({
                    element['param']: {
                        "type": element['type'],
                        "mode": "NULLABLE",
                        "description": element["description"]
                    }
                })

        self.tables_with_schema, self.fields = create_fields(
            client_name, "Email", self.report_dict, placement)

        self.bq.check_or_create_data_set(self.data_set_id)
        self.bq.check_or_create_tables(self.tables_with_schema,
                                       self.data_set_id)
Esempio n. 2
0
    def __init__(self, ct_site_id, ct_token, client_name, path_to_bq, date_from, date_to, report_range):
        self.__ct_token = ct_token
        self.ct_site_id = ct_site_id
        self.node_url = "https://api-node9.calltouch.ru/calls-service/RestAPI/requests/"
        self.__url = f'http://api.calltouch.ru/calls-service/RestAPI/{ct_site_id}/'
        self.bq = BigQuery(path_to_bq)
        self.client_name = client_name
        self.date_from = date_from
        self.date_to = date_to
        self.data_set_id = f"{client_name}_Calltouch_{ct_site_id}"
        self.report_range = report_range
        self.report_dict = {
            "CALLS": {
                "fields": {
                    'date': {"type": "DATE", "mode": "NULLABLE", "description": "Call day :DATE"},
                    'callUrl': {"type": "STRING", "mode": "NULLABLE", "description": "Call URL :STRING"},
                    'uniqueCall': {"type": "BOOLEAN", "mode": "NULLABLE", "description": "Unique Call :BOOLEAN"},
                    'utmContent': {"type": "STRING", "mode": "NULLABLE", "description": "UTM Content :STRING"},
                    'source': {"type": "STRING", "mode": "NULLABLE", "description": "Source :STRING"},
                    'waitingConnect': {"type": "FLOAT", "mode": "NULLABLE", "description": "Waiting connect :FLOAT"},
                    'ctCallerId': {"type": "STRING", "mode": "NULLABLE", "description": "Calltouch Caller ID :STRING"},
                    'keyword': {"type": "STRING", "mode": "NULLABLE", "description": "Keyword :STRING"},
                    'utmSource': {"type": "STRING", "mode": "NULLABLE", "description": "UTM Source :STRING"},
                    'sipCallId': {"type": "STRING", "mode": "NULLABLE", "description": "Sip Call ID :STRING"},
                    'utmCampaign': {"type": "STRING", "mode": "NULLABLE", "description": "UTM Campaign :STRING"},
                    'phoneNumber': {"type": "STRING", "mode": "NULLABLE", "description": "Phone number :STRING"},
                    'uniqTargetCall': {"type": "BOOLEAN", "mode": "NULLABLE", "description": "Uniq Call :BOOLEAN"},
                    'utmMedium': {"type": "STRING", "mode": "NULLABLE", "description": "UTM Medium :BOOLEAN"},
                    'city': {"type": "STRING", "mode": "NULLABLE", "description": "City :STRING"},
                    'yaClientId': {"type": "STRING", "mode": "NULLABLE", "description": "Yandex Client_ID :STRING"},
                    'medium': {"type": "STRING", "mode": "NULLABLE", "description": "Medium :STRING"},
                    'duration': {"type": "FLOAT", "mode": "NULLABLE", "description": "Call duration :FLOAT"},
                    'callbackCall': {"type": "BOOLEAN", "mode": "NULLABLE", "description": "Callback call :BOOLEAN"},
                    'successful': {"type": "BOOLEAN", "mode": "NULLABLE", "description": "Successful :BOOLEAN"},
                    'callId': {"type": "STRING", "mode": "NULLABLE", "description": "Call ID :STRING"},
                    'clientId': {"type": "STRING", "mode": "NULLABLE", "description": "Google Client_ID :STRING"},
                    'callerNumber': {"type": "STRING", "mode": "NULLABLE", "description": "Caller number :STRING"},
                    'utmTerm': {"type": "STRING", "mode": "NULLABLE", "description": "UTM Term :STRING"},
                    'sessionId': {"type": "STRING", "mode": "NULLABLE", "description": "Session ID :STRING"},
                    'targetCall': {"type": "BOOLEAN", "mode": "NULLABLE", "description": "Target Call :BOOLEAN"},
                    'AUTO_PR': {"type": "STRING", "mode": "NULLABLE", "description": "AUTO Tags :STRING"},
                    'MANUAL': {"type": "STRING", "mode": "NULLABLE", "description": "MANUAL Tags :STRING"}
                }}}

        self.tables_with_schema, self.fields = create_fields(client_name, "Calltouch", self.report_dict, ct_site_id)

        self.bq.check_or_create_data_set(self.data_set_id)
        self.bq.check_or_create_tables(self.tables_with_schema, self.data_set_id)
Esempio n. 3
0
    def __init__(self, client_id, client_secret, client_name, path_to_bq,
                 date_from, date_to):
        self.client_id = client_id
        self.access_token = ""
        self.client_secret = client_secret
        self.client_name = client_name
        self.data_set_id = f"{client_name}_Hybrid"
        self.path_to_bq = path_to_bq
        self.bq = BigQuery(path_to_bq)
        self.date_from = date_from
        self.date_to = date_to
        self.url = "https://api.hybrid.ru/"

        self.report_dict = {
            "CAMPAIGNS": {
                "fields": {
                    "Id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "CampaignID :STRING"
                    },
                    "Name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Campaign name :STRING"
                    }
                }
            },
            "CAMPAIGN_STAT": {
                "fields": {
                    "Day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    },
                    "ImpressionCount": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Impressions :INTEGER"
                    },
                    "ClickCount": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Clicks :INTEGER"
                    },
                    "Reach": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Reach :INTEGER"
                    },
                    "CTR": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "CTR :FLOAT"
                    },
                    "id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "CampaignID :STRING"
                    }
                }
            },
            "ADVERTISER_STAT": {
                "fields": {
                    "Day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    },
                    "ImpressionCount": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Impressions :INTEGER"
                    },
                    "ClickCount": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Clicks :INTEGER"
                    },
                    "Reach": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Reach :INTEGER"
                    },
                    "CTR": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "CTR :FLOAT"
                    }
                }
            }
        }
        self.tables_with_schema, self.fields = create_fields(
            client_name, "Hybrid", self.report_dict, None)

        self.bq.check_or_create_data_set(self.data_set_id)
        self.bq.check_or_create_tables(self.tables_with_schema,
                                       self.data_set_id)
Esempio n. 4
0
    def __init__(self, counter, access_token, client_name, path_to_bq,
                 date_from, date_to):
        self.__request_url = f"https://api-metrika.yandex.net/management/v1/counter/{counter}/"
        self.__source = 'visits'
        self.date_from = date_from
        self.date_to = date_to
        self.counter_id = counter
        self.client_name = client_name
        self.data_set_id = f"{client_name}_YMLogs_{counter}"
        self.path_to_bq = path_to_bq
        self.bq = BigQuery(path_to_bq)
        self.__access_token = access_token
        self.date_range = slice_date_on_period(date_from, date_to, 1)
        self.fields = 'ym:s:visitID,ym:s:counterID,ym:s:date,ym:s:isNewUser,ym:s:clientID,ym:s:pageViews,' \
                      'ym:s:visitDuration,ym:s:bounce,ym:s:regionCity,ym:s:UTMCampaign,ym:s:UTMContent,' \
                      'ym:s:UTMMedium,ym:s:UTMSource,ym:s:UTMTerm,ym:s:deviceCategory'

        self.report_dict = {
            "YMLogs": {
                "fields": {
                    "ym_s_visitID": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Visit ID :INTEGER"
                    },
                    "ym_s_counterID": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Counter ID :INTEGER"
                    },
                    "ym_s_date": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Date :DATE"
                    },
                    "ym_s_isNewUser": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Is new user :INTEGER"
                    },
                    "ym_s_clientID": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "YA client ID :STRING"
                    },
                    "ym_s_pageViews": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Page views :INTEGER"
                    },
                    "ym_s_visitDuration": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Visit duration :FLOAT"
                    },
                    "ym_s_bounces": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Bounce :INTEGER"
                    },
                    "ym_s_regionCity": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Region city :STRING"
                    },
                    "ym_s_UTMCampaign": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "UTMCampaign :STRING"
                    },
                    "ym_s_UTMContent": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "UTMContent :STRING"
                    },
                    "ym_s_UTMMedium": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "UTMMedium :STRING"
                    },
                    "ym_s_UTMSource": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "UTMSource :STRING"
                    },
                    "ym_s_UTMTerm": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "UTMTerm :STRING"
                    }
                }
            }
        }

        self.tables_with_schema, self.fields = create_fields(
            client_name, "YMLogs", self.report_dict, counter)

        self.bq.check_or_create_data_set(self.data_set_id)
        self.bq.check_or_create_tables(self.tables_with_schema,
                                       self.data_set_id)
Esempio n. 5
0
    def __init__(self, token, account, client_name, date_from, date_to,
                 path_to_bq):
        self.date_from = date_from
        self.date_to = date_to
        self.path_to_bq = path_to_bq
        self.bq = BigQuery(path_to_bq)
        self.token = token
        self.account = account
        self.client_name = client_name
        self.data_set_id = f"{self.client_name}_Facebook_{self.account[4:]}"
        self.date_range = slice_date_on_period(date_from, date_to, 5)

        self.report_dict = {
            "ADS_STAT": {
                "fields": {
                    "clicks": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "impressions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "spend": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p100_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p25_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p50_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_30_sec_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p75_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p95_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_thruplay_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_avg_time_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "conversions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "ad_id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "ad_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "campaign_id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "campaign_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "adset_id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "adset_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "date_start": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    }
                }
            },
            "CAMPAIGN_STAT": {
                "fields": {
                    "clicks": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "impressions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "reach": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "spend": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "date_start": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "campaign_id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "campaign_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p100_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p25_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p50_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_30_sec_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p75_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_p95_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_thruplay_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "video_avg_time_watched_actions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "conversions": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    }
                }
            },
            "ADSETS_STAT": {
                "fields": {
                    "reach": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "ad_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "adset_id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "adset_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "campaign_id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "campaign_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "ad_id": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "frequency": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    },
                    "date_start": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Copies :STRING"
                    }
                }
            }
        }

        self.tables_with_schema, self.fields = create_fields(
            client_name, "Facebook", self.report_dict, account[4:])

        self.bq.check_or_create_data_set(self.data_set_id)
        self.bq.check_or_create_tables(self.tables_with_schema,
                                       self.data_set_id)
Esempio n. 6
0
    def __init__(self, access_token, account_id, client_id, client_name,
                 path_to_bq, date_from, date_to):
        self.__access_token = access_token
        self.data_set_id = f"{client_name}_VKontakte_{client_id}"
        self.__v = "5.101"
        self.__method_url = "https://api.vk.com/method/"
        self.account_id = account_id
        self.bq = BigQuery(path_to_bq)
        self.client_id = client_id
        self.client_name = client_name
        self.date_from = date_from
        self.date_to = date_to

        self.report_dict = {
            "CAMPAIGNS": {
                "fields": {
                    "id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Campaign ID :INTEGER"
                    },
                    "type": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Campaign type :STRING"
                    },
                    "name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Campaign name :STRING"
                    }
                }
            },
            "ADS": {
                "fields": {
                    "id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad ID :INTEGER"
                    },
                    "campaign_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Campaign ID :INTEGER"
                    },
                    "goal_type": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Goal type :INTEGER"
                    },
                    "cost_type": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Cost type :INTEGER"
                    },
                    "category1_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Category1 ID :INTEGER"
                    },
                    "category2_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Category2 ID :INTEGER"
                    },
                    "age_restriction": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Age restriction :INTEGER"
                    },
                    "name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Ad name :STRING"
                    },
                    "ad_format": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad format :INTEGER"
                    },
                    "ad_platform": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Ad platform :STRING"
                    }
                }
            },
            "CAMPAIGN_STAT": {
                "fields": {
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    },
                    "spent": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Spent :FLOAT"
                    },
                    "impressions": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Impressions :INTEGER"
                    },
                    "clicks": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Clicks :INTEGER"
                    },
                    "reach": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Reach :INTEGER"
                    },
                    "join_rate": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Join to group :INTEGER"
                    },
                    "campaign_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Campaign ID :INTEGER"
                    },
                    'lead_form_sends': {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Lead form :INTEGER"
                    },
                    'goals': {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Goals :INTEGER"
                    }
                }
            },
            "ADS_STAT": {
                "fields": {
                    "ad_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad ID :INTEGER"
                    },
                    "clicks": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Clicks :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    },
                    "impressions": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Impressions :INTEGER"
                    },
                    "join_rate": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Join to group :INTEGER"
                    },
                    "reach": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Reach :INTEGER"
                    },
                    "spent": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Spent :FLOAT"
                    },
                    'lead_form_sends': {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Lead form :INTEGER"
                    },
                    'goals': {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Goals :INTEGER"
                    }
                }
            },
            "SEX_STAT": {
                "fields": {
                    "impressions_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Imp rate :FLOAT"
                    },
                    "clicks_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Clicks rate :FLOAT"
                    },
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Param value :STRING"
                    },
                    "ad_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad ID :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            },
            "AGE_STAT": {
                "fields": {
                    "impressions_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Imp rate :FLOAT"
                    },
                    "clicks_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Clicks rate :FLOAT"
                    },
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Param value :STRING"
                    },
                    "ad_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad ID :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            },
            "SEX_AGE_STAT": {
                "fields": {
                    "impressions_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Imp rate :FLOAT"
                    },
                    "clicks_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Clicks rate :FLOAT"
                    },
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Param value :STRING"
                    },
                    "ad_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad ID :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            },
            "CITIES_STAT": {
                "fields": {
                    "impressions_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Imp rate :FLOAT"
                    },
                    "clicks_rate": {
                        "type": "FLOAT",
                        "mode": "NULLABLE",
                        "description": "Clicks rate :FLOAT"
                    },
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Param value :STRING"
                    },
                    "ad_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad ID :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    },
                    "name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "City name :STRING"
                    }
                }
            },
            "POST_REACH": {
                "fields": {
                    "id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Ad ID :INTEGER"
                    },
                    "reach_subscribers": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Reach subscribers :INTEGER"
                    },
                    "reach_total": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Reach total :INTEGER"
                    },
                    "links": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Link :INTEGER"
                    },
                    "to_group": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "To group :INTEGER"
                    },
                    "join_group": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Join group :INTEGER"
                    },
                    "report": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Report :INTEGER"
                    },
                    "hide": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Hide :INTEGER"
                    },
                    "unsubscribe": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Unsubscribe :INTEGER"
                    },
                    "video_views_start": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Video start :INTEGER"
                    },
                    "video_views_3s": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Video 3s :INTEGER"
                    },
                    "video_views_10s": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Video 10s :INTEGER"
                    },
                    "video_views_25p": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Video 25p :INTEGER"
                    },
                    "video_views_50p": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Video 50p :INTEGER"
                    },
                    "video_views_75p": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Video 75p :INTEGER"
                    },
                    "video_views_100p": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Video 100p :INTEGER"
                    }
                }
            },
            "LEAD_FORMS": {
                "fields": {
                    "form_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Form ID :INTEGER"
                    },
                    "group_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Group ID :INTEGER"
                    },
                    "name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Name :STRING"
                    },
                    "title": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Title :STRING"
                    },
                    "description": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Description :STRING"
                    },
                    "site_link_url": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Site link URL :STRING"
                    },
                    "url": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "URL :STRING"
                    }
                }
            },
            "LEADS": {
                "fields": {
                    "lead_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Lead ID :INTEGER"
                    },
                    "user_id": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "User ID :INTEGER"
                    },
                    "date": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    },
                    "first_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "First name :STRING"
                    },
                    "phone_number": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Phone number :STRING"
                    },
                    "patronymic_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Patronymic name :STRING"
                    },
                    "last_name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Last name :STRING"
                    },
                    "email": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Email :STRING"
                    }
                }
            },
            "GROUP_ACTIVITY": {
                "fields": {
                    "copies": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Copies :INTEGER"
                    },
                    "hidden": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Hidden :INTEGER"
                    },
                    "likes": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Likes :INTEGER"
                    },
                    "subscribed": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Subscribed :INTEGER"
                    },
                    "unsubscribed": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Unsubscribed :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Site link URL :DATE"
                    }
                }
            },
            "GROUP_AGE_STAT": {
                "fields": {
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Age param :STRING"
                    },
                    "count": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Count of users :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            },
            "GROUP_CITIES_STAT": {
                "fields": {
                    "count": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Count of users :INTEGER"
                    },
                    "name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "City name :STRING"
                    },
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "City ID :STRING"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            },
            "GROUP_COUNTRIES_STAT": {
                "fields": {
                    "code": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Country code :STRING"
                    },
                    "count": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Count of users :INTEGER"
                    },
                    "name": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Country name :STRING"
                    },
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Country ID :STRING"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            },
            "GROUP_SEX_STAT": {
                "fields": {
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Gender param :STRING"
                    },
                    "count": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Count of users :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            },
            "GROUP_SEX_AGE_STAT": {
                "fields": {
                    "value": {
                        "type": "STRING",
                        "mode": "NULLABLE",
                        "description": "Age & Gender param :STRING"
                    },
                    "count": {
                        "type": "INTEGER",
                        "mode": "NULLABLE",
                        "description": "Count of users :INTEGER"
                    },
                    "day": {
                        "type": "DATE",
                        "mode": "NULLABLE",
                        "description": "Day :DATE"
                    }
                }
            }
        }

        self.tables_with_schema, self.fields = create_fields(
            client_name, "VKontakte", self.report_dict, client_id)
        self.bq.check_or_create_data_set(self.data_set_id)
        self.bq.check_or_create_tables(self.tables_with_schema,
                                       self.data_set_id)

        "https://oauth.vk.com/authorize?client_id=7446867&display=page&redirect_uri=http://localhost:8000/auth/vkontakte&scope=pages,ads,offline,groups,stats,email&response_type=code&v=5.103"
        "https://oauth.vk.com/access_token?client_id=7446867&client_secret=3yU3omb66HfxRlujOKxJ&redirect_uri=http://localhost:8000/auth/vkontakte&code=26ffc758fd72e8f81c"
Esempio n. 7
0
 def __init__(self, path_to_json, db_name, db_table):
     logging.Handler.__init__(self)
     self.bq = BigQuery(path_to_json)
     self.db_name = db_name
     self.db_table = db_table