diff --git a/lib/GTSRSSApi.pm b/lib/GTSRSSApi.pm index 87a9a75..187089f 100644 --- a/lib/GTSRSSApi.pm +++ b/lib/GTSRSSApi.pm @@ -27,7 +27,6 @@ my $viewstate; my $viewstate_generator; my $event_validation; my $pg_date_formatter = DateTime::Format::Pg->new; -my $db = GTSRSSApi::DB->connect; # This method will run once at server start sub startup ($self) { @@ -105,6 +104,7 @@ sub fetch_gts_data { my @offers = $html->find('.gtsPokemonSummary.gtsOffer.pfBoxThin.pfFormGroup') ->each; + my $db = GTSRSSApi::DB->connect; $db->do( <<'EOF', undef ); UPDATE offers SET marked_to_check_is_available = true WHERE is_available = true; EOF diff --git a/lib/GTSRSSApi/Controller/Page.pm b/lib/GTSRSSApi/Controller/Page.pm index f7bebac..9a70e55 100644 --- a/lib/GTSRSSApi/Controller/Page.pm +++ b/lib/GTSRSSApi/Controller/Page.pm @@ -11,7 +11,6 @@ use Mojo::DOM; use Mojo::Base 'Mojolicious::Controller', -signatures; use GTSRSSApi::DB; -my $db = GTSRSSApi::DB->connect; # This action will render a template sub index ($self) { @@ -21,6 +20,7 @@ sub index ($self) { } sub all_rss ($self) { + my $db = GTSRSSApi::DB->connect; my @news = $db->selectall_array( <<'EOF', { Slice => {} } ); SELECT news_text, date FROM news ORDER BY date DESC LIMIT 100; EOF @@ -36,6 +36,7 @@ EOF } sub shiny_rss ($self) { + my $db = GTSRSSApi::DB->connect; my @news = $db->selectall_array( <<'EOF', { Slice => {} } ); SELECT news_text, date FROM news WHERE is_shiny ORDER BY date DESC LIMIT 100; EOF @@ -51,6 +52,7 @@ EOF } sub pokerus_rss($self) { + my $db = GTSRSSApi::DB->connect; my @news = $db->selectall_array( <<'EOF', { Slice => {} } ); SELECT news_text, date FROM news WHERE has_pokerus ORDER BY date DESC LIMIT 100; EOF