Skip to content

Commit

Permalink
Verifico no agregar queries repetidas
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslavandeira committed Jul 2, 2018
1 parent 5d41070 commit ec671fa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions series_tiempo_ar_api/apps/analytics/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def _run_import(self):
not import_config_model.kong_api_id):
raise FieldError("Configuración de importación de analytics no inicializada")

response = self.exec_request(from_date=start_date, limit=self.limit)
response = self.exec_request(from_date=start_date,
limit=self.limit,
kong_api_id=import_config_model.kong_api_id)
count = response['count']
self._load_queries_into_db(response)
next_results = response['next']
Expand Down Expand Up @@ -74,20 +76,22 @@ def _load_queries_into_db(self, query_results):
params=parsed_querystring,
api_mgmt_id=result['id'],
))
self.loaded_api_mgmt_ids.update([result['id']])

Query.objects.bulk_create(queries)

def exec_request(self, url=None, **kwargs):
def exec_request(self, url=None, **params):
"""Wrapper sobre la llamada a la API de api-mgmt"""
if url and params:
raise ValueError

import_config_model = ImportConfig.get_solo()

if url is None:
url = import_config_model.endpoint

params = {'kong_api_id': import_config_model.kong_api_id}
params.update(kwargs)
return self.requests.get(
url,
headers=import_config_model.get_authorization_header(),
params=params
params=params,
).json()

0 comments on commit ec671fa

Please sign in to comment.