dbquery

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dbquery contains queries that operate on MR's 'DbConnection' type. There are essentially just functions that go out to the database and make some query returning a true/false or single value return.

For queries which return arrays / multiple result see dbtomem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadAgencyTimezones added in v0.6.0

func LoadAgencyTimezones(DB *sqlx.DB, queryFeedIDs []int) (*[]string, error)

LoadAgencyTimezones simply extracts the timezone names for the given query feed ids.

func LoadConnections

func LoadConnections(
	DB *sqlx.DB, queryFeedIDs []int, tzToUTCDeltasMap map[string]int, dateYYYYMMDD uint, fromUTCSeconds, toUTCSeconds int,
) (*[]dbt.Connection, error)

LoadConnections loads the valid connections for the given input timespan. Note input from/to seconds are expected to be in UTC timezone for the date and thus can be negative values themselves.

Returned connections from_stop_drutctime and to_stop_drutctime are in UTC seconds and normalized in-query based on the feedid agency's timezone. This effectively "abstracts": timezone handling, multiday queries, and additionally using connections from different feedid timezones into a normalized format (returned connections existing as from/to UTC seconds relative to a given YYYYMMDD date).

func LoadConnectionsVerbose

func LoadConnectionsVerbose(
	DB *sqlx.DB, queryFeedIDs []int, tzToUTCDeltasMap map[string]int, dateYYYYMMDD uint, fromUTCSeconds, toUTCSeconds int,
	connIDs *[]string, fromStopIDs *[]string,
) (*[]dbt.ConnectionVerbose, error)

LoadConnectionsVerbose loads the connections for the given connection IDs note, that conn_id incoporates the feed id as a prefix, so passing query feedid here is solely for

func LoadStopWalks

func LoadStopWalks(
	DB *sqlx.DB,
	queryFeedIDs []int,
	originPoint [2]float64,
	maxWalkKM float64,
) (*[]dbt.StopWalk, error)

LoadStopWalks loads stopwalks given the input origin coordinate and a max distance in km to walk

func LoadTransfers

func LoadTransfers(
	DB *sqlx.DB,
	queryFeedIDs []int,
	minTransferSeconds uint,
	maxTransferSeconds uint,
	walkspeedKmHr float64,
	transferCategories []string,
) (*[]dbt.Transfer, error)

LoadTransfers load the transfers from three seperate categories flagged by transferCategories:

"f" - Feed-provided transfers contained in transfers.txt "i" - Implicit transfers (transfers from one stop to the same stop) "g" - Generated transfres (transfers from one stop to a different stop)

Note - IntArraysSortedFilter logic makes sures pairs are not duplicate e.g. [[1 3] [3 1] [5 1]] is reduced to [[1 3] [5 1]]

func QueryBoundsMatch

func QueryBoundsMatch(
	DB *sqlx.DB,
	queryFeedIDs []int,
	coord [2]float64,
) error

QueryBoundsMatch is a querying function that determines if the passed param matches for the feed_id for the DB conneciton min/max lat/lon

func QueryFeedIDsLoadedAndComputed added in v0.7.0

func QueryFeedIDsLoadedAndComputed(
	DB *sqlx.DB,
	queryFeedIDs []int,
) error

func QueryValue

func QueryValue(DB *sqlx.DB, query string, args []any) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL