From f268bf28f869c615721073175372567ab5e8424a Mon Sep 17 00:00:00 2001 From: frankknoll Date: Fri, 16 Jun 2023 21:53:07 +0200 Subject: [PATCH] adding last_updated to VaccineDistributionByZipcode.html --- docs/VaccineDistributionByZipcode.html | 15 +++++++++------ src/BatchCodeTableHtmlUpdater.py | 14 ++++++-------- src/HowBadIsMyBatch.ipynb | 14 ++++++++------ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/VaccineDistributionByZipcode.html b/docs/VaccineDistributionByZipcode.html index 68763ccba20..9fde3e8448b 100644 --- a/docs/VaccineDistributionByZipcode.html +++ b/docs/VaccineDistributionByZipcode.html @@ -42,12 +42,15 @@ -

Data Sources: - Vaccine Adverse Event Reporting System - (VAERS) and - Vaccine Distribution by Zipcode -

+
+
Data Sources:
+
Vaccine Adverse Event Reporting System + (VAERS)
+
Vaccine Distribution by Zipcode
+
Last updated:
+
June 09, 2023
+
\ No newline at end of file diff --git a/src/BatchCodeTableHtmlUpdater.py b/src/BatchCodeTableHtmlUpdater.py index 7e115ca6235..e6d3accf92e 100644 --- a/src/BatchCodeTableHtmlUpdater.py +++ b/src/BatchCodeTableHtmlUpdater.py @@ -5,29 +5,27 @@ from HtmlUtils import getBatchcodeOptions, getBatchcodes from DateProvider import DateProvider -def updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile): +def updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile, lastUpdated): batchcodeOptions = getBatchcodeOptions(getBatchcodes(batchCodeTable.sort_values(by = 'Adverse Reaction Reports', ascending = False))) _saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile) - saveLastUpdatedBatchCodeTable( - DateProvider().getLastUpdatedDataSource(), - batchCodeTableHtmlFile) + saveLastUpdated2HtmlFile(lastUpdated, batchCodeTableHtmlFile) def _saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile): HtmlTransformerUtil().applySoupTransformerToFile( file=batchCodeTableHtmlFile, - soupTransformer=lambda soup: + soupTransformer = lambda soup: BeautifulSoup( BatchcodeOptionsSetter().setBatchcodeOptions( html=str(soup), options=batchcodeOptions), 'lxml')) -def saveLastUpdatedBatchCodeTable(lastUpdated, batchCodeTableHtmlFile): +def saveLastUpdated2HtmlFile(lastUpdated, htmlFile): def setLastUpdated(soup): soup.find(id="last_updated").string.replace_with( lastUpdated.strftime(DateProvider.DATE_FORMAT)) return soup HtmlTransformerUtil().applySoupTransformerToFile( - file=batchCodeTableHtmlFile, - soupTransformer=setLastUpdated) + file = htmlFile, + soupTransformer = setLastUpdated) diff --git a/src/HowBadIsMyBatch.ipynb b/src/HowBadIsMyBatch.ipynb index 2821ee2a1ac..62ad2386e31 100644 --- a/src/HowBadIsMyBatch.ipynb +++ b/src/HowBadIsMyBatch.ipynb @@ -14,7 +14,7 @@ "from HistogramFactoryAndPersister import createAndSaveGlobalHistograms\n", "from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n", "from BatchCodeTablePersister import createGlobalBatchCodeTable\n", - "from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile, saveLastUpdatedBatchCodeTable\n", + "from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile, saveLastUpdated2HtmlFile\n", "from InternationalVaersCovid19Provider import getInternationalVaersCovid19, getInternationalVaersCovid19BeforeDeletion, get_international_VAERSVAX_VAERSSYMPTOMS_Covid19\n", "from DateProvider import DateProvider\n", "from BarChartDescriptionTable2DictionaryConverter import BarChartDescriptionTable2DictionaryConverter\n", @@ -151,9 +151,7 @@ "outputs": [], "source": [ "IOUtils.saveDataFrameAsJson(batchCodeTable, '../docs/data/batchCodeTables/Global.json')\n", - "saveLastUpdatedBatchCodeTable(\n", - " DateProvider().getLastUpdatedDataSource(),\n", - " batchCodeTableHtmlFile = \"../docs/batchCodes.html\")" + "saveLastUpdated2HtmlFile(dateProvider.getLastUpdatedDataSource(), \"../docs/batchCodes.html\")" ] }, { @@ -163,7 +161,10 @@ "metadata": {}, "outputs": [], "source": [ - "updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile=\"../docs/HowBadIsMyBatch.html\")" + "updateBatchCodeTableHtmlFile(\n", + " batchCodeTable,\n", + " batchCodeTableHtmlFile = \"../docs/HowBadIsMyBatch.html\",\n", + " lastUpdated = dateProvider.getLastUpdatedDataSource())" ] }, { @@ -364,7 +365,8 @@ "source": [ "from IOUtils import IOUtils\n", "\n", - "IOUtils.saveDataFrameAsJson(vaccineDistributionByZipcode, '../docs/data/vaccineDistributionByZipcode/VaccineDistributionByZipcode.json')" + "IOUtils.saveDataFrameAsJson(vaccineDistributionByZipcode, '../docs/data/vaccineDistributionByZipcode/VaccineDistributionByZipcode.json')\n", + "saveLastUpdated2HtmlFile(dateProvider.getLastUpdatedDataSource(), \"../docs/VaccineDistributionByZipcode.html\")" ] } ],