From b58021af04a451346a64efa3ec382f45d75a870d Mon Sep 17 00:00:00 2001 From: frankknoll Date: Thu, 2 Feb 2023 17:46:20 +0100 Subject: [PATCH 1/3] making Company column searchable --- docs/batchCodeTable.html | 256 ++++++++++++++++++++++++++++----------- docs/batchCodeTable.js | 25 +++- src/help.txt | 1 - 3 files changed, 211 insertions(+), 71 deletions(-) diff --git a/docs/batchCodeTable.html b/docs/batchCodeTable.html index 002016d9ad5..2682004cbd1 100644 --- a/docs/batchCodeTable.html +++ b/docs/batchCodeTable.html @@ -1,25 +1,32 @@ + - - -Batch Codes of Coronavirus 2019 Vaccines - - - - - - - - - - - - - - - - + + + + + + + + + + + + + -Fork me on GitHub -

Batch Codes of Coronavirus 2019 Vaccines

-

- -

-

-

-Check out your batch code (Last updated: January 27, 2023) + Fork me on GitHub +

Batch Codes of Coronavirus 2019 Vaccines

+

+

- - - - - - - - - - - - - - - -
BatchAdverse Reaction ReportsDeathsDisabilitiesLife Threatening IllnessesCompanyCountriesSevere reportsLethality
-

Data Source: -Vaccine Adverse Event Reporting System +

+

+ Check out your batch code (Last updated: January 27, 2023) +

+ + + + + + + + + + + + + + + +
BatchAdverse Reaction ReportsDeathsDisabilitiesLife Threatening IllnessesCompanyCountriesSevere reportsLethality
+

Data Source: + Vaccine Adverse Event Reporting System (VAERS) -

