diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-08-13 10:55:32 +0200 | 
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-08-13 10:55:32 +0200 | 
| commit | 944688cfff5ee4c886adbe856889ab1e40bd58ac (patch) | |
| tree | a1a1eded3634d73c0dcc07cf0c7b037af18b4e4f /lib | |
| parent | a58a312baf4408774584bbad5d170583f05e07a7 (diff) | |
influxdb: add stations statistics
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Travelynx/Command/influxdb.pm | 59 | 
1 files changed, 58 insertions, 1 deletions
| diff --git a/lib/Travelynx/Command/influxdb.pm b/lib/Travelynx/Command/influxdb.pm index 5767a00..1ad0d6c 100644 --- a/lib/Travelynx/Command/influxdb.pm +++ b/lib/Travelynx/Command/influxdb.pm @@ -29,6 +29,7 @@ sub run {  	my $active = $now->clone->subtract( months => 1 );  	my @stats; +	my @stations;  	my @traewelling;  	push( @@ -83,6 +84,44 @@ sub run {  			$db->select( 'polylines', 'count(*) as count' )->hash->{count}  		)  	); + +	push( +		@stations, +		query_to_influx( +			'iris', +			$db->select( +				'stations', +				'count(*) as count', +				{ +					source   => 0, +					archived => 0 +				} +			)->hash->{count} +		) +	); +	push( +		@stations, +		query_to_influx( +			'hafas', +			$db->select( +				'stations', +				'count(*) as count', +				{ +					source   => 1, +					archived => 0 +				} +			)->hash->{count} +		) +	); +	push( +		@stations, +		query_to_influx( +			'archived', +			$db->select( 'stations', 'count(*) as count', { archived => 1 } ) +			  ->hash->{count} +		) +	); +  	push(  		@traewelling,  		query_to_influx( @@ -115,13 +154,31 @@ sub run {  		)  	); -	if ( $self->app->config->{influxdb}->{url} ) { +	if ( $self->app->mode eq 'development' ) { +		$self->app->log->debug( 'POST ' +			  . $self->app->config->{influxdb}->{url} +			  . ' stats ' +			  . join( ',', @stats ) ); +		$self->app->log->debug( 'POST ' +			  . $self->app->config->{influxdb}->{url} +			  . ' stations ' +			  . join( ',', @stations ) ); +		$self->app->log->debug( 'POST ' +			  . $self->app->config->{influxdb}->{url} +			  . ' traewelling ' +			  . join( ',', @traewelling ) ); +	} +	elsif ( $self->app->config->{influxdb}->{url} ) {  		$self->app->ua->post_p(  			$self->app->config->{influxdb}->{url},  			'stats ' . join( ',', @stats )  		)->wait;  		$self->app->ua->post_p(  			$self->app->config->{influxdb}->{url}, +			'stations ' . join( ',', @stations ) +		)->wait; +		$self->app->ua->post_p( +			$self->app->config->{influxdb}->{url},  			'traewelling ' . join( ',', @traewelling )  		)->wait;  	} | 
