refactoring
This commit is contained in:
24
src/BarChartDescriptionTable2DictionaryConverter.py
Normal file
24
src/BarChartDescriptionTable2DictionaryConverter.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from GoogleAnalyticsReader import GoogleAnalyticsReader
|
||||
from CountriesByBatchcodeProvider import getDateRangeOfVAERSReportsBeforeDeletionOfCountryCodes
|
||||
|
||||
|
||||
class BarChartDescriptionTable2DictionaryConverter:
|
||||
|
||||
@staticmethod
|
||||
def convert2Dictionary(barChartDescriptionTable):
|
||||
return {
|
||||
'dateRange guessed': BarChartDescriptionTable2DictionaryConverter.dateRange2Str(GoogleAnalyticsReader(dataDir='data/GoogleAnalytics').getDateRange()),
|
||||
'dateRange before deletion': BarChartDescriptionTable2DictionaryConverter.dateRange2Str(getDateRangeOfVAERSReportsBeforeDeletionOfCountryCodes()),
|
||||
'barChartDescriptions': barChartDescriptionTable['BAR_CHART_DESCRIPTION'].to_dict()
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def dateRange2Str(dateRange):
|
||||
return {
|
||||
'start': BarChartDescriptionTable2DictionaryConverter._date2Str(dateRange[0]),
|
||||
'end': BarChartDescriptionTable2DictionaryConverter._date2Str(dateRange[1])
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _date2Str(date):
|
||||
return date.strftime("%d.%m.%Y")
|
||||
@@ -17,6 +17,7 @@
|
||||
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile, saveLastUpdatedBatchCodeTable\n",
|
||||
"from InternationalVaersCovid19Provider import getInternationalVaersCovid19, get_international_VAERSVAX_VAERSSYMPTOMS_Covid19\n",
|
||||
"from DateProvider import DateProvider\n",
|
||||
"from BarChartDescriptionTable2DictionaryConverter import BarChartDescriptionTable2DictionaryConverter\n",
|
||||
"from datetime import datetime\n",
|
||||
"from VAERSFileDownloader import updateVAERSFiles\n",
|
||||
"from IOUtils import IOUtils\n",
|
||||
@@ -196,41 +197,6 @@
|
||||
"barChartDescriptionTable"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7ebfd53c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def dateRange2Str(dateRange):\n",
|
||||
" return {\n",
|
||||
" 'start': _date2Str(dateRange[0]),\n",
|
||||
" 'end': _date2Str(dateRange[1])\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
"def _date2Str(date):\n",
|
||||
" return date.strftime(\"%d.%m.%Y\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0ec101b6",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from GoogleAnalyticsReader import GoogleAnalyticsReader\n",
|
||||
"from CountriesByBatchcodeProvider import getDateRangeOfVAERSReportsBeforeDeletionOfCountryCodes\n",
|
||||
"\n",
|
||||
"dateRange = GoogleAnalyticsReader(dataDir = 'data/GoogleAnalytics').getDateRange()\n",
|
||||
"barChartDescriptions = {\n",
|
||||
" 'dateRange guessed': dateRange2Str(dateRange),\n",
|
||||
" 'dateRange before deletion': dateRange2Str(getDateRangeOfVAERSReportsBeforeDeletionOfCountryCodes()),\n",
|
||||
" 'barChartDescriptions': barChartDescriptionTable['BAR_CHART_DESCRIPTION'].to_dict()\n",
|
||||
"}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -238,7 +204,9 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"IOUtils.saveDictAsJson(barChartDescriptions, '../docs/data/barChartDescriptionTable.json')\n"
|
||||
"IOUtils.saveDictAsJson(\n",
|
||||
" BarChartDescriptionTable2DictionaryConverter.convert2Dictionary(barChartDescriptionTable),\n",
|
||||
" '../docs/data/barChartDescriptionTable.json')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user