survey-extraction/etl/daily_script.py
2025-03-19 09:14:26 +00:00

80 lines
3.4 KiB
Python

import os
from pdfReader.pdfReaderToText import pdfReaderToText
from etl.scraper.scraper import SharePointScraper, SharePointInstaller, WEEK_COMMENCING
from pprint import pprint, pformat
import logging
from etl.utils.logger import Logger
from etl.validator.validator import DomnaSharePointValidator
from collections import Counter
logger = Logger(name="main.py", level=logging.INFO).get_logger()
def main():
"""
This script returns a list of names that is misformatted in the sharepoint
"""
# Correct dates format checker
south_coast_scraper = SharePointScraper(SharePointInstaller.SOUTH_COAST_INSULATION)
south_coast_names = south_coast_scraper.list_of_names_that_has_the_wrong_date_format()
south_coast_submissions = south_coast_scraper.get_number_of_surverys_completed()
jjc_scraper = SharePointScraper(SharePointInstaller.JJC)
jjc_names = jjc_scraper.list_of_names_that_has_the_wrong_date_format()
jjc_coast_submission = jjc_scraper.get_number_of_surverys_completed()
SGEC = SharePointScraper(SharePointInstaller.SGEC)
sgec_names = SGEC.list_of_names_that_has_the_wrong_date_format()
sgec_submission = SGEC.get_number_of_surverys_completed()
BAXTER_KELLY = SharePointScraper(SharePointInstaller.BAXTER_KELLY)
b_names = BAXTER_KELLY.list_of_names_that_has_the_wrong_date_format()
BAXTER_KELLY_submissions = BAXTER_KELLY.get_number_of_surverys_completed()
total_dict = dict(Counter(south_coast_submissions) + Counter(jjc_coast_submission) + Counter(sgec_submission) + Counter(BAXTER_KELLY_submissions))
total = 0
for item, val in total_dict.items():
total += val
logger.info("Good morning Cyrus")
logger.info("-------------------------------------------")
logger.info("-------------WRONG DATE FORMAT-------------")
logger.info("-------------------------------------------")
if south_coast_names:
logger.info("South Coast with wrong date format:")
logger.info(pformat(south_coast_names))
if jjc_names:
logger.info("JJC with wrong date format")
logger.info(pformat(jjc_names))
if sgec_names:
logger.info("SGEC with wrong date format")
logger.info(pformat(sgec_names))
if b_names:
logger.info("Baxter Kelly with wrong date format")
logger.info(pformat(b_names))
logger.info("-")
logger.info("------EACH PRE SITE NOTES SUBMISSIONS------")
logger.info("-------------------------------------------")
logger.info(f"For week commencing: {WEEK_COMMENCING}")
logger.info(f"South Coast Submissions: {pformat(south_coast_submissions)}")
logger.info(f"JJC: {pformat(jjc_coast_submission)}")
logger.info(f"SGEC Submissions: {pformat(sgec_submission)}")
logger.info(f"Baxter Kelly: {pformat(BAXTER_KELLY_submissions)}")
logger.info("-------------------------------------------")
logger.info("-----TOTAL PRE SITE NOTES SUBMISSIONS------")
logger.info("-------------------------------------------")
logger.info(f"For week commencing: {WEEK_COMMENCING}")
logger.info(f"Total Submissions: {total}")
logger.info(f"Submissions per Surveyor: {pformat(total_dict)}")
logger.info("-------------------------------------------")
logger.info("---BROUGHT TO YOU BY THE DOMNA TECH TEAM---")
logger.info("-------------------------------------------")
if __name__ == "__main__":
main()