database: avoid needlessly incrementing backends.id
This commit is contained in:
parent
9dc5d26380
commit
e2b5365810
1 changed files with 18 additions and 8 deletions
|
@ -2815,17 +2815,27 @@ sub sync_stations {
|
||||||
sub sync_backends {
|
sub sync_backends {
|
||||||
my ($db) = @_;
|
my ($db) = @_;
|
||||||
for my $service ( Travel::Status::DE::HAFAS::get_services() ) {
|
for my $service ( Travel::Status::DE::HAFAS::get_services() ) {
|
||||||
$db->insert(
|
my $present = $db->select(
|
||||||
'backends',
|
'backends',
|
||||||
|
'count(*) as count',
|
||||||
{
|
{
|
||||||
iris => 0,
|
|
||||||
hafas => 1,
|
hafas => 1,
|
||||||
efa => 0,
|
name => $service->{shortname}
|
||||||
ris => 0,
|
}
|
||||||
name => $service->{shortname},
|
)->hash->{count};
|
||||||
},
|
if ( not $present ) {
|
||||||
{ on_conflict => undef }
|
$db->insert(
|
||||||
);
|
'backends',
|
||||||
|
{
|
||||||
|
iris => 0,
|
||||||
|
hafas => 1,
|
||||||
|
efa => 0,
|
||||||
|
ris => 0,
|
||||||
|
name => $service->{shortname},
|
||||||
|
},
|
||||||
|
{ on_conflict => undef }
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->update( 'schema_version',
|
$db->update( 'schema_version',
|
||||||
|
|
Loading…
Reference in a new issue