dbquery

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 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 LoadConnections

func LoadConnections(
	DB *sqlx.DB, querySources []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 source agency's timezone. This effectively "abstracts": timezone handling, multiday queries, and additionally using connections from different source 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, querySources []int, dateYYYYMMDD uint, fromSeconds, toSeconds int,
	connIDs []string,
) (*[]dbt.ConnectionVerbose, error)

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

func LoadStopWalks

func LoadStopWalks(
	DB *sqlx.DB,
	querySources []int,
	originPoint utilfuncs.Coord,
	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,
	querySources []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,
	querySources []int,
	coord utilfuncs.Coord,
) error

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

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