Formatting.
This commit is contained in:
parent
cd9c3b6e39
commit
a79fc533ee
11 changed files with 231 additions and 204 deletions
|
|
@ -2,19 +2,20 @@ from core.mysql_wrapper import get_anunciosdb
|
|||
|
||||
|
||||
class CapturasInterface:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.anunciosdb = get_anunciosdb()
|
||||
|
||||
def insert_captura(self, ad_data):
|
||||
|
||||
columns = ', '.join(ad_data.keys())
|
||||
placeholders_string = ', '.join(['%s'] * len(ad_data))
|
||||
columns = ", ".join(ad_data.keys())
|
||||
placeholders_string = ", ".join(["%s"] * len(ad_data))
|
||||
|
||||
query_statement = """ INSERT INTO capturas
|
||||
( fecha_captura, {} )
|
||||
VALUES( NOW(), {} )""".format(columns, placeholders_string)
|
||||
VALUES( NOW(), {} )""".format(
|
||||
columns, placeholders_string
|
||||
)
|
||||
|
||||
query_parameters = tuple([v for v in ad_data.values()])
|
||||
|
||||
|
|
@ -71,7 +72,6 @@ class CapturasInterface:
|
|||
|
||||
return result > 0
|
||||
|
||||
|
||||
def get_not_geocoded_captura(self):
|
||||
query_statement = """
|
||||
SELECT *
|
||||
|
|
@ -82,17 +82,21 @@ class CapturasInterface:
|
|||
cursor_result = self.anunciosdb.query(query_statement, dictionary=True)
|
||||
return cursor_result.fetchone()
|
||||
|
||||
def update_geo_data(self, referencia, fecha_captura, latitude, longitude, precision):
|
||||
def update_geo_data(
|
||||
self, referencia, fecha_captura, latitude, longitude, precision
|
||||
):
|
||||
query_statement = """
|
||||
UPDATE anuncios.capturas
|
||||
SET latitud = %(latitud)s, longitud = %(longitud)s, `precision` = %(precision)s
|
||||
WHERE referencia = %(referencia)s AND fecha_captura = %(fecha_captura)s
|
||||
"""
|
||||
query_parameters = {'referencia': referencia,
|
||||
'fecha_captura': fecha_captura,
|
||||
'latitud': latitude,
|
||||
'longitud': longitude,
|
||||
'precision': precision}
|
||||
query_parameters = {
|
||||
"referencia": referencia,
|
||||
"fecha_captura": fecha_captura,
|
||||
"latitud": latitude,
|
||||
"longitud": longitude,
|
||||
"precision": precision,
|
||||
}
|
||||
|
||||
self.anunciosdb.query(query_statement, query_parameters)
|
||||
|
||||
|
|
@ -114,13 +118,15 @@ class CapturasInterface:
|
|||
AND (`t1`.`fecha_captura` BETWEEN %(start_date)s AND %(end_date)s)
|
||||
)
|
||||
"""
|
||||
query_parameters = {'start_date': start_date.strftime('%Y-%m-%d 00:00:00'),
|
||||
'end_date': end_date.strftime('%Y-%m-%d 00:00:00')}
|
||||
query_parameters = {
|
||||
"start_date": start_date.strftime("%Y-%m-%d 00:00:00"),
|
||||
"end_date": end_date.strftime("%Y-%m-%d 00:00:00"),
|
||||
}
|
||||
|
||||
cursor_result = self.anunciosdb.query(query_statement, query_parameters, dictionary=True)
|
||||
cursor_result = self.anunciosdb.query(
|
||||
query_statement, query_parameters, dictionary=True
|
||||
)
|
||||
return cursor_result.fetchall()
|
||||
|
||||
|
||||
capturas_interface = CapturasInterface()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue