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 $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

View File

@ -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