From c9178cabb0be8369a929d6baef656402e8c1f5b2 Mon Sep 17 00:00:00 2001 From: ChrisSheng97 Date: Fri, 24 Apr 2020 16:06:31 -0400 Subject: [PATCH 01/61] add FAQs --- site/FAQ.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/site/FAQ.php b/site/FAQ.php index 5892e5d..1a206b4 100644 --- a/site/FAQ.php +++ b/site/FAQ.php @@ -78,6 +78,52 @@ another project (not crowdsourced) we are forecasting future demand on hospitals.

+ +
+ +

+ + 5. “Can you only see your score if you’re one of the top 10? / Can you see more than just last weeks forecast? I’m having trouble figuring out if my prior forecasts were any good. " + +

+

+ Answer: Unfortunately we can only show the top 10 scores.  However, your own score each week is always sent you you in the email you receive the following week. +

+ +
+ +

+ + 6. “I only have an iPhone. I do not have a computer to work on. Should I withdraw from the study or is there a way I can use my iPhone? " + +

+

+ Answer: Unfortunately we do not yet have a way to support smooth participation by phone. +

+ +
+ +

+ + 7. “On forecasting methodologies: Would you like us to forecast the following week, two weeks out, or the rest of the dates on the graph? Do you want us to use a method we can communicate to others? Do you want us to use a statistical method or just look at the data in the context of what you know from public information?" + +

+

+ Answer: Please forecast the rest of the time period shown on the Crowdcast display.  You may use any method you wish, including qualitative reasoning and personal judgement, using whatever data you have and anything else that you believe is relevant.  Your goal is to be as accurate as possible, regardless of the method you use. +

+ +
+ +

+ + 8. “On forecasting assumptions: Now that there is a pandemic, people are being asked to self-isolate if they have symptoms, instead of seeing a doctor, because of shortage of testing. Would you have to take that into consideration when making your forecasts? (i.e. it would be lower then you may predict because of lack of doctor’s visits, and lack of testing). Is it based on what I see around my area? People sheltering or using social distancing base not doing those things?" + +

+

+ Answer: You should take into account all considerations that you believe are relevant to what will eventually be measured and reported in the location for which you are forecasting. +

