- {msg}
-
-
This is system generated mail. Please do not reply
+
+
+
+ {msg}
+
+
This is system generated mail. Please do not reply.
@@ -116,6 +117,44 @@ def init_tracker_tab(cur):
logging.info("++++++++++++++++ process tracker tab status ++++++++++++++++++++++")
cur.execute(f"""select * from process_tracker""")
logging.info(cur.fetchall())
+
+
+def get_status():
+ conn = psycopg2.connect(database=config.get('database'), user=config.get('db_user'),
+ password=config.get('db_pass'), host=config.get('db_host'),
+ port=config.get('db_port'))
+
+ conn.autocommit = True
+ cur = conn.cursor()
+
+ cur.execute(
+ f"""select count(1) from raena_spider_management.rce_category where rce_source_id = (select id from raena_spider_management.rce_source where source_name = 'Hasaki')""")
+ cat_count = cur.fetchone()[0]
+
+ cur.execute(f"""select count(1) from raena_spider_management.crawler_tracker_hasaki""")
+ product_total = cur.fetchone()[0]
+
+ cur.execute(f"""select count(1) from raena_spider_management.crawler_tracker_hasaki where flag = 1""")
+ product_successful = cur.fetchone()[0]
+
+ cur.execute(f"""select count(1) from raena_spider_management.crawler_tracker_hasaki where flag = 0""")
+ product_failed = cur.fetchone()[0]
+
+ msg = f"""
+
Hasaki Crawler run is completed. Please check the status below,
+
+
+ - Total Collected categories: {cat_count}
+ - Total Collected products for categories: {product_total}
+ - Total successfully collected products: {product_successful}
+ - Total failed to collect products: 0 else 'style="color: green;"'}>{product_failed}
+
+ """
+
+ cur.close()
+ conn.close()
+
+ return msg
@@ -143,8 +182,10 @@ if __name__ == "__main__":
cur.close()
conn.close()
+
+ msg = get_status()
- send_mail("Hasaki crawler run complete.")
+ send_mail(msg)
except Exception as e:
logging.info("Error: ".format(e))