count of Datum records from the database.\n"; exit(1) }
# fetch all the data available (posibly json), process it,
# create Datum objects, store it in DB and return an array
# of the Datum objects
type (SQLite or MySQL), and DB connection options. The example configuration at 't/example-config.json' can be used as a quick start. Make a copy if that file and do not modify that file directly as t
ave or don't save data to files (json and pl hashtables). Default is ".($do_save_to_file?"yes":"no").".]\n"
. "[--(no)save-to-db : save or don't save data to DB (json and pl hashtables). Default is "
es9.arcgis.com/N9p5hsImWXAccRNI/arcgis/rest/services/Z7biAeD8PAkqgmWhxG2A/FeatureServer/1/query?f=json&where=Confirmed%20%3E%3D%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*
N9p5hsImWXAccRNI/arcgis/rest/services/Z7biAeD8PAkqgmWhxG2A/FeatureServer/1/query?cacheHint=true&f=json&orderByFields=Confirmed+desc%2CCountry_Region+asc%2CProvince_State+asc&outFields=*&resultOffset=0
es9.arcgis.com/N9p5hsImWXAccRNI/arcgis/rest/services/Z7biAeD8PAkqgmWhxG2A/FeatureServer/1/query?f=json&where=Confirmed%20%3E%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&or
<<'EXA'
db-search-and-make-new-db.pl --config-file-source config/config.json --config-file-destination config/destination.json --tablename 'Datum' --conditions "{'name'=>'Hackney'}" --attributes "{'r
a DBIx::Class::ResultSet->search() takes
# returns undef on failure
# returns the loaded datum objs on success (can be empty) as a hashref
sub select_datums_from_db {
my ($self, $params) = @_;
my
ovider '$providerstr'." }
my $jsonfiles = Statistics::Covid::Utils::find_files($datadir, qr/\.json$/i);
@basenames = map { s/\.((data)|(meta))\.json$//; $_ } @$jsonfiles;
}
if( scalar(@basenames
tistics::Covid::Datum;
$covid = Statistics::Covid->new({
'config-file' => 't/config-for-t.json',
'providers' => ['UK::BBC', 'UK::GOVUK', 'World::JHU'],
'save-to-file' => 1,
'save-to-db'
<<'EXA'
db-search-and-make-new-db.pl --config-file-source config/config.json --config-file-destination config/destination.json --tablename 'Datum' --conditions "{'name'=>'Hackney'}" --attributes "{'r
from file or set via the config* subs
# this reflects exactly the configuration json file (e.g. t/example-config.json)
# with 'dbparams' as subhash
'config-hash' => undef,
};
bless $self => $c
ename($params->{'log-filename'}) }
# we accept config-file or config-hash, see t/example-config.json for an example
if( exists $params->{'config-file'} ){ if( ! $self->config_file($params->{'config
]->config()->{'dbparams'} }
sub fileparams { return $_[0]->config()->{'fileparams'} }
# reads json data from file which represents the configuration settings
# for this module. It contains a 'file
0.23';
use DateTime;
use DateTime::Format::Strptime;
use File::Path;
#use JSON qw/decode_json/;
use JSON::Parse qw/parse_json/;
use Try::Tiny;
use Data::Dump qw/dump pp/;
use File::Find;
# DBIx::Cla
a
# regex pattern, e.g. '\.json$' or can be a precompiled regex
# which apart from the added speed (possibly) offers the flexibility
# of using regex switches, e.g. qr/\.json$/i
sub find_files {
# an
ng, $!"; return undef }
my $json_contents = undef;
{local $/ = undef; $json_contents = <$fh> } close($fh);
my $inhash = Statistics::Covid::Utils::configstring2perl($json_contents);
if( ! defined $
ime;
use File::Spec;
use File::Path;
use Data::Dump;
use JSON::Parse;
use File::Basename;
# this will take all the pv (the perl-vars-from-json fetched)
# and create a data id to be used for labelling
ata_received_string is the json string fetched (or whatever the provider sent)
# data_as_perlvar is the data received as a perlvar (if it's json we received, then JSON::json_decode()
# will give the p
s a perl variable (Data::Dump) with extension .pl
# and also as a json file (verbatim from the data provider)
# with extension .json.
# Ideally you need only the .pl file
# For other data provider
'} = [
[
# start a url
'https://www.bbc.co.uk/indepthtoolkit/data-sets/coronavirus_lookup/json',
# and its headers if any
[]
]
];
# initialise our parent class
my $self = $class->SU
my $datas = $_[1]; # this is an arrayref of [url, data_received_string, data_as_perlvar]
# this json is idiotic because it's just arrays,
# 0: location id
# 1: location name
# 2: cases
# 3: popu
0]->[0];
for my $apv (reverse @{$datas->[0]->[2]}){ # we only have 1 triplet and we get the perl-json-var
if( $apv->[0] eq 'UpdatedOn' ){
$date = Statistics::Covid::Utils::epoch_stupid_date_form
ervices1.arcgis.com/0IrmI40n5ZYxTUrV/arcgis/rest/services/DailyIndicators/FeatureServer/0/query?f=json&where=1%3D1&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&resultOffset=0&r
ervices1.arcgis.com/0IrmI40n5ZYxTUrV/arcgis/rest/services/CountyUAs_cases/FeatureServer/0/query?f=json&where=TotalCases%20%3C%3E%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=
ervices1.arcgis.com/0IrmI40n5ZYxTUrV/arcgis/rest/services/CountyUAs_cases/FeatureServer/0/query?f=json&where=TotalCases%20%3E%3D%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=
e;
# read data from db
$covid = Statistics::Covid->new({
'config-file' => 't/config-for-t.json',
'debug' => 2,
}) or die "Statistics::Covid->new() failed";
# retrieve data from DB for sele
;
# read data from db
$covid = Statistics::Covid->new({
'config-file' => 't/config-for-t.json',
'debug' => 2,
}) or die "Statistics::Covid->new() failed";
# retrieve data from DB for sele
<<'EXA'
db-search-and-make-new-db.pl --config-file-source config/config.json --config-file-destination config/destination.json --tablename 'Datum' --conditions "{'name'=>'Hackney'}" --attributes "{'r