+ + Date: Fri, 24 Apr 2020 16:13:38 -0500 Subject: [PATCH 02/61] restore development-specific configuration - deploy to dev paths - restrict access to known users - use dev database on localhost --- deploy.json | 18 +++++++++--------- site/.htaccess | 8 ++++++++ site/common/settings.php | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/deploy.json b/deploy.json index ffdf95a..288fbd3 100644 --- a/deploy.json +++ b/deploy.json @@ -7,42 +7,42 @@ { "type": "move", "src": "site/.htaccess", - "dst": "/var/www/html/crowdcast/.htaccess", + "dst": "/var/www/html/cc-test/.htaccess", "add-header-comment": false }, "// service worker", { "type": "move", "src": "site/sw.js", - "dst": "/var/www/html/crowdcast/sw.js", + "dst": "/var/www/html/cc-test/sw.js", "add-header-comment": true }, "// web sources", { "type": "move", "src": "site/", - "dst": "/var/www/html/crowdcast/", + "dst": "/var/www/html/cc-test/", "match": "^.*\\.php$", "add-header-comment": true }, { "type": "move", "src": "site/common/", - "dst": "/var/www/html/crowdcast/common/", + "dst": "/var/www/html/cc-test/common/", "match": "^.*\\.php$", "add-header-comment": true }, { "type": "move", "src": "site/css/", - "dst": "/var/www/html/crowdcast/css/", + "dst": "/var/www/html/cc-test/css/", "match": "^.*\\.(css|php)$", "add-header-comment": true }, { "type": "move", "src": "site/js/", - "dst": "/var/www/html/crowdcast/js/", + "dst": "/var/www/html/cc-test/js/", "match": "^.*\\.js$", "add-header-comment": true }, @@ -51,21 +51,21 @@ { "type": "move", "src": "site/images/flags/", - "dst": "/var/www/html/crowdcast/images/flags/", + "dst": "/var/www/html/cc-test/images/flags/", "match": "^.*\\.png$" }, "// tutorials", { "type": "move", "src": "site/images/", - "dst": "/var/www/html/crowdcast/images/", + "dst": "/var/www/html/cc-test/images/", "match": "^.*\\.(gif|mp4)$" }, "// benchmark data", { "type":"move", "src":"site/data/", - "dst":"/var/www/html/crowdcast/data/", + "dst":"/var/www/html/cc-test/data/", "match":"^.*\\.csv$" } ] diff --git a/site/.htaccess b/site/.htaccess index 61f4952..4c2fc5b 100644 --- a/site/.htaccess +++ b/site/.htaccess @@ -1,5 +1,13 @@ RewriteEngine On +## Resrtict access to known users ## +AuthType Basic +AuthName "Restricted Site: Crowdcast" +AuthBasicProvider file +AuthUserFile /var/www/passwords +Require user cctest +## Resrtict access to known users ## + ## Compress Files ## diff --git a/site/common/settings.php b/site/common/settings.php index e6c84ee..ce2b3b2 100644 --- a/site/common/settings.php +++ b/site/common/settings.php @@ -1,7 +1,7 @@ Date: Fri, 24 Apr 2020 16:14:38 -0500 Subject: [PATCH 03/61] update dev readme --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 06bb328..f3533f2 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ # Status -[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-crowdcast)](#) +[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast)](#) # About -The Crowdcast website for collecting flu forecasts. +This is the **development** version of the website. -The site is live at: -- https://delphi.cmu.edu/crowdcast +1. it is generally safe to make changes here at any time, as they will not +affect the production environment +2. changes should be merged from this branch into +[the prod branch](https://github.com/cmu-delphi/www-epicast/tree/prod), +except for production-specific configuration -A live demo is available at http://demo.epicast.net/ (User ID is `00000000`) +See +[the master branch README.md](https://github.com/cmu-delphi/www-epicast/blob/master/README.md) +for more information. From ad0a87a88eef540cd50c221da21e838548d61886 Mon Sep 17 00:00:00 2001 From: undefx Date: Fri, 24 Apr 2020 18:24:43 -0500 Subject: [PATCH 04/61] use dev branch badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3533f2..b7d0a11 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Status -[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast)](#) +[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast/dev)](#) # About From 4c40cbd87987169c303aa802d49b609008c44f7c Mon Sep 17 00:00:00 2001 From: undefx Date: Fri, 24 Apr 2020 21:23:30 -0500 Subject: [PATCH 05/61] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7d0a11..e964d80 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Status -[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast/dev)](#) +[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast/dev)](#) # About From e46227a87bf8b6260844da1b8026001aa9ba3cb3 Mon Sep 17 00:00:00 2001 From: undefx Date: Fri, 24 Apr 2020 21:26:13 -0500 Subject: [PATCH 06/61] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e964d80..b7d0a11 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Status -[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast/dev)](#) +[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast/dev)](#) # About From e3e92bf5e7bfe07bb51b0370e7ed26438d409201 Mon Sep 17 00:00:00 2001 From: undefx Date: Tue, 28 Apr 2020 12:46:20 -0500 Subject: [PATCH 07/61] launch without forcing https - enables local development over http --- site/launch.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/site/launch.php b/site/launch.php index cb82fea..af4d1ca 100644 --- a/site/launch.php +++ b/site/launch.php @@ -25,7 +25,12 @@ if($path !== '/') { $path .= '/'; } -$location = 'https://' . $_SERVER['HTTP_HOST'] . $path . $location; # TODO: Can we let the https rewrite handle this? +if (stripos($_SERVER['SERVER_PROTOCOL'],'https') === 0) { + $protocol = 'https://'; +} else { + $protocol = 'http://'; +} +$location = $protocol . $_SERVER['HTTP_HOST'] . $path . $location; # TODO: Can we let the https rewrite handle this? header("Location: {$location}"); ?> From a55767d4a671f32daa3de47c63cf268014198522 Mon Sep 17 00:00:00 2001 From: undefx Date: Tue, 28 Apr 2020 12:47:31 -0500 Subject: [PATCH 08/61] don't lookup nowcast, as it is unused - don't get the nowcast from the database as it's not used anyway - the nowcast should be taken from the epidata api, rather than reading from the database directly --- site/forecast.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/site/forecast.php b/site/forecast.php index 954b039..32cdc1d 100644 --- a/site/forecast.php +++ b/site/forecast.php @@ -93,7 +93,7 @@ $seasonStart = 201936; //Nowcast (may or may not be available) -getNowcast($dbh, $output, addEpiweeks($currentWeek, 1), $regionID); +// getNowcast($dbh, $output, addEpiweeks($currentWeek, 1), $regionID); if(getPreference($output, 'skip_instructions', 'int') !== 1) { ?> @@ -124,7 +124,7 @@
History
- +
@@ -327,7 +327,7 @@ function loader(sidebarTitle,rid,parent,whitelist) { } // check for new season - var si = Math.floor(epidata[i].epiweek / 100); + var si = Math.floor(epidata[i].epiweek / 100); if (modweek < seasonDefn[0]) si = si - 1; // whitelist: don't create an extra new season for 2009-2010 week 201036-40 if (season<0 || (season != si && (!whitelist || si in whitelist))) { @@ -335,11 +335,11 @@ function loader(sidebarTitle,rid,parent,whitelist) { season = si; module.season[season] = {start:i,year:season,label:season==2009?(season+" pandemic"):season,color:getStyle(rid,season).color,current:season==currentSeason}; // the templating engine needs a list, so we make a list - module.seasons[mi++] = module.season[season]; + module.seasons[mi++] = module.season[season]; } } module.season[season].end = epidata.length-1; - + curves[rid] = module; $(parent).append($(Mustache.render(document.getElementById('sidebar_template').innerHTML, module))); toggleAllSeasons(rid); From 6f657a8fa601fa594d391af8a34f22eefa2a3759 Mon Sep 17 00:00:00 2001 From: undefx Date: Tue, 28 Apr 2020 12:50:57 -0500 Subject: [PATCH 09/61] use delphi-hosted epidata library - include in header as this will be used across several pages in the near future - remove outdated local copy of the library - use hosted version as this will always be up-to-date with the epidata api --- site/common/header.php | 1 + site/forecast.php | 1 - site/js/delphi_epidata.js | 453 -------------------------------------- 3 files changed, 1 insertion(+), 454 deletions(-) delete mode 100644 site/js/delphi_epidata.js diff --git a/site/common/header.php b/site/common/header.php index 27d1d96..792cafe 100644 --- a/site/common/header.php +++ b/site/common/header.php @@ -20,6 +20,7 @@ +
- - + + + + diff --git a/site/sw.js b/site/sw.js deleted file mode 100644 index e1a5413..0000000 --- a/site/sw.js +++ /dev/null @@ -1,64 +0,0 @@ -//Initialize Service Worker Properly -"use strict"; -// var workbox = 0; - -"function" == typeof importScripts && - importScripts ( - "https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js" - ); - -console.log('Was Workbox able to load?'); - if (workbox) { - console.log('Workbox loaded correctly.'); - } else { - console.log('Workbox did not load correctly, please check your service worker for errors.'); -} - -workbox.precaching.precacheAndRoute([ - // If forecast.php gets cached it will show inaccurate data when accessing different regions - // { url: 'forecast.php', revision: 'fc386e2' }, -]); - -//workbox.googleAnalytics.initialize(); - -workbox.routing.registerRoute( - // Cache JS, CSS, JSON files - /.*\.(?:css|js|json)/, - // Use cache but update in the background ASAP - workbox.strategies.staleWhileRevalidate({ - cacheName: 'filetype-cache', - }) -); - -workbox.routing.registerRoute( - // Cache Image files - /.*\.(?:png|jpg|jpeg|svg|gif)/, - // Use the cache if it's available - workbox.strategies.cacheFirst({ - cacheName: 'image-cache', - plugins: [ - new workbox.expiration.Plugin({ - // Cache up to 50 images - maxEntries: 25, - // Cache for a maximum of 28 days - maxAgeSeconds: 28 * 24 * 60 * 60, - // Automatically cleanup if quota is exceeded. - purgeOnQuotaError: true, - }) - ], - }) -); - -workbox.routing.registerRoute( - /.*(?:facebook|googleapis|ajax.googleapis|fonts.googleapis|fonts.gstatic|maxcdn.bootstrapcdn)\.com.*$/, - workbox.strategies.staleWhileRevalidate({ - cacheName: 'external-cache', - }) -); - -workbox.routing.registerRoute( - /.*(?:delphi.midas.cs.cmu)\.edu.*$/, - workbox.strategies.staleWhileRevalidate({ - cacheName: 'API-cache', - }) -); From a27efc02df275c6294c1affd79b6ab068ccc4ec2 Mon Sep 17 00:00:00 2001 From: undefx Date: Tue, 28 Apr 2020 14:49:52 -0500 Subject: [PATCH 11/61] get latest issue from epidata api - removes final dependency on the epidata database, at least for "normal-season" epicast - populate "latest issue" async in javascript in the places it's needed (it's only needed for dislpay purposes) --- site/admin.php | 556 ++++++++++++++++++++------------------- site/common/database.php | 50 ++-- site/home.php | 29 +- site/js/utils.js | 46 +++- site/scores.php | 174 ++++++------ 5 files changed, 433 insertions(+), 422 deletions(-) diff --git a/site/admin.php b/site/admin.php index 9bfd797..88c4d26 100644 --- a/site/admin.php +++ b/site/admin.php @@ -1,277 +1,279 @@ -', $field); - printf(' ', $field); -} -function sortBool(&$a, &$b) { - global $sortDir, $sortKey; - $value = 0; - if($a[$sortKey] && !$b[$sortKey]) { - $value = 1; - } - if(!$a[$sortKey] && $b[$sortKey]) { - $value = -1; - } - return $value * ($sortDir === 'a' ? 1 : -1); -} -function sortInt(&$a, &$b) { - global $sortDir, $sortKey; - $value = $a[$sortKey] - $b[$sortKey]; - return $value * ($sortDir === 'a' ? 1 : -1); -} -if(isAdmin($output)) { -?> -
- 0) { - $numForecastusers++; - } - } - } - foreach($u['submissions_hosp'] as &$s) { - if($s[0] === $output['epiweek']['round_epiweek']) { - $numForecasts_hosp += $s[1]; - if($s[1] > 0) { - $numForecastusers_hosp++; - } - } - } - foreach($emailTypes as &$type) { - if(getPreference($u, 'email_' . $type, 'int') === 1) { - $u['emails']++; - } - } - foreach($u['submissions'] as &$s) { - $u['total_submissions'] += $s[1]; - } - foreach($u['submissions_hosp'] as &$s) { - $u['total_submissions_hosp'] += $s[1]; - } - } - //PHP sort - if($sortFunc !== null) { - usort($output['userbase'], $sortFunc); - } - ?> -
-
- User Stats -
-
-
-
-
Total Registered Users
-
-
-
-
New Users Last 7 Days
-
-
-
-
Users Active Last 7 Days
-
-
-
-
Users Online Now
-
-
-
- -
-
- Regions and States -
-
-
-
-
Most Recent Report
-
-
-
-
Forecasts Received This Round
-
-
-
-
Users Participated This Round
-
-
-
- - -
-
- Userbase -
- Hopefully some day this will be too long to display on a single page. -
-
-
- - - - - - - - - - - - - - - -
Name EmailFirst Seen Last Seen PreferencesPresence Communication Submissions
', explode(' ', $u['first_seen'])) ?>', explode(' ', $u['last_seen'])) ?>', $k, $u['user_preferences'][$k]); - } else { - printf('%s: %s
', $k, $output['default_preferences'][$k]); - } - } - foreach(array_keys($u['user_preferences']) as $k) { - if(!isset($output['default_preferences'][$k])) { - printf('%s: %s
', $k, $u['user_preferences'][$k]); - } - } - ?>
- Online Now - - Offline - - Missing - - All Emails - 0) { ?> - Some Emails - - Do Not Contact - '); - foreach($u['submissions'] as &$s) { - printf('%s: %d
', formatEpiweek($s[0]), $s[1]); - } - printf('Total: %d
', $u['total_submissions']); - ?>
-
-
-
-
- Control Interface -
- Update user and system settings. -
-
-

The control interface is here.

-
-
- +', $field); + printf(' ', $field); +} +function sortBool(&$a, &$b) { + global $sortDir, $sortKey; + $value = 0; + if($a[$sortKey] && !$b[$sortKey]) { + $value = 1; + } + if(!$a[$sortKey] && $b[$sortKey]) { + $value = -1; + } + return $value * ($sortDir === 'a' ? 1 : -1); +} +function sortInt(&$a, &$b) { + global $sortDir, $sortKey; + $value = $a[$sortKey] - $b[$sortKey]; + return $value * ($sortDir === 'a' ? 1 : -1); +} +if(isAdmin($output)) { +?> +
+ 0) { + $numForecastusers++; + } + } + } + foreach($u['submissions_hosp'] as &$s) { + if($s[0] === $output['epiweek']['round_epiweek']) { + $numForecasts_hosp += $s[1]; + if($s[1] > 0) { + $numForecastusers_hosp++; + } + } + } + foreach($emailTypes as &$type) { + if(getPreference($u, 'email_' . $type, 'int') === 1) { + $u['emails']++; + } + } + foreach($u['submissions'] as &$s) { + $u['total_submissions'] += $s[1]; + } + foreach($u['submissions_hosp'] as &$s) { + $u['total_submissions_hosp'] += $s[1]; + } + } + //PHP sort + if($sortFunc !== null) { + usort($output['userbase'], $sortFunc); + } + ?> +
+
+ User Stats +
+
+
+
+
Total Registered Users
+
+
+
+
New Users Last 7 Days
+
+
+
+
Users Active Last 7 Days
+
+
+
+
Users Online Now
+
+
+
+ +
+
+ Regions and States +
+
+
+
+ +
Most Recent Report
+
+
+
+
Forecasts Received This Round
+
+
+
+
Users Participated This Round
+
+
+
+ + +
+
+ Userbase +
+ Hopefully some day this will be too long to display on a single page. +
+
+
+ + + + + + + + + + + + + + + +
Name EmailFirst Seen Last Seen PreferencesPresence Communication Submissions
', explode(' ', $u['first_seen'])) ?>', explode(' ', $u['last_seen'])) ?>', $k, $u['user_preferences'][$k]); + } else { + printf('%s: %s
', $k, $output['default_preferences'][$k]); + } + } + foreach(array_keys($u['user_preferences']) as $k) { + if(!isset($output['default_preferences'][$k])) { + printf('%s: %s
', $k, $u['user_preferences'][$k]); + } + } + ?>
+ Online Now + + Offline + + Missing + + All Emails + 0) { ?> + Some Emails + + Do Not Contact + '); + foreach($u['submissions'] as &$s) { + printf('%s: %d
', formatEpiweek($s[0]), $s[1]); + } + printf('Total: %d
', $u['total_submissions']); + ?>
+
+
+
+
+ Control Interface +
+ Update user and system settings. +
+
+

The control interface is here.

+
+
+ diff --git a/site/common/database.php b/site/common/database.php index fa054a0..95b88df 100644 --- a/site/common/database.php +++ b/site/common/database.php @@ -191,9 +191,7 @@ function getUserStats_hosp($dbh, &$output, $userID, $epiweek) { $output['result'] will contain the following values: 1 - Success 2 - Failure (table ec_fluv_round) - 3 - Failure (table epidata.fluview) - $output['epiweek']['round_epiweek'] - This round's identifier (can be ahead of data_epiweek) - $output['epiweek']['data_epiweek'] - The most recently published issue (from epidata.fluview) + $output['epiweek']['round_epiweek'] - This round's identifier (can be ahead of latest issue) $output['epiweek']['deadline'] - Deadline timestamp as a string (YYYY-MM-DD HH:MM:SS) $output['epiweek']['deadline_timestamp'] - Unix timestamp of deadline $output['epiweek']['remaining'] - An array containing days/hours/minutes/seconds remaining @@ -246,14 +244,6 @@ function getEpiweekInfo($dbh, &$output) { setResult($output, 2); return getResult($output); } - $result = $dbh->query('SELECT max(`issue`) AS `data_epiweek` FROM epidata.`fluview`'); - if($row = $result->fetch_assoc()) { - $output['epiweek']['data_epiweek'] = intval($row['data_epiweek']); - setResult($output, 1); - } else { - setResult($output, 3); - return getResult($output); - } return getResult($output); } @@ -357,7 +347,7 @@ function getRegions($dbh, &$output, $userID) { $regions[$region['id']] = $region; } $output['regions'] = &$regions; - + setResult($output, count($regions) == NUM_REGIONS ? 1 : 2); return getResult($output); } @@ -443,7 +433,7 @@ function getRegionsExtended($dbh, &$output, $userID) { if(getRegions($dbh, $output, $userID) !== 1) { return getResult($output); } - + //History and forecast for every region foreach($output['regions'] as &$r) { if(getPreference($output, 'advanced_prior', 'int') === 1) { @@ -451,16 +441,16 @@ function getRegionsExtended($dbh, &$output, $userID) { } else { $firstWeek = 200430; } - + if(getHistory($dbh, $output, $r['id'], $firstWeek) !== 1) { return getResult($output); } - + $r['history'] = $output['history']; if(loadForecast($dbh, $output, $userID, $r['id']) !== 1) { return getResult($output); } - + $r['forecast'] = $output['forecast']; } setResult($output, 1); @@ -596,7 +586,7 @@ function getAgeGroupsExtended($dbh, &$output, $userID) { 2 - Failure $output['history'] - Arrays of epiweeks and historical incidence (wILI) for the region */ -function getHistory($dbh, &$output, $regionID, $firstWeek) { +function getHistory($dbh, &$output, $regionID, $firstWeek) { $result = $dbh->query("SELECT fv.`epiweek`, fv.`wili` FROM epidata.`fluview` AS fv JOIN ( SELECT `epiweek`, max(`issue`) AS `latest` FROM epidata.`fluview` AS fv JOIN ec_fluv_regions AS reg ON reg.`fluview_name` = fv.`region` WHERE reg.`id` = {$regionID} AND fv.`epiweek` >= {$firstWeek} GROUP BY fv.`epiweek` ) AS issues ON fv.`epiweek` = issues.`epiweek` AND fv.`issue` = issues.`latest` JOIN ec_fluv_regions AS reg ON reg.`fluview_name` = fv.`region` WHERE reg.`id` = {$regionID} AND fv.`epiweek` >= {$firstWeek} ORDER BY fv.`epiweek` ASC"); $date = array(); $wili = array(); @@ -739,7 +729,7 @@ function listAgeGroups($dbh) { 2 - Failure */ function saveForecast($dbh, &$output, $userID, $regionID, $forecast, $commit) { - + $temp = array(); if(getEpiweekInfo($dbh, $temp) !== 1) { return getResult($temp); @@ -752,18 +742,18 @@ function saveForecast($dbh, &$output, $userID, $regionID, $forecast, $commit) { if($commit) { $dbh->query("INSERT INTO ec_fluv_submissions (`user_id`, `region_id`, `epiweek_now`, `date`) VALUES ({$userID}, {$regionID}, {$temp['epiweek']['round_epiweek']}, now())"); } - + $debug = false; if ($debug) { echo "-------saveForecast----\n"; echo $commit; } - - + + setResult($output, 1); - + getRegions($dbh, $output, $userID); - + return getResult($output); } @@ -840,7 +830,7 @@ function loadForecast($dbh, &$output, $userID, $regionID, $submitted=false) { echo "-----inside loadForecast------\n"; echo "user ID, region ID, submitted: "; echo $userID; - echo $regionID; + echo $regionID; echo $submitted; } @@ -849,7 +839,7 @@ function loadForecast($dbh, &$output, $userID, $regionID, $submitted=false) { if(getEpiweekInfo($dbh, $temp) !== 1) { return getResult($temp); } - + $result = $dbh->query("SELECT coalesce(max(`epiweek_now`), 0) `epiweek` FROM ec_fluv_submissions WHERE `user_id` = {$userID} AND `region_id` = {$regionID} AND `epiweek_now` < {$temp['epiweek']['round_epiweek']}"); } else { $result = $dbh->query("SELECT coalesce(max(`epiweek_now`), 0) `epiweek` FROM ec_fluv_forecast WHERE `user_id` = {$userID} AND `region_id` = {$regionID}"); @@ -863,17 +853,17 @@ function loadForecast($dbh, &$output, $userID, $regionID, $submitted=false) { $date = array(); $wili = array(); $result = $dbh->query("SELECT `epiweek_now`, `epiweek`, `wili` FROM ec_fluv_forecast f WHERE `user_id` = {$userID} AND `region_id` = {$regionID} AND `epiweek_now` = {$epiweek} ORDER BY f.`epiweek` ASC"); - + if ($debug and ($regionID == 1 or $regionID == 8)) { echo "epiweek: "; echo $epiweek; echo "\n"; } - + while($row = $result->fetch_assoc()) { array_push($date, intval($row['epiweek'])); array_push($wili, floatval($row['wili'])); - + if ($debug and ($regionID == 1 or $regionID == 8)) { echo intval($row['epiweek']); echo ", "; @@ -1041,7 +1031,7 @@ function registerUser_mturk_2019($dbh, $mturkID, $taskID) { $query = "INSERT INTO ec_fluv_users_mturk_2019 (`hash`, `name`, `email`, `first_seen`, `last_seen`, `taskID`) VALUES ('{$hash}', '{$escapedInput}', '{$email}', now(), now(), {$taskID})"; $dbh->query($query); - + $temp = array(); if(getEpiweekInfo_mturk($temp) !== 1) { return getResult($temp); @@ -1577,7 +1567,7 @@ function getECDCILI($dbh, &$output, $regionID, $firstWeek) { WHERE ed.`region` = \"{$country}\" AND ed.`epiweek` >= {$firstWeek} ORDER BY ed.`epiweek` ASC"; $result = $dbh->query($query); - + $date = array(); $wili = array(); while($row=$result->fetch_assoc()) { diff --git a/site/home.php b/site/home.php index dd4cfb1..15064db 100644 --- a/site/home.php +++ b/site/home.php @@ -19,36 +19,36 @@ fail('Error loading epiweek info'); } //User stats - + // echo "calling getUserStats"; if(getUserStats($dbh, $output, $output['user_id'], $output['epiweek']['round_epiweek']) != 1) { fail('Error loading user info'); } - + // Hospitalization forecasts: turned off for this season. // if(getUserStats_hosp($dbh, $output, $output['user_id'], $output['epiweek']['round_epiweek']) != 1) { // fail('Error loading user info'); // } - + if(getRegions($dbh, $output, $output['user_id']) != 1) { fail('Error loading region info'); } - + ?>
Post Forecast - +
Due by 10:00 AM (ET) on .
- + - +
@@ -95,9 +95,10 @@
- +
-
+
+
latest available data
@@ -114,7 +115,7 @@ if ($missing == 0) { ?> - +
Nice job, you're finished! @@ -131,7 +132,7 @@

Hover a button above to see which states are in that region or the location of the state in the map below.

- +
@@ -200,7 +201,7 @@
- +
@@ -209,11 +210,11 @@ COVID-19 Information and Data
- +

DELPHI COVID-19 and ILI Data Sources - spreadsheet updated continually

- +