Fixing db error.

This commit is contained in:
sergiotarxz 2024-05-06 20:09:50 +02:00
parent 8e5437fe40
commit eff8f40143
2 changed files with 4 additions and 2 deletions

View File

@ -27,7 +27,6 @@ my $viewstate;
my $viewstate_generator; my $viewstate_generator;
my $event_validation; my $event_validation;
my $pg_date_formatter = DateTime::Format::Pg->new; my $pg_date_formatter = DateTime::Format::Pg->new;
my $db = GTSRSSApi::DB->connect;
# This method will run once at server start # This method will run once at server start
sub startup ($self) { sub startup ($self) {
@ -105,6 +104,7 @@ sub fetch_gts_data {
my @offers = my @offers =
$html->find('.gtsPokemonSummary.gtsOffer.pfBoxThin.pfFormGroup') $html->find('.gtsPokemonSummary.gtsOffer.pfBoxThin.pfFormGroup')
->each; ->each;
my $db = GTSRSSApi::DB->connect;
$db->do( <<'EOF', undef ); $db->do( <<'EOF', undef );
UPDATE offers SET marked_to_check_is_available = true WHERE is_available = true; UPDATE offers SET marked_to_check_is_available = true WHERE is_available = true;
EOF EOF

View File

@ -11,7 +11,6 @@ use Mojo::DOM;
use Mojo::Base 'Mojolicious::Controller', -signatures; use Mojo::Base 'Mojolicious::Controller', -signatures;
use GTSRSSApi::DB; use GTSRSSApi::DB;
my $db = GTSRSSApi::DB->connect;
# This action will render a template # This action will render a template
sub index ($self) { sub index ($self) {
@ -21,6 +20,7 @@ sub index ($self) {
} }
sub all_rss ($self) { sub all_rss ($self) {
my $db = GTSRSSApi::DB->connect;
my @news = $db->selectall_array( <<'EOF', { Slice => {} } ); my @news = $db->selectall_array( <<'EOF', { Slice => {} } );
SELECT news_text, date FROM news ORDER BY date DESC LIMIT 100; SELECT news_text, date FROM news ORDER BY date DESC LIMIT 100;
EOF EOF
@ -36,6 +36,7 @@ EOF
} }
sub shiny_rss ($self) { sub shiny_rss ($self) {
my $db = GTSRSSApi::DB->connect;
my @news = $db->selectall_array( <<'EOF', { Slice => {} } ); my @news = $db->selectall_array( <<'EOF', { Slice => {} } );
SELECT news_text, date FROM news WHERE is_shiny ORDER BY date DESC LIMIT 100; SELECT news_text, date FROM news WHERE is_shiny ORDER BY date DESC LIMIT 100;
EOF EOF
@ -51,6 +52,7 @@ EOF
} }
sub pokerus_rss($self) { sub pokerus_rss($self) {
my $db = GTSRSSApi::DB->connect;
my @news = $db->selectall_array( <<'EOF', { Slice => {} } ); my @news = $db->selectall_array( <<'EOF', { Slice => {} } );
SELECT news_text, date FROM news WHERE has_pokerus ORDER BY date DESC LIMIT 100; SELECT news_text, date FROM news WHERE has_pokerus ORDER BY date DESC LIMIT 100;
EOF EOF