summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Model/Stations.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx/Model/Stations.pm')
-rw-r--r--lib/Travelynx/Model/Stations.pm35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Travelynx/Model/Stations.pm b/lib/Travelynx/Model/Stations.pm
index ecd8adb..147219f 100644
--- a/lib/Travelynx/Model/Stations.pm
+++ b/lib/Travelynx/Model/Stations.pm
@@ -50,6 +50,41 @@ sub add_or_update {
);
}
+sub add_meta {
+ my ( $self, %opt ) = @_;
+ my $db = $opt{db} // $self->{pg}->db;
+ my $eva = $opt{eva};
+ my @meta = @{ $opt{meta} };
+
+ for my $meta (@meta) {
+ if ( $meta != $eva ) {
+ $db->insert(
+ 'related_stations',
+ {
+ eva => $eva,
+ meta => $meta
+ },
+ { on_conflict => undef }
+ );
+ }
+ }
+}
+
+sub get_meta {
+ my ( $self, %opt ) = @_;
+ my $db = $opt{db} // $self->{pg}->db;
+ my $eva = $opt{eva};
+
+ my $res = $db->select( 'related_stations', ['meta'], { eva => $eva } );
+ my @ret;
+
+ while ( my $row = $res->hash ) {
+ push( @ret, $row->{meta} );
+ }
+
+ return @ret;
+}
+
sub get_for_autocomplete {
my ($self) = @_;