survey-extraction/etl/daily_script.py

68 lines
2.6 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))
logger.info("-------------------------------------------")
logger.info("Good morning Cyrus")
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(f"For week commencing: {WEEK_COMMENCING}")
logger.info(f"Submissions: {pformat(total_dict)}")
logger.info("-------------------------------------------")
# Make a quick script that checks if the Pictures folder exists in a certain fail directory
# Make a cron job in github runner for Cyrus for this
logger.info("Hope this helps! <3")
if __name__ == "__main__":
main()