summaryrefslogtreecommitdiff
path: root/lib/Travelynx
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-08-12 18:08:41 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-08-12 18:08:41 +0200
commite2b5365810bd49c799b396a98cbb07b54a86f475 (patch)
treeaac163d52ceab272a372a76e5973011b710cb5ac /lib/Travelynx
parent9dc5d26380db07ce8cb4d1c3a98dada09a70c07a (diff)
database: avoid needlessly incrementing backends.id
Diffstat (limited to 'lib/Travelynx')
-rw-r--r--lib/Travelynx/Command/database.pm26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm
index 4389430..ebe9537 100644
--- a/lib/Travelynx/Command/database.pm
+++ b/lib/Travelynx/Command/database.pm
@@ -2815,17 +2815,27 @@ sub sync_stations {
sub sync_backends {
my ($db) = @_;
for my $service ( Travel::Status::DE::HAFAS::get_services() ) {
- $db->insert(
+ my $present = $db->select(
'backends',
+ 'count(*) as count',
{
- iris => 0,
hafas => 1,
- efa => 0,
- ris => 0,
- name => $service->{shortname},
- },
- { on_conflict => undef }
- );
+ name => $service->{shortname}
+ }
+ )->hash->{count};
+ if ( not $present ) {
+ $db->insert(
+ 'backends',
+ {
+ iris => 0,
+ hafas => 1,
+ efa => 0,
+ ris => 0,
+ name => $service->{shortname},
+ },
+ { on_conflict => undef }
+ );
+ }
}
$db->update( 'schema_version',