- - + + \ No newline at end of file diff --git a/docs/batchCodeTable.js b/docs/batchCodeTable.js index bec9c6004cf..f1415aaaada 100644 --- a/docs/batchCodeTable.js +++ b/docs/batchCodeTable.js @@ -48,7 +48,6 @@ class BatchCodeTableInitializer { this.#getColumnIndex('Deaths'), this.#getColumnIndex('Disabilities'), this.#getColumnIndex('Life Threatening Illnesses'), - this.#getColumnIndex('Company'), this.#getColumnIndex('Countries'), this.#getColumnIndex('Severe reports'), this.#getColumnIndex('Lethality') @@ -56,7 +55,7 @@ class BatchCodeTableInitializer { }, { orderable: false, - targets: this.#getColumnIndex('Countries') + targets: [this.#getColumnIndex('Countries'), this.#getColumnIndex('Company')] }, { render: (data, type, row) => { @@ -105,6 +104,7 @@ class BatchCodeTableInitializer { }) .then(json => { this.#setTableRows(json.data); + this.#makeCompanyColumnSearchable(); this.#selectInput(); this.#displayControlColumn(country == 'Global'); }); @@ -122,6 +122,27 @@ class BatchCodeTableInitializer { .draw(); } + #makeCompanyColumnSearchable() { + // adapted from https://datatables.net/examples/api/multi_filter_select.html + const companyColumn = this.#batchCodeTable.column(this.#getColumnIndex('Company')); + const select = $('') + .appendTo($(companyColumn.header())) + .on('change', function () { + const val = $.fn.dataTable.util.escapeRegex($(this).val()); + companyColumn + .search(val ? '^' + val + '$' : '', true, false) + .draw(); + }); + + companyColumn + .data() + .unique() + .sort() + .each(function (d, _) { + select.append(''); + }); + } + #selectInput() { const input = document.querySelector(".dataTables_filter input"); input.focus(); diff --git a/src/help.txt b/src/help.txt index 8a58afecd45..5070ada96ac 100644 --- a/src/help.txt +++ b/src/help.txt @@ -4,7 +4,6 @@ FK-FIXME: FK-TODO: - Histogramme auch speziell für die einzelnen Länder berechnen und anzeigen. -- make Company column searchable: https://datatables.net/examples/api/multi_filter_select.html anacron job: sudo cp src/intensivstationen_howbadismybatch.sh /etc/cron.daily/intensivstationen_howbadismybatch From da2a9041e0ee3bedd727f325ef217a6e00f4e518 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Thu, 2 Feb 2023 21:28:27 +0100 Subject: [PATCH 2/3] docu --- src/help.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/help.txt b/src/help.txt index 5070ada96ac..ec1ae7a154f 100644 --- a/src/help.txt +++ b/src/help.txt @@ -20,3 +20,17 @@ www.HowBadIsMyBatch.info https://datatables.net/examples/api/row_details.html https://www.datatables.net/blog/2017-03-31 + +Profiling: +========== +from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory +import cProfile +cProfile.run( + 'SymptomByBatchcodeTableFactory.createSymptomByBatchcodeTable(international_VAERSVAX_Covid19, international_VAERSSYMPTOMS)', + 'tmp/restats') + +import pstats +from pstats import SortKey + +p = pstats.Stats('tmp/restats') +p.strip_dirs().sort_stats(SortKey.CUMULATIVE).print_stats() From 8e311dfa03c696d080b82db1e851900e0332964e Mon Sep 17 00:00:00 2001 From: frankknoll Date: Thu, 2 Feb 2023 22:19:28 +0100 Subject: [PATCH 3/3] making Company column searchable --- docs/ColumnSearch.js | 35 +++++++++++++++++++++++++++++++++++ docs/batchCodeTable.html | 1 + docs/batchCodeTable.js | 25 +++---------------------- 3 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 docs/ColumnSearch.js diff --git a/docs/ColumnSearch.js b/docs/ColumnSearch.js new file mode 100644 index 00000000000..bafe737a09b --- /dev/null +++ b/docs/ColumnSearch.js @@ -0,0 +1,35 @@ +// adapted from https://datatables.net/examples/api/multi_filter_select.html +class ColumnSearch { + + #column; + #select; + + constructor(column) { + this.#column = column; + const clazz = this; + $('
').appendTo($(this.#column.header())); + this.#select = $('') + .appendTo($(this.#column.header())) + .on( + 'change', + function () { + const val = $.fn.dataTable.util.escapeRegex($(this).val()); + clazz.#column + .search(val ? '^' + val + '$' : '', true, false) + .draw(); + }); + } + + columnContentUpdated() { + this.#select.empty(); + this.#select.append(''); + const clazz = this; + this.#column + .data() + .unique() + .sort() + .each(function (d, _) { + clazz.#select.append(''); + }); + } +} \ No newline at end of file diff --git a/docs/batchCodeTable.html b/docs/batchCodeTable.html index 2682004cbd1..ec29179045a 100644 --- a/docs/batchCodeTable.html +++ b/docs/batchCodeTable.html @@ -21,6 +21,7 @@ + diff --git a/docs/batchCodeTable.js b/docs/batchCodeTable.js index f1415aaaada..037d0ca83dc 100644 --- a/docs/batchCodeTable.js +++ b/docs/batchCodeTable.js @@ -4,6 +4,7 @@ class BatchCodeTableInitializer { #countrySelect; #batchCodeTableElement; #batchCodeTable; + #columnSearch; constructor({ heading, countrySelect, batchCodeTableElement }) { this.#heading = heading; @@ -13,6 +14,7 @@ class BatchCodeTableInitializer { initialize() { this.#batchCodeTable = this.#createEmptyBatchCodeTable(); + this.#columnSearch = new ColumnSearch(this.#batchCodeTable.column(this.#getColumnIndex('Company'))); this.#countrySelect.addEventListener('change', event => this.#displayCountry(event.target.value)); this.#displayCountry('Global'); this.#initializeHistogramView(); @@ -104,7 +106,7 @@ class BatchCodeTableInitializer { }) .then(json => { this.#setTableRows(json.data); - this.#makeCompanyColumnSearchable(); + this.#columnSearch.columnContentUpdated(); this.#selectInput(); this.#displayControlColumn(country == 'Global'); }); @@ -122,27 +124,6 @@ class BatchCodeTableInitializer { .draw(); } - #makeCompanyColumnSearchable() { - // adapted from https://datatables.net/examples/api/multi_filter_select.html - const companyColumn = this.#batchCodeTable.column(this.#getColumnIndex('Company')); - const select = $('') - .appendTo($(companyColumn.header())) - .on('change', function () { - const val = $.fn.dataTable.util.escapeRegex($(this).val()); - companyColumn - .search(val ? '^' + val + '$' : '', true, false) - .draw(); - }); - - companyColumn - .data() - .unique() - .sort() - .each(function (d, _) { - select.append(''); - }); - } - #selectInput() { const input = document.querySelector(".dataTables_filter input"); input.focus();