From 238b0f530546a59aebd71dbc69737679b1f530b0 Mon Sep 17 00:00:00 2001 From: pablomartincalvo Date: Thu, 18 Oct 2018 22:36:10 +0200 Subject: [PATCH] Retoques menores en refresher. --- .idea/workspace.xml | 296 +++++++++++++++++---------------- db_layer/capturas_interface.py | 5 +- refresher/refresher.py | 10 +- 3 files changed, 163 insertions(+), 148 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f0b13aa..ea79b5b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,7 @@ - - @@ -32,12 +30,12 @@ - + - + @@ -46,15 +44,15 @@ - + - + - - + + @@ -85,32 +83,33 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + + @@ -119,17 +118,8 @@ - - - - - - - - - - - + + @@ -159,7 +149,7 @@ - + @@ -171,8 +161,8 @@ - - + + @@ -180,13 +170,13 @@ - - + + - - - + + + @@ -247,9 +237,9 @@ @@ -327,7 +317,7 @@ - + - - - + + + @@ -549,7 +539,14 @@ @@ -563,16 +560,15 @@ - - + - + @@ -648,7 +644,8 @@ - @@ -658,6 +655,11 @@ 38 @@ -817,13 +819,6 @@ - - - - - - - @@ -838,16 +833,6 @@ - - - - - - - - - - @@ -855,51 +840,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -909,10 +849,80 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/db_layer/capturas_interface.py b/db_layer/capturas_interface.py index 358084c..f573643 100644 --- a/db_layer/capturas_interface.py +++ b/db_layer/capturas_interface.py @@ -49,17 +49,16 @@ class CapturasInterface(): ON da.ad_url LIKE CONCAT('%', uc.referencia, '%') WHERE uc.fecha_captura < (NOW() - INTERVAL 10 day) AND da.ad_url is null + ORDER BY RAND() LIMIT 1 """ cursor_result = self.anunciosdb.query(query_statement, dictionary=True) try: - return c + return cursor_result.fetchone() except: return None - - capturas_interface = CapturasInterface() diff --git a/refresher/refresher.py b/refresher/refresher.py index 367bead..36b144f 100644 --- a/refresher/refresher.py +++ b/refresher/refresher.py @@ -2,16 +2,17 @@ from time import sleep from db_layer.capturas_interface import capturas_interface from db_layer.capturing_tasks_interface import capturing_interface + class Refresher: def start(self): while True: - sleep(30) + sleep(1) if capturas_interface.old_ads_exist(): old_ad = capturas_interface.get_old_ad() - capturing_interface.create_capturing_task(old_ad['referencia']) + capturing_interface.create_capturing_task(str(old_ad['referencia'])) @staticmethod def dead_ad_checker(html): @@ -26,6 +27,11 @@ class Refresher: return False +if __name__ == '__main__': + refresher = Refresher() + refresher.start() + +