db

package
v0.0.0-...-87ff850 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForeignKeyViolation = "23503"
	UniqueViolation     = "23505"
)
View Source
const (
	UserTokenPurposeRegistration  = "registration"
	UserTokenPurposePasswordReset = "password_reset"
)

Variables

View Source
var (
	ErrBatchAlreadyClosed = errors.New("batch already closed")
)
View Source
var ErrRecordNotFound = pgx.ErrNoRows
View Source
var ErrUniqueViolation = &pgconn.PgError{
	Code: UniqueViolation,
}

Functions

func ErrorCode

func ErrorCode(err error) string

Types

type APIToken

type APIToken struct {
	ID          int64              `json:"id"`
	UserID      int64              `json:"user_id"`
	Name        string             `json:"name"`
	TokenHash   string             `json:"token_hash"`
	TokenPrefix string             `json:"token_prefix"`
	Permissions []byte             `json:"permissions"`
	LastUsedAt  pgtype.Timestamptz `json:"last_used_at"`
	ExpiresAt   pgtype.Timestamptz `json:"expires_at"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
}

type AccessRequest

type AccessRequest struct {
	ID             int64              `json:"id"`
	UserID         int64              `json:"user_id"`
	StationIds     []byte             `json:"station_ids"`
	AllStations    bool               `json:"all_stations"`
	Variables      []byte             `json:"variables"`
	AllVariables   bool               `json:"all_variables"`
	MaxDaysHistory pgtype.Int4        `json:"max_days_history"`
	Reason         pgtype.Text        `json:"reason"`
	Status         string             `json:"status"`
	ReviewedBy     pgtype.Int8        `json:"reviewed_by"`
	ReviewNote     pgtype.Text        `json:"review_note"`
	ReviewedAt     pgtype.Timestamptz `json:"reviewed_at"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	UpdatedAt      pgtype.Timestamptz `json:"updated_at"`
}

type BatchCreateUserRolesBatchResults

type BatchCreateUserRolesBatchResults struct {
	// contains filtered or unexported fields
}

func (*BatchCreateUserRolesBatchResults) Close

func (*BatchCreateUserRolesBatchResults) QueryRow

func (b *BatchCreateUserRolesBatchResults) QueryRow(f func(int, RoleUser, error))

type BatchCreateUserRolesParams

type BatchCreateUserRolesParams struct {
	Username string `json:"username"`
	RoleName string `json:"role_name"`
}

type BatchDeleteUserRolesBatchResults

type BatchDeleteUserRolesBatchResults struct {
	// contains filtered or unexported fields
}

func (*BatchDeleteUserRolesBatchResults) Close

func (*BatchDeleteUserRolesBatchResults) Exec

func (b *BatchDeleteUserRolesBatchResults) Exec(f func(int, error))

type BatchDeleteUserRolesParams

type BatchDeleteUserRolesParams struct {
	Username string `json:"username"`
	RoleName string `json:"role_name"`
}

type CompleteRegistrationTxParams

type CompleteRegistrationTxParams struct {
	TokenHash string
	Password  string
	FullName  pgtype.Text
	Email     pgtype.Text
	SetEmail  bool
}

type CompleteUserRegistrationParams

type CompleteUserRegistrationParams struct {
	Password string      `json:"password"`
	FullName pgtype.Text `json:"full_name"`
	SetEmail bool        `json:"set_email"`
	Email    pgtype.Text `json:"email"`
	ID       int64       `json:"id"`
}

type ConsumeUserTokenParams

type ConsumeUserTokenParams struct {
	TokenHash string `json:"token_hash"`
	Purpose   string `json:"purpose"`
}

type CountMOObservationsParams

type CountMOObservationsParams struct {
	StationIds  []int64            `json:"station_ids"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
}

type CountObservationsParams

type CountObservationsParams struct {
	StationIds  []int64            `json:"station_ids"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
}

type CountStationMOObservationsParams

type CountStationMOObservationsParams struct {
	StationID   int64              `json:"station_id"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
}

type CountStationObservationsParams

type CountStationObservationsParams struct {
	StationID   int64              `json:"station_id"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
}

type CountStationsWithinBBoxParams

type CountStationsWithinBBoxParams struct {
	Xmin   float32     `json:"xmin"`
	Ymin   float32     `json:"ymin"`
	Xmax   float32     `json:"xmax"`
	Ymax   float32     `json:"ymax"`
	Status pgtype.Text `json:"status"`
}

type CountStationsWithinRadiusParams

type CountStationsWithinRadiusParams struct {
	Cx     float32     `json:"cx"`
	Cy     float32     `json:"cy"`
	R      float32     `json:"r"`
	Status pgtype.Text `json:"status"`
}

type CreateAPITokenParams

type CreateAPITokenParams struct {
	UserID      int64              `json:"user_id"`
	Name        string             `json:"name"`
	TokenHash   string             `json:"token_hash"`
	TokenPrefix string             `json:"token_prefix"`
	Permissions []byte             `json:"permissions"`
	ExpiresAt   pgtype.Timestamptz `json:"expires_at"`
}

type CreateAccessRequestParams

type CreateAccessRequestParams struct {
	UserID         int64       `json:"user_id"`
	StationIds     []byte      `json:"station_ids"`
	AllStations    bool        `json:"all_stations"`
	Variables      []byte      `json:"variables"`
	AllVariables   bool        `json:"all_variables"`
	MaxDaysHistory pgtype.Int4 `json:"max_days_history"`
	Reason         pgtype.Text `json:"reason"`
}

type CreateCurrentObservationParams

type CreateCurrentObservationParams struct {
	StationID     int64              `json:"station_id"`
	Rain          pgtype.Float4      `json:"rain"`
	Temp          pgtype.Float4      `json:"temp"`
	Rh            pgtype.Float4      `json:"rh"`
	Wdir          pgtype.Float4      `json:"wdir"`
	Wspd          pgtype.Float4      `json:"wspd"`
	Srad          pgtype.Float4      `json:"srad"`
	Mslp          pgtype.Float4      `json:"mslp"`
	Tn            pgtype.Float4      `json:"tn"`
	Tx            pgtype.Float4      `json:"tx"`
	Gust          pgtype.Float4      `json:"gust"`
	RainAccum     pgtype.Float4      `json:"rain_accum"`
	TnTimestamp   pgtype.Timestamptz `json:"tn_timestamp"`
	TxTimestamp   pgtype.Timestamptz `json:"tx_timestamp"`
	GustTimestamp pgtype.Timestamptz `json:"gust_timestamp"`
	Timestamp     pgtype.Timestamptz `json:"timestamp"`
}

type CreateGLabsLoadParams

type CreateGLabsLoadParams struct {
	Promo         pgtype.Text `json:"promo"`
	TransactionID pgtype.Int4 `json:"transaction_id"`
	Status        pgtype.Text `json:"status"`
	MobileNumber  string      `json:"mobile_number"`
}

type CreateMisolStationParams

type CreateMisolStationParams struct {
	ID        int64 `json:"id"`
	StationID int64 `json:"station_id"`
}

type CreateMisolStationTxParams

type CreateMisolStationTxParams struct {
	ID        int64         `json:"id"`
	Name      string        `json:"name"`
	Lat       pgtype.Float4 `json:"lat"`
	Lon       pgtype.Float4 `json:"lon"`
	Elevation pgtype.Float4 `json:"elevation"`
	Province  pgtype.Text   `json:"province"`
	Region    pgtype.Text   `json:"region"`
	Address   pgtype.Text   `json:"address"`
}

type CreateMisolStationTxResult

type CreateMisolStationTxResult struct {
	ID   int64
	Info ObservationsStation
}

type CreatePasswordResetTokenTxParams

type CreatePasswordResetTokenTxParams struct {
	UserID    int64
	TokenHash string
	ExpiresAt time.Time
	CreatedBy pgtype.Int8
}

type CreateRegistrationTokenTxParams

type CreateRegistrationTokenTxParams struct {
	UserID    int64
	TokenHash string
	ExpiresAt time.Time
	CreatedBy pgtype.Int8
}

type CreateRoleParams

type CreateRoleParams struct {
	Name        string      `json:"name"`
	Description pgtype.Text `json:"description"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID          `json:"id"`
	UserID       int64              `json:"user_id"`
	RefreshToken string             `json:"refresh_token"`
	UserAgent    string             `json:"user_agent"`
	ClientIp     string             `json:"client_ip"`
	IsBlocked    bool               `json:"is_blocked"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
}

type CreateSimAccessTokenParams

type CreateSimAccessTokenParams struct {
	AccessToken  string `json:"access_token"`
	Type         string `json:"type"`
	MobileNumber string `json:"mobile_number"`
}

type CreateSimCardParams

type CreateSimCardParams struct {
	MobileNumber string      `json:"mobile_number"`
	Type         pgtype.Text `json:"type"`
}

type CreateStationHealthParams

type CreateStationHealthParams struct {
	Vb1               pgtype.Float4      `json:"vb1"`
	Vb2               pgtype.Float4      `json:"vb2"`
	Curr              pgtype.Float4      `json:"curr"`
	Bp1               pgtype.Float4      `json:"bp1"`
	Bp2               pgtype.Float4      `json:"bp2"`
	Cm                pgtype.Text        `json:"cm"`
	Ss                pgtype.Int4        `json:"ss"`
	TempArq           pgtype.Float4      `json:"temp_arq"`
	RhArq             pgtype.Float4      `json:"rh_arq"`
	Fpm               pgtype.Text        `json:"fpm"`
	ErrorMsg          pgtype.Text        `json:"error_msg"`
	Message           pgtype.Text        `json:"message"`
	DataCount         pgtype.Int4        `json:"data_count"`
	DataStatus        pgtype.Text        `json:"data_status"`
	Timestamp         pgtype.Timestamptz `json:"timestamp"`
	MinutesDifference pgtype.Int4        `json:"minutes_difference"`
	StationID         int64              `json:"station_id"`
}

type CreateStationMOObservationParams

type CreateStationMOObservationParams struct {
	Pres      pgtype.Float4      `json:"pres"`
	Rr        pgtype.Float4      `json:"rr"`
	Rh        pgtype.Float4      `json:"rh"`
	Temp      pgtype.Float4      `json:"temp"`
	Td        pgtype.Float4      `json:"td"`
	Wdir      pgtype.Float4      `json:"wdir"`
	Wspd      pgtype.Float4      `json:"wspd"`
	Wspdx     pgtype.Float4      `json:"wspdx"`
	Srad      pgtype.Float4      `json:"srad"`
	Hi        pgtype.Float4      `json:"hi"`
	Wchill    pgtype.Float4      `json:"wchill"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	QcLevel   int32              `json:"qc_level"`
	StationID int64              `json:"station_id"`
}

type CreateStationObservationParams

type CreateStationObservationParams struct {
	Pres               pgtype.Float4      `json:"pres"`
	Rr                 pgtype.Float4      `json:"rr"`
	RainTips           pgtype.Int4        `json:"rain_tips"`
	RainCumulativeTips pgtype.Int4        `json:"rain_cumulative_tips"`
	Rh                 pgtype.Float4      `json:"rh"`
	Temp               pgtype.Float4      `json:"temp"`
	Td                 pgtype.Float4      `json:"td"`
	Wdir               pgtype.Float4      `json:"wdir"`
	Wspd               pgtype.Float4      `json:"wspd"`
	Wspdx              pgtype.Float4      `json:"wspdx"`
	Srad               pgtype.Float4      `json:"srad"`
	Mslp               pgtype.Float4      `json:"mslp"`
	Hi                 pgtype.Float4      `json:"hi"`
	Wchill             pgtype.Float4      `json:"wchill"`
	Timestamp          pgtype.Timestamptz `json:"timestamp"`
	QcLevel            int32              `json:"qc_level"`
	StationID          int64              `json:"station_id"`
}

type CreateStationParams

type CreateStationParams struct {
	Name          string        `json:"name"`
	Elevation     pgtype.Float4 `json:"elevation"`
	DateInstalled pgtype.Date   `json:"date_installed"`
	MoStationID   pgtype.Text   `json:"mo_station_id"`
	SmsSystemType pgtype.Text   `json:"sms_system_type"`
	MobileNumber  pgtype.Text   `json:"mobile_number"`
	StationType   pgtype.Text   `json:"station_type"`
	StationType2  pgtype.Text   `json:"station_type2"`
	StationUrl    pgtype.Text   `json:"station_url"`
	Status        pgtype.Text   `json:"status"`
	LoggerVersion pgtype.Text   `json:"logger_version"`
	PriorityLevel pgtype.Text   `json:"priority_level"`
	ProviderID    pgtype.Text   `json:"provider_id"`
	Province      pgtype.Text   `json:"province"`
	Region        pgtype.Text   `json:"region"`
	Address       pgtype.Text   `json:"address"`
	Lat           pgtype.Float4 `json:"lat"`
	Lon           pgtype.Float4 `json:"lon"`
}

type CreateUserParams

type CreateUserParams struct {
	Username string      `json:"username"`
	Password string      `json:"password"`
	FullName string      `json:"full_name"`
	Email    pgtype.Text `json:"email"`
	Status   string      `json:"status"`
}

type CreateUserTokenParams

type CreateUserTokenParams struct {
	UserID    int64              `json:"user_id"`
	Purpose   string             `json:"purpose"`
	TokenHash string             `json:"token_hash"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	CreatedBy pgtype.Int8        `json:"created_by"`
}

type CreateWeatherlinkStationParams

type CreateWeatherlinkStationParams struct {
	StationID int64       `json:"station_id"`
	Uuid      pgtype.Text `json:"uuid"`
	APIKey    pgtype.Text `json:"api_key"`
	APISecret pgtype.Text `json:"api_secret"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

type DeleteStationHealthParams

type DeleteStationHealthParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type DeleteStationMOObservationParams

type DeleteStationMOObservationParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type DeleteStationObservationParams

type DeleteStationObservationParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type FirstOrCreateSimAccessTokenTxParams

type FirstOrCreateSimAccessTokenTxParams struct {
	MobileNumber     string      `json:"mobile_number"`
	MobileNumberType pgtype.Text `json:"mobile_number_type"`
	AccessToken      string      `json:"access_token"`
	AccessTokenType  string      `json:"access_token_type"`
}

type FirstOrCreateSimAccessTokenTxResult

type FirstOrCreateSimAccessTokenTxResult struct {
	AccessToken SimAccessToken
	IsCreated   bool
}

type GetLatestStationObservationRow

type GetLatestStationObservationRow struct {
	ID                  int64               `json:"id"`
	Name                string              `json:"name"`
	Lat                 pgtype.Float4       `json:"lat"`
	Lon                 pgtype.Float4       `json:"lon"`
	Elevation           pgtype.Float4       `json:"elevation"`
	Address             pgtype.Text         `json:"address"`
	ObservationsCurrent ObservationsCurrent `json:"observations_current"`
}

type GetNearestLatestStationObservationParams

type GetNearestLatestStationObservationParams struct {
	Lon           float32 `json:"lon"`
	Lat           float32 `json:"lat"`
	WindowSeconds float64 `json:"window_seconds"`
}

type GetNearestLatestStationObservationRow

type GetNearestLatestStationObservationRow struct {
	ID            int64              `json:"id"`
	Name          string             `json:"name"`
	Lat           pgtype.Float4      `json:"lat"`
	Lon           pgtype.Float4      `json:"lon"`
	Elevation     pgtype.Float4      `json:"elevation"`
	Address       pgtype.Text        `json:"address"`
	Rain          pgtype.Float4      `json:"rain"`
	Temp          pgtype.Float4      `json:"temp"`
	Rh            pgtype.Float4      `json:"rh"`
	Wdir          pgtype.Float4      `json:"wdir"`
	Wspd          pgtype.Float4      `json:"wspd"`
	Srad          pgtype.Float4      `json:"srad"`
	Mslp          pgtype.Float4      `json:"mslp"`
	Tn            pgtype.Float4      `json:"tn"`
	Tx            pgtype.Float4      `json:"tx"`
	Gust          pgtype.Float4      `json:"gust"`
	RainAccum     pgtype.Float4      `json:"rain_accum"`
	TnTimestamp   pgtype.Timestamptz `json:"tn_timestamp"`
	TxTimestamp   pgtype.Timestamptz `json:"tx_timestamp"`
	GustTimestamp pgtype.Timestamptz `json:"gust_timestamp"`
	Timestamp     pgtype.Timestamptz `json:"timestamp"`
}

type GetStationHealthParams

type GetStationHealthParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type GetStationMOObservationParams

type GetStationMOObservationParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type GetStationObservationParams

type GetStationObservationParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type GetStationStatsByIdsParams

type GetStationStatsByIdsParams struct {
	WindowSeconds float64 `json:"window_seconds"`
	StationIds    []int64 `json:"station_ids"`
}

type GetStationStatsByIdsRow

type GetStationStatsByIdsRow struct {
	Total     int64 `json:"total"`
	Online    int64 `json:"online"`
	Offline   int64 `json:"offline"`
	Reporting int64 `json:"reporting"`
}

type GetStationStatsRow

type GetStationStatsRow struct {
	Total     int64 `json:"total"`
	Online    int64 `json:"online"`
	Offline   int64 `json:"offline"`
	Reporting int64 `json:"reporting"`
}

type GetUserTokenByHashParams

type GetUserTokenByHashParams struct {
	TokenHash string `json:"token_hash"`
	Purpose   string `json:"purpose"`
}

type GlabsLoad

type GlabsLoad struct {
	ID            int64              `json:"id"`
	Status        pgtype.Text        `json:"status"`
	Promo         pgtype.Text        `json:"promo"`
	TransactionID pgtype.Int4        `json:"transaction_id"`
	MobileNumber  string             `json:"mobile_number"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

type InvalidateUserTokensParams

type InvalidateUserTokensParams struct {
	UserID  int64  `json:"user_id"`
	Purpose string `json:"purpose"`
}

type ListAccessRequestsByStatusParams

type ListAccessRequestsByStatusParams struct {
	Status string `json:"status"`
	Limit  int32  `json:"limit"`
	Offset int32  `json:"offset"`
}

type ListAccessRequestsParams

type ListAccessRequestsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListLatestObservationsRow

type ListLatestObservationsRow struct {
	ID            int64              `json:"id"`
	Name          string             `json:"name"`
	Lat           pgtype.Float4      `json:"lat"`
	Lon           pgtype.Float4      `json:"lon"`
	Elevation     pgtype.Float4      `json:"elevation"`
	Address       pgtype.Text        `json:"address"`
	Rain          pgtype.Float4      `json:"rain"`
	Temp          pgtype.Float4      `json:"temp"`
	Rh            pgtype.Float4      `json:"rh"`
	Wdir          pgtype.Float4      `json:"wdir"`
	Wspd          pgtype.Float4      `json:"wspd"`
	Srad          pgtype.Float4      `json:"srad"`
	Mslp          pgtype.Float4      `json:"mslp"`
	Tn            pgtype.Float4      `json:"tn"`
	Tx            pgtype.Float4      `json:"tx"`
	Gust          pgtype.Float4      `json:"gust"`
	RainAccum     pgtype.Float4      `json:"rain_accum"`
	TnTimestamp   pgtype.Timestamptz `json:"tn_timestamp"`
	TxTimestamp   pgtype.Timestamptz `json:"tx_timestamp"`
	GustTimestamp pgtype.Timestamptz `json:"gust_timestamp"`
	Timestamp     pgtype.Timestamptz `json:"timestamp"`
	Rn            int64              `json:"rn"`
}

type ListLufftStationMsgParams

type ListLufftStationMsgParams struct {
	StationID int64 `json:"station_id"`
	Limit     int32 `json:"limit"`
	Offset    int32 `json:"offset"`
}

type ListLufftStationMsgRow

type ListLufftStationMsgRow struct {
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	Message   pgtype.Text        `json:"message"`
}

type ListMOObservationsParams

type ListMOObservationsParams struct {
	StationIds  []int64            `json:"station_ids"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
	Offset      int32              `json:"offset"`
	Limit       pgtype.Int4        `json:"limit"`
}

type ListObservationsParams

type ListObservationsParams struct {
	StationIds  []int64            `json:"station_ids"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
	CursorTs    pgtype.Timestamptz `json:"cursor_ts"`
	CursorID    pgtype.Int8        `json:"cursor_id"`
	Offset      int32              `json:"offset"`
	Limit       pgtype.Int4        `json:"limit"`
}

type ListRolesParams

type ListRolesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListStationHealthsParams

type ListStationHealthsParams struct {
	StationID int64 `json:"station_id"`
	Limit     int32 `json:"limit"`
	Offset    int32 `json:"offset"`
}

type ListStationMOObservationsParams

type ListStationMOObservationsParams struct {
	StationID   int64              `json:"station_id"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
	CursorTs    pgtype.Timestamptz `json:"cursor_ts"`
	CursorID    pgtype.Int8        `json:"cursor_id"`
	Offset      int32              `json:"offset"`
	Limit       pgtype.Int4        `json:"limit"`
}

type ListStationObservationsParams

type ListStationObservationsParams struct {
	StationID   int64              `json:"station_id"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
	CursorTs    pgtype.Timestamptz `json:"cursor_ts"`
	CursorID    pgtype.Int8        `json:"cursor_id"`
	Offset      int32              `json:"offset"`
	Limit       pgtype.Int4        `json:"limit"`
}

type ListStationsByIdsParams

type ListStationsByIdsParams struct {
	StationIds []int64     `json:"station_ids"`
	Offset     int32       `json:"offset"`
	Limit      pgtype.Int4 `json:"limit"`
}

type ListStationsParams

type ListStationsParams struct {
	Status pgtype.Text `json:"status"`
	Offset int32       `json:"offset"`
	Limit  pgtype.Int4 `json:"limit"`
}

type ListStationsWithinBBoxParams

type ListStationsWithinBBoxParams struct {
	Xmin   float32     `json:"xmin"`
	Ymin   float32     `json:"ymin"`
	Xmax   float32     `json:"xmax"`
	Ymax   float32     `json:"ymax"`
	Status pgtype.Text `json:"status"`
	Offset int32       `json:"offset"`
	Limit  pgtype.Int4 `json:"limit"`
}

type ListStationsWithinRadiusParams

type ListStationsWithinRadiusParams struct {
	Cx     float32     `json:"cx"`
	Cy     float32     `json:"cy"`
	R      float32     `json:"r"`
	Status pgtype.Text `json:"status"`
	Offset int32       `json:"offset"`
	Limit  pgtype.Int4 `json:"limit"`
}

type ListUserRolesByUserIDsRow

type ListUserRolesByUserIDsRow struct {
	UserID   int64  `json:"user_id"`
	RoleName string `json:"role_name"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32       `json:"limit"`
	Offset int32       `json:"offset"`
	Status pgtype.Text `json:"status"`
}

type ListWeatherlinkStationsParams

type ListWeatherlinkStationsParams struct {
	Offset int32       `json:"offset"`
	Limit  pgtype.Int4 `json:"limit"`
}

type MisolStation

type MisolStation struct {
	ID        int64 `json:"id"`
	StationID int64 `json:"station_id"`
}

type ObservationsCurrent

type ObservationsCurrent struct {
	ID            int64              `json:"id"`
	StationID     int64              `json:"station_id"`
	Rain          pgtype.Float4      `json:"rain"`
	Temp          pgtype.Float4      `json:"temp"`
	Rh            pgtype.Float4      `json:"rh"`
	Wdir          pgtype.Float4      `json:"wdir"`
	Wspd          pgtype.Float4      `json:"wspd"`
	Srad          pgtype.Float4      `json:"srad"`
	Mslp          pgtype.Float4      `json:"mslp"`
	Tn            pgtype.Float4      `json:"tn"`
	Tx            pgtype.Float4      `json:"tx"`
	Gust          pgtype.Float4      `json:"gust"`
	RainAccum     pgtype.Float4      `json:"rain_accum"`
	Timestamp     pgtype.Timestamptz `json:"timestamp"`
	TnTimestamp   pgtype.Timestamptz `json:"tn_timestamp"`
	TxTimestamp   pgtype.Timestamptz `json:"tx_timestamp"`
	GustTimestamp pgtype.Timestamptz `json:"gust_timestamp"`
}

type ObservationsMoObservation

type ObservationsMoObservation struct {
	ID        int64              `json:"id"`
	Pres      pgtype.Float4      `json:"pres"`
	Rr        pgtype.Float4      `json:"rr"`
	Rh        pgtype.Float4      `json:"rh"`
	Temp      pgtype.Float4      `json:"temp"`
	Td        pgtype.Float4      `json:"td"`
	Wdir      pgtype.Float4      `json:"wdir"`
	Wspd      pgtype.Float4      `json:"wspd"`
	Wspdx     pgtype.Float4      `json:"wspdx"`
	Srad      pgtype.Float4      `json:"srad"`
	Hi        pgtype.Float4      `json:"hi"`
	StationID int64              `json:"station_id"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	Wchill    pgtype.Float4      `json:"wchill"`
	Rain      pgtype.Float4      `json:"rain"`
	Tx        pgtype.Float4      `json:"tx"`
	Tn        pgtype.Float4      `json:"tn"`
	Wrun      pgtype.Float4      `json:"wrun"`
	Thwi      pgtype.Float4      `json:"thwi"`
	Thswi     pgtype.Float4      `json:"thswi"`
	Senergy   pgtype.Float4      `json:"senergy"`
	Sradx     pgtype.Float4      `json:"sradx"`
	Uvi       pgtype.Float4      `json:"uvi"`
	Uvdose    pgtype.Float4      `json:"uvdose"`
	Uvx       pgtype.Float4      `json:"uvx"`
	Hdd       pgtype.Float4      `json:"hdd"`
	Cdd       pgtype.Float4      `json:"cdd"`
	Et        pgtype.Float4      `json:"et"`
	QcLevel   int32              `json:"qc_level"`
	Wdirx     pgtype.Float4      `json:"wdirx"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type ObservationsObservation

type ObservationsObservation struct {
	ID                 int64              `json:"id"`
	Pres               pgtype.Float4      `json:"pres"`
	Rr                 pgtype.Float4      `json:"rr"`
	Rh                 pgtype.Float4      `json:"rh"`
	Temp               pgtype.Float4      `json:"temp"`
	Td                 pgtype.Float4      `json:"td"`
	Wdir               pgtype.Float4      `json:"wdir"`
	Wspd               pgtype.Float4      `json:"wspd"`
	Wspdx              pgtype.Float4      `json:"wspdx"`
	Srad               pgtype.Float4      `json:"srad"`
	Mslp               pgtype.Float4      `json:"mslp"`
	Hi                 pgtype.Float4      `json:"hi"`
	StationID          int64              `json:"station_id"`
	Timestamp          pgtype.Timestamptz `json:"timestamp"`
	Wchill             pgtype.Float4      `json:"wchill"`
	QcLevel            int32              `json:"qc_level"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	RainTips           pgtype.Int4        `json:"rain_tips"`
	RainCumulativeTips pgtype.Int4        `json:"rain_cumulative_tips"`
}

type ObservationsStation

type ObservationsStation struct {
	ID            int64              `json:"id"`
	Name          string             `json:"name"`
	Lat           pgtype.Float4      `json:"lat"`
	Lon           pgtype.Float4      `json:"lon"`
	Elevation     pgtype.Float4      `json:"elevation"`
	DateInstalled pgtype.Date        `json:"date_installed"`
	MoStationID   pgtype.Text        `json:"mo_station_id"`
	SmsSystemType pgtype.Text        `json:"sms_system_type"`
	MobileNumber  pgtype.Text        `json:"mobile_number"`
	StationType   pgtype.Text        `json:"station_type"`
	StationType2  pgtype.Text        `json:"station_type2"`
	StationUrl    pgtype.Text        `json:"station_url"`
	Status        pgtype.Text        `json:"status"`
	LoggerVersion pgtype.Text        `json:"logger_version"`
	PriorityLevel pgtype.Text        `json:"priority_level"`
	ProviderID    pgtype.Text        `json:"provider_id"`
	Province      pgtype.Text        `json:"province"`
	Region        pgtype.Text        `json:"region"`
	Address       pgtype.Text        `json:"address"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
	DeletedAt     pgtype.Timestamptz `json:"deleted_at"`
	Geom          types.Point        `json:"geom"`
}

type ObservationsStationhealth

type ObservationsStationhealth struct {
	ID                int64              `json:"id"`
	Vb1               pgtype.Float4      `json:"vb1"`
	Vb2               pgtype.Float4      `json:"vb2"`
	Curr              pgtype.Float4      `json:"curr"`
	Bp1               pgtype.Float4      `json:"bp1"`
	Bp2               pgtype.Float4      `json:"bp2"`
	Cm                pgtype.Text        `json:"cm"`
	Ss                pgtype.Int4        `json:"ss"`
	TempArq           pgtype.Float4      `json:"temp_arq"`
	RhArq             pgtype.Float4      `json:"rh_arq"`
	Fpm               pgtype.Text        `json:"fpm"`
	ErrorMsg          pgtype.Text        `json:"error_msg"`
	Message           pgtype.Text        `json:"message"`
	DataCount         pgtype.Int4        `json:"data_count"`
	DataStatus        pgtype.Text        `json:"data_status"`
	Timestamp         pgtype.Timestamptz `json:"timestamp"`
	StationID         int64              `json:"station_id"`
	MinutesDifference pgtype.Int4        `json:"minutes_difference"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
}

type PostgresContainer

type PostgresContainer struct {
	Source string
	Conn   *pgxpool.Pool
	// contains filtered or unexported fields
}

func NewDockerPostgres

func NewDockerPostgres(config util.Config) *PostgresContainer

func (*PostgresContainer) Close

func (pg *PostgresContainer) Close()

type Querier

type Querier interface {
	BatchCreateUserRoles(ctx context.Context, arg []BatchCreateUserRolesParams) *BatchCreateUserRolesBatchResults
	BatchDeleteUserRoles(ctx context.Context, arg []BatchDeleteUserRolesParams) *BatchDeleteUserRolesBatchResults
	CompleteUserRegistration(ctx context.Context, arg CompleteUserRegistrationParams) (User, error)
	ConsumeUserToken(ctx context.Context, arg ConsumeUserTokenParams) (UserToken, error)
	CountAPITokensByUser(ctx context.Context, userID int64) (int64, error)
	CountAccessRequests(ctx context.Context) (int64, error)
	CountAccessRequestsByStatus(ctx context.Context, status string) (int64, error)
	CountLufftStationMsg(ctx context.Context, stationID int64) (int64, error)
	CountMOObservations(ctx context.Context, arg CountMOObservationsParams) (int64, error)
	CountObservations(ctx context.Context, arg CountObservationsParams) (int64, error)
	CountRoles(ctx context.Context) (int64, error)
	CountStationMOObservations(ctx context.Context, arg CountStationMOObservationsParams) (int64, error)
	CountStationObservations(ctx context.Context, arg CountStationObservationsParams) (int64, error)
	CountStations(ctx context.Context, status pgtype.Text) (int64, error)
	CountStationsByIds(ctx context.Context, stationIds []int64) (int64, error)
	CountStationsWithinBBox(ctx context.Context, arg CountStationsWithinBBoxParams) (int64, error)
	CountStationsWithinRadius(ctx context.Context, arg CountStationsWithinRadiusParams) (int64, error)
	CountUsers(ctx context.Context, status pgtype.Text) (int64, error)
	CreateAPIToken(ctx context.Context, arg CreateAPITokenParams) (APIToken, error)
	CreateAccessRequest(ctx context.Context, arg CreateAccessRequestParams) (AccessRequest, error)
	CreateCurrentObservation(ctx context.Context, arg CreateCurrentObservationParams) (ObservationsCurrent, error)
	CreateGLabsLoad(ctx context.Context, arg CreateGLabsLoadParams) (GlabsLoad, error)
	CreateMisolStation(ctx context.Context, arg CreateMisolStationParams) (MisolStation, error)
	CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateSimAccessToken(ctx context.Context, arg CreateSimAccessTokenParams) (SimAccessToken, error)
	CreateSimCard(ctx context.Context, arg CreateSimCardParams) (SimCard, error)
	CreateStation(ctx context.Context, arg CreateStationParams) (ObservationsStation, error)
	CreateStationHealth(ctx context.Context, arg CreateStationHealthParams) (ObservationsStationhealth, error)
	CreateStationMOObservation(ctx context.Context, arg CreateStationMOObservationParams) (ObservationsMoObservation, error)
	CreateStationObservation(ctx context.Context, arg CreateStationObservationParams) (ObservationsObservation, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	CreateUserToken(ctx context.Context, arg CreateUserTokenParams) (UserToken, error)
	CreateWeatherlinkStation(ctx context.Context, arg CreateWeatherlinkStationParams) (Weatherlink, error)
	DeleteAPIToken(ctx context.Context, id int64) error
	DeleteAccessRequest(ctx context.Context, id int64) error
	DeleteMisolStation(ctx context.Context, id int64) error
	DeleteRole(ctx context.Context, id int64) error
	DeleteSession(ctx context.Context, id uuid.UUID) error
	DeleteSessionsByUserID(ctx context.Context, userID int64) error
	DeleteSimAccessToken(ctx context.Context, accessToken string) error
	DeleteStation(ctx context.Context, id int64) error
	DeleteStationHealth(ctx context.Context, arg DeleteStationHealthParams) error
	DeleteStationMOObservation(ctx context.Context, arg DeleteStationMOObservationParams) error
	DeleteStationObservation(ctx context.Context, arg DeleteStationObservationParams) error
	DeleteUser(ctx context.Context, id int64) error
	DeleteUserAccess(ctx context.Context, userID int64) error
	GetAPIToken(ctx context.Context, id int64) (APIToken, error)
	GetAPITokenByHash(ctx context.Context, tokenHash string) (APIToken, error)
	GetAccessRequest(ctx context.Context, id int64) (AccessRequest, error)
	GetLatestStationObservation(ctx context.Context, id int64) (GetLatestStationObservationRow, error)
	GetMisolStation(ctx context.Context, id int64) (MisolStation, error)
	GetNearestLatestStationObservation(ctx context.Context, arg GetNearestLatestStationObservationParams) (GetNearestLatestStationObservationRow, error)
	GetRole(ctx context.Context, id int64) (Role, error)
	GetRoleByName(ctx context.Context, name string) (Role, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetSimAccessToken(ctx context.Context, accessToken string) (SimAccessToken, error)
	GetSimCard(ctx context.Context, mobileNumber string) (SimCard, error)
	GetStation(ctx context.Context, id int64) (ObservationsStation, error)
	GetStationByMobileNumber(ctx context.Context, mobileNumber pgtype.Text) (ObservationsStation, error)
	GetStationHealth(ctx context.Context, arg GetStationHealthParams) (ObservationsStationhealth, error)
	GetStationMOObservation(ctx context.Context, arg GetStationMOObservationParams) (ObservationsMoObservation, error)
	GetStationObservation(ctx context.Context, arg GetStationObservationParams) (ObservationsObservation, error)
	GetStationStats(ctx context.Context, windowSeconds float64) (GetStationStatsRow, error)
	GetStationStatsByIds(ctx context.Context, arg GetStationStatsByIdsParams) (GetStationStatsByIdsRow, error)
	GetUser(ctx context.Context, id int64) (User, error)
	GetUserAccess(ctx context.Context, userID int64) (UserAccess, error)
	GetUserByEmail(ctx context.Context, lower string) (User, error)
	GetUserByUsername(ctx context.Context, username string) (User, error)
	GetUserTokenByHash(ctx context.Context, arg GetUserTokenByHashParams) (UserToken, error)
	InsertCurrentMOObservations(ctx context.Context) ([]ObservationsCurrent, error)
	InsertCurrentObservations(ctx context.Context) ([]ObservationsCurrent, error)
	InvalidateUserTokens(ctx context.Context, arg InvalidateUserTokensParams) error
	ListAPITokensByUser(ctx context.Context, userID int64) ([]APIToken, error)
	ListAccessRequests(ctx context.Context, arg ListAccessRequestsParams) ([]AccessRequest, error)
	ListAccessRequestsByStatus(ctx context.Context, arg ListAccessRequestsByStatusParams) ([]AccessRequest, error)
	ListAccessRequestsByUser(ctx context.Context, userID int64) ([]AccessRequest, error)
	ListLatestObservations(ctx context.Context, windowSeconds float64) ([]ListLatestObservationsRow, error)
	ListLufftStationMsg(ctx context.Context, arg ListLufftStationMsgParams) ([]ListLufftStationMsgRow, error)
	ListMOObservations(ctx context.Context, arg ListMOObservationsParams) ([]ObservationsMoObservation, error)
	ListObservations(ctx context.Context, arg ListObservationsParams) ([]ObservationsObservation, error)
	ListRoles(ctx context.Context, arg ListRolesParams) ([]Role, error)
	ListStationHealths(ctx context.Context, arg ListStationHealthsParams) ([]ObservationsStationhealth, error)
	ListStationMOObservations(ctx context.Context, arg ListStationMOObservationsParams) ([]ObservationsMoObservation, error)
	ListStationObservations(ctx context.Context, arg ListStationObservationsParams) ([]ObservationsObservation, error)
	ListStations(ctx context.Context, arg ListStationsParams) ([]ObservationsStation, error)
	ListStationsByIds(ctx context.Context, arg ListStationsByIdsParams) ([]ObservationsStation, error)
	ListStationsWithinBBox(ctx context.Context, arg ListStationsWithinBBoxParams) ([]ObservationsStation, error)
	ListStationsWithinRadius(ctx context.Context, arg ListStationsWithinRadiusParams) ([]ObservationsStation, error)
	ListUserRoles(ctx context.Context, userID int64) ([]string, error)
	ListUserRolesByUserIDs(ctx context.Context, userIds []int64) ([]ListUserRolesByUserIDsRow, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
	ListWeatherlinkStations(ctx context.Context, arg ListWeatherlinkStationsParams) ([]Weatherlink, error)
	MarkStaleStationsOffline(ctx context.Context, staleAfterSeconds float64) (int64, error)
	ReviewUser(ctx context.Context, arg ReviewUserParams) (User, error)
	SetStationStatus(ctx context.Context, arg SetStationStatusParams) (int64, error)
	UpdateAPITokenLastUsedAt(ctx context.Context, id int64) error
	UpdateAccessRequestStatus(ctx context.Context, arg UpdateAccessRequestStatusParams) (AccessRequest, error)
	UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
	UpdateStation(ctx context.Context, arg UpdateStationParams) (ObservationsStation, error)
	UpdateStationHealth(ctx context.Context, arg UpdateStationHealthParams) (ObservationsStationhealth, error)
	UpdateStationMOObservation(ctx context.Context, arg UpdateStationMOObservationParams) (ObservationsMoObservation, error)
	UpdateStationObservation(ctx context.Context, arg UpdateStationObservationParams) (ObservationsObservation, error)
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
	UpsertUserAccess(ctx context.Context, arg UpsertUserAccessParams) (UserAccess, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) BatchCreateUserRoles

func (*Queries) BatchDeleteUserRoles

func (*Queries) CompleteUserRegistration

func (q *Queries) CompleteUserRegistration(ctx context.Context, arg CompleteUserRegistrationParams) (User, error)

func (*Queries) ConsumeUserToken

func (q *Queries) ConsumeUserToken(ctx context.Context, arg ConsumeUserTokenParams) (UserToken, error)

func (*Queries) CountAPITokensByUser

func (q *Queries) CountAPITokensByUser(ctx context.Context, userID int64) (int64, error)

func (*Queries) CountAccessRequests

func (q *Queries) CountAccessRequests(ctx context.Context) (int64, error)

func (*Queries) CountAccessRequestsByStatus

func (q *Queries) CountAccessRequestsByStatus(ctx context.Context, status string) (int64, error)

func (*Queries) CountLufftStationMsg

func (q *Queries) CountLufftStationMsg(ctx context.Context, stationID int64) (int64, error)

func (*Queries) CountMOObservations

func (q *Queries) CountMOObservations(ctx context.Context, arg CountMOObservationsParams) (int64, error)

func (*Queries) CountObservations

func (q *Queries) CountObservations(ctx context.Context, arg CountObservationsParams) (int64, error)

func (*Queries) CountRoles

func (q *Queries) CountRoles(ctx context.Context) (int64, error)

func (*Queries) CountStationMOObservations

func (q *Queries) CountStationMOObservations(ctx context.Context, arg CountStationMOObservationsParams) (int64, error)

func (*Queries) CountStationObservations

func (q *Queries) CountStationObservations(ctx context.Context, arg CountStationObservationsParams) (int64, error)

func (*Queries) CountStations

func (q *Queries) CountStations(ctx context.Context, status pgtype.Text) (int64, error)

func (*Queries) CountStationsByIds

func (q *Queries) CountStationsByIds(ctx context.Context, stationIds []int64) (int64, error)

func (*Queries) CountStationsWithinBBox

func (q *Queries) CountStationsWithinBBox(ctx context.Context, arg CountStationsWithinBBoxParams) (int64, error)

func (*Queries) CountStationsWithinRadius

func (q *Queries) CountStationsWithinRadius(ctx context.Context, arg CountStationsWithinRadiusParams) (int64, error)

func (*Queries) CountUsers

func (q *Queries) CountUsers(ctx context.Context, status pgtype.Text) (int64, error)

func (*Queries) CreateAPIToken

func (q *Queries) CreateAPIToken(ctx context.Context, arg CreateAPITokenParams) (APIToken, error)

func (*Queries) CreateAccessRequest

func (q *Queries) CreateAccessRequest(ctx context.Context, arg CreateAccessRequestParams) (AccessRequest, error)

func (*Queries) CreateCurrentObservation

func (q *Queries) CreateCurrentObservation(ctx context.Context, arg CreateCurrentObservationParams) (ObservationsCurrent, error)

func (*Queries) CreateGLabsLoad

func (q *Queries) CreateGLabsLoad(ctx context.Context, arg CreateGLabsLoadParams) (GlabsLoad, error)

func (*Queries) CreateMisolStation

func (q *Queries) CreateMisolStation(ctx context.Context, arg CreateMisolStationParams) (MisolStation, error)

func (*Queries) CreateRole

func (q *Queries) CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)

func (*Queries) CreateSimAccessToken

func (q *Queries) CreateSimAccessToken(ctx context.Context, arg CreateSimAccessTokenParams) (SimAccessToken, error)

func (*Queries) CreateSimCard

func (q *Queries) CreateSimCard(ctx context.Context, arg CreateSimCardParams) (SimCard, error)

func (*Queries) CreateStation

func (q *Queries) CreateStation(ctx context.Context, arg CreateStationParams) (ObservationsStation, error)

func (*Queries) CreateStationHealth

func (*Queries) CreateStationMOObservation

func (q *Queries) CreateStationMOObservation(ctx context.Context, arg CreateStationMOObservationParams) (ObservationsMoObservation, error)

func (*Queries) CreateStationObservation

func (q *Queries) CreateStationObservation(ctx context.Context, arg CreateStationObservationParams) (ObservationsObservation, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) CreateUserToken

func (q *Queries) CreateUserToken(ctx context.Context, arg CreateUserTokenParams) (UserToken, error)

func (*Queries) CreateWeatherlinkStation

func (q *Queries) CreateWeatherlinkStation(ctx context.Context, arg CreateWeatherlinkStationParams) (Weatherlink, error)

func (*Queries) DeleteAPIToken

func (q *Queries) DeleteAPIToken(ctx context.Context, id int64) error

func (*Queries) DeleteAccessRequest

func (q *Queries) DeleteAccessRequest(ctx context.Context, id int64) error

func (*Queries) DeleteMisolStation

func (q *Queries) DeleteMisolStation(ctx context.Context, id int64) error

func (*Queries) DeleteRole

func (q *Queries) DeleteRole(ctx context.Context, id int64) error

func (*Queries) DeleteSession

func (q *Queries) DeleteSession(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteSessionsByUserID

func (q *Queries) DeleteSessionsByUserID(ctx context.Context, userID int64) error

func (*Queries) DeleteSimAccessToken

func (q *Queries) DeleteSimAccessToken(ctx context.Context, accessToken string) error

func (*Queries) DeleteStation

func (q *Queries) DeleteStation(ctx context.Context, id int64) error

func (*Queries) DeleteStationHealth

func (q *Queries) DeleteStationHealth(ctx context.Context, arg DeleteStationHealthParams) error

func (*Queries) DeleteStationMOObservation

func (q *Queries) DeleteStationMOObservation(ctx context.Context, arg DeleteStationMOObservationParams) error

func (*Queries) DeleteStationObservation

func (q *Queries) DeleteStationObservation(ctx context.Context, arg DeleteStationObservationParams) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id int64) error

func (*Queries) DeleteUserAccess

func (q *Queries) DeleteUserAccess(ctx context.Context, userID int64) error

func (*Queries) GetAPIToken

func (q *Queries) GetAPIToken(ctx context.Context, id int64) (APIToken, error)

func (*Queries) GetAPITokenByHash

func (q *Queries) GetAPITokenByHash(ctx context.Context, tokenHash string) (APIToken, error)

func (*Queries) GetAccessRequest

func (q *Queries) GetAccessRequest(ctx context.Context, id int64) (AccessRequest, error)

func (*Queries) GetLatestStationObservation

func (q *Queries) GetLatestStationObservation(ctx context.Context, id int64) (GetLatestStationObservationRow, error)

func (*Queries) GetMisolStation

func (q *Queries) GetMisolStation(ctx context.Context, id int64) (MisolStation, error)

func (*Queries) GetRole

func (q *Queries) GetRole(ctx context.Context, id int64) (Role, error)

func (*Queries) GetRoleByName

func (q *Queries) GetRoleByName(ctx context.Context, name string) (Role, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error)

func (*Queries) GetSimAccessToken

func (q *Queries) GetSimAccessToken(ctx context.Context, accessToken string) (SimAccessToken, error)

func (*Queries) GetSimCard

func (q *Queries) GetSimCard(ctx context.Context, mobileNumber string) (SimCard, error)

func (*Queries) GetStation

func (q *Queries) GetStation(ctx context.Context, id int64) (ObservationsStation, error)

func (*Queries) GetStationByMobileNumber

func (q *Queries) GetStationByMobileNumber(ctx context.Context, mobileNumber pgtype.Text) (ObservationsStation, error)

func (*Queries) GetStationHealth

func (*Queries) GetStationMOObservation

func (q *Queries) GetStationMOObservation(ctx context.Context, arg GetStationMOObservationParams) (ObservationsMoObservation, error)

func (*Queries) GetStationObservation

func (q *Queries) GetStationObservation(ctx context.Context, arg GetStationObservationParams) (ObservationsObservation, error)

func (*Queries) GetStationStats

func (q *Queries) GetStationStats(ctx context.Context, windowSeconds float64) (GetStationStatsRow, error)

func (*Queries) GetStationStatsByIds

func (q *Queries) GetStationStatsByIds(ctx context.Context, arg GetStationStatsByIdsParams) (GetStationStatsByIdsRow, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int64) (User, error)

func (*Queries) GetUserAccess

func (q *Queries) GetUserAccess(ctx context.Context, userID int64) (UserAccess, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, lower string) (User, error)

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Queries) GetUserTokenByHash

func (q *Queries) GetUserTokenByHash(ctx context.Context, arg GetUserTokenByHashParams) (UserToken, error)

func (*Queries) InsertCurrentMOObservations

func (q *Queries) InsertCurrentMOObservations(ctx context.Context) ([]ObservationsCurrent, error)

func (*Queries) InsertCurrentObservations

func (q *Queries) InsertCurrentObservations(ctx context.Context) ([]ObservationsCurrent, error)

func (*Queries) InvalidateUserTokens

func (q *Queries) InvalidateUserTokens(ctx context.Context, arg InvalidateUserTokensParams) error

func (*Queries) ListAPITokensByUser

func (q *Queries) ListAPITokensByUser(ctx context.Context, userID int64) ([]APIToken, error)

func (*Queries) ListAccessRequests

func (q *Queries) ListAccessRequests(ctx context.Context, arg ListAccessRequestsParams) ([]AccessRequest, error)

func (*Queries) ListAccessRequestsByStatus

func (q *Queries) ListAccessRequestsByStatus(ctx context.Context, arg ListAccessRequestsByStatusParams) ([]AccessRequest, error)

func (*Queries) ListAccessRequestsByUser

func (q *Queries) ListAccessRequestsByUser(ctx context.Context, userID int64) ([]AccessRequest, error)

func (*Queries) ListLatestObservations

func (q *Queries) ListLatestObservations(ctx context.Context, windowSeconds float64) ([]ListLatestObservationsRow, error)

func (*Queries) ListLufftStationMsg

func (q *Queries) ListLufftStationMsg(ctx context.Context, arg ListLufftStationMsgParams) ([]ListLufftStationMsgRow, error)

func (*Queries) ListMOObservations

func (q *Queries) ListMOObservations(ctx context.Context, arg ListMOObservationsParams) ([]ObservationsMoObservation, error)

func (*Queries) ListObservations

func (q *Queries) ListObservations(ctx context.Context, arg ListObservationsParams) ([]ObservationsObservation, error)

func (*Queries) ListRoles

func (q *Queries) ListRoles(ctx context.Context, arg ListRolesParams) ([]Role, error)

func (*Queries) ListStationHealths

func (q *Queries) ListStationHealths(ctx context.Context, arg ListStationHealthsParams) ([]ObservationsStationhealth, error)

func (*Queries) ListStationMOObservations

func (q *Queries) ListStationMOObservations(ctx context.Context, arg ListStationMOObservationsParams) ([]ObservationsMoObservation, error)

func (*Queries) ListStationObservations

func (q *Queries) ListStationObservations(ctx context.Context, arg ListStationObservationsParams) ([]ObservationsObservation, error)

func (*Queries) ListStations

func (q *Queries) ListStations(ctx context.Context, arg ListStationsParams) ([]ObservationsStation, error)

func (*Queries) ListStationsByIds

func (q *Queries) ListStationsByIds(ctx context.Context, arg ListStationsByIdsParams) ([]ObservationsStation, error)

func (*Queries) ListStationsWithinBBox

func (q *Queries) ListStationsWithinBBox(ctx context.Context, arg ListStationsWithinBBoxParams) ([]ObservationsStation, error)

func (*Queries) ListStationsWithinRadius

func (q *Queries) ListStationsWithinRadius(ctx context.Context, arg ListStationsWithinRadiusParams) ([]ObservationsStation, error)

func (*Queries) ListUserRoles

func (q *Queries) ListUserRoles(ctx context.Context, userID int64) ([]string, error)

func (*Queries) ListUserRolesByUserIDs

func (q *Queries) ListUserRolesByUserIDs(ctx context.Context, userIds []int64) ([]ListUserRolesByUserIDsRow, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) ListWeatherlinkStations

func (q *Queries) ListWeatherlinkStations(ctx context.Context, arg ListWeatherlinkStationsParams) ([]Weatherlink, error)

func (*Queries) MarkStaleStationsOffline

func (q *Queries) MarkStaleStationsOffline(ctx context.Context, staleAfterSeconds float64) (int64, error)

func (*Queries) ReviewUser

func (q *Queries) ReviewUser(ctx context.Context, arg ReviewUserParams) (User, error)

func (*Queries) SetStationStatus

func (q *Queries) SetStationStatus(ctx context.Context, arg SetStationStatusParams) (int64, error)

func (*Queries) UpdateAPITokenLastUsedAt

func (q *Queries) UpdateAPITokenLastUsedAt(ctx context.Context, id int64) error

func (*Queries) UpdateAccessRequestStatus

func (q *Queries) UpdateAccessRequestStatus(ctx context.Context, arg UpdateAccessRequestStatusParams) (AccessRequest, error)

func (*Queries) UpdateRole

func (q *Queries) UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)

func (*Queries) UpdateStation

func (q *Queries) UpdateStation(ctx context.Context, arg UpdateStationParams) (ObservationsStation, error)

func (*Queries) UpdateStationHealth

func (*Queries) UpdateStationMOObservation

func (q *Queries) UpdateStationMOObservation(ctx context.Context, arg UpdateStationMOObservationParams) (ObservationsMoObservation, error)

func (*Queries) UpdateStationObservation

func (q *Queries) UpdateStationObservation(ctx context.Context, arg UpdateStationObservationParams) (ObservationsObservation, error)

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) UpsertUserAccess

func (q *Queries) UpsertUserAccess(ctx context.Context, arg UpsertUserAccessParams) (UserAccess, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ResetPasswordTxParams

type ResetPasswordTxParams struct {
	TokenHash string
	Password  string
}

type ReviewUserParams

type ReviewUserParams struct {
	Status     string      `json:"status"`
	ReviewedBy pgtype.Int8 `json:"reviewed_by"`
	ReviewNote pgtype.Text `json:"review_note"`
	ID         int64       `json:"id"`
}

type Role

type Role struct {
	ID          int64              `json:"id"`
	Name        string             `json:"name"`
	Description pgtype.Text        `json:"description"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
}

type RoleUser

type RoleUser struct {
	RoleID    int64              `json:"role_id"`
	UserID    int64              `json:"user_id"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

SQLStore provides all functions to execute SQL queries and transactions

func (*SQLStore) BulkCreateUserRoles

func (s *SQLStore) BulkCreateUserRoles(ctx context.Context, arg []UserRolesParams) (ret []UserRolesParams, errs []error)

func (*SQLStore) BulkDeleteUserRoles

func (s *SQLStore) BulkDeleteUserRoles(ctx context.Context, arg []UserRolesParams) []error

func (*SQLStore) CompleteRegistrationTx

func (store *SQLStore) CompleteRegistrationTx(ctx context.Context, arg CompleteRegistrationTxParams) (User, error)

CompleteRegistrationTx consumes a registration token and activates the invited user in one transaction. If the user was already activated (or the email conflicts), the whole transaction rolls back and the token stays usable.

func (*SQLStore) CreateMisolStationTx

func (store *SQLStore) CreateMisolStationTx(ctx context.Context, arg CreateMisolStationTxParams) (CreateMisolStationTxResult, error)

func (*SQLStore) CreatePasswordResetTokenTx

func (store *SQLStore) CreatePasswordResetTokenTx(ctx context.Context, arg CreatePasswordResetTokenTxParams) (UserToken, error)

CreatePasswordResetTokenTx invalidates any unused reset tokens for the user and creates a new one atomically.

func (*SQLStore) CreateRegistrationTokenTx

func (store *SQLStore) CreateRegistrationTokenTx(ctx context.Context, arg CreateRegistrationTokenTxParams) (UserToken, error)

CreateRegistrationTokenTx invalidates any unused registration tokens for the user and creates a new one atomically.

func (*SQLStore) Ping

func (store *SQLStore) Ping(ctx context.Context) error

Ping verifies that the database connection is usable.

func (*SQLStore) ResetPasswordTx

func (store *SQLStore) ResetPasswordTx(ctx context.Context, arg ResetPasswordTxParams) (User, error)

ResetPasswordTx consumes a reset token, changes the password and revokes all existing sessions atomically.

type Session

type Session struct {
	ID           uuid.UUID          `json:"id"`
	UserID       int64              `json:"user_id"`
	RefreshToken string             `json:"refresh_token"`
	UserAgent    string             `json:"user_agent"`
	ClientIp     string             `json:"client_ip"`
	IsBlocked    bool               `json:"is_blocked"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
}

type SetStationStatusParams

type SetStationStatusParams struct {
	Status pgtype.Text `json:"status"`
	ID     int64       `json:"id"`
}

type SimAccessToken

type SimAccessToken struct {
	AccessToken  string             `json:"access_token"`
	Type         string             `json:"type"`
	MobileNumber string             `json:"mobile_number"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

type SimCard

type SimCard struct {
	MobileNumber string             `json:"mobile_number"`
	Type         pgtype.Text        `json:"type"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

type Store

type Store interface {
	Querier
	Ping(ctx context.Context) error
	BulkCreateUserRoles(ctx context.Context, arg []UserRolesParams) (ret []UserRolesParams, errs []error)
	BulkDeleteUserRoles(ctx context.Context, arg []UserRolesParams) []error
	CreateMisolStationTx(ctx context.Context, arg CreateMisolStationTxParams) (CreateMisolStationTxResult, error)
	FirstOrCreateSimAccessTokenTx(ctx context.Context, arg FirstOrCreateSimAccessTokenTxParams) (FirstOrCreateSimAccessTokenTxResult, error)
	CreateRegistrationTokenTx(ctx context.Context, arg CreateRegistrationTokenTxParams) (UserToken, error)
	CompleteRegistrationTx(ctx context.Context, arg CompleteRegistrationTxParams) (User, error)
	CreatePasswordResetTokenTx(ctx context.Context, arg CreatePasswordResetTokenTxParams) (UserToken, error)
	ResetPasswordTx(ctx context.Context, arg ResetPasswordTxParams) (User, error)
}

Store provides all functions to execute db queries and transaction

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

NewStore creates a new store

type UpdateAccessRequestStatusParams

type UpdateAccessRequestStatusParams struct {
	ID         int64       `json:"id"`
	Status     string      `json:"status"`
	ReviewedBy pgtype.Int8 `json:"reviewed_by"`
	ReviewNote pgtype.Text `json:"review_note"`
}

type UpdateRoleParams

type UpdateRoleParams struct {
	Name        pgtype.Text `json:"name"`
	Description pgtype.Text `json:"description"`
	ID          int64       `json:"id"`
}

type UpdateStationHealthParams

type UpdateStationHealthParams struct {
	Vb1               pgtype.Float4      `json:"vb1"`
	Vb2               pgtype.Float4      `json:"vb2"`
	Curr              pgtype.Float4      `json:"curr"`
	Bp1               pgtype.Float4      `json:"bp1"`
	Bp2               pgtype.Float4      `json:"bp2"`
	Cm                pgtype.Text        `json:"cm"`
	Ss                pgtype.Int4        `json:"ss"`
	TempArq           pgtype.Float4      `json:"temp_arq"`
	RhArq             pgtype.Float4      `json:"rh_arq"`
	Fpm               pgtype.Text        `json:"fpm"`
	ErrorMsg          pgtype.Text        `json:"error_msg"`
	Message           pgtype.Text        `json:"message"`
	DataCount         pgtype.Int4        `json:"data_count"`
	DataStatus        pgtype.Text        `json:"data_status"`
	Timestamp         pgtype.Timestamptz `json:"timestamp"`
	MinutesDifference pgtype.Int4        `json:"minutes_difference"`
	StationID         int64              `json:"station_id"`
	ID                int64              `json:"id"`
}

type UpdateStationMOObservationParams

type UpdateStationMOObservationParams struct {
	Pres      pgtype.Float4      `json:"pres"`
	Rr        pgtype.Float4      `json:"rr"`
	Rh        pgtype.Float4      `json:"rh"`
	Temp      pgtype.Float4      `json:"temp"`
	Td        pgtype.Float4      `json:"td"`
	Wdir      pgtype.Float4      `json:"wdir"`
	Wspd      pgtype.Float4      `json:"wspd"`
	Wspdx     pgtype.Float4      `json:"wspdx"`
	Srad      pgtype.Float4      `json:"srad"`
	Hi        pgtype.Float4      `json:"hi"`
	Wchill    pgtype.Float4      `json:"wchill"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	QcLevel   pgtype.Int4        `json:"qc_level"`
	StationID int64              `json:"station_id"`
	ID        int64              `json:"id"`
}

type UpdateStationObservationParams

type UpdateStationObservationParams struct {
	Pres               pgtype.Float4      `json:"pres"`
	Rr                 pgtype.Float4      `json:"rr"`
	RainTips           pgtype.Int4        `json:"rain_tips"`
	RainCumulativeTips pgtype.Int4        `json:"rain_cumulative_tips"`
	Rh                 pgtype.Float4      `json:"rh"`
	Temp               pgtype.Float4      `json:"temp"`
	Td                 pgtype.Float4      `json:"td"`
	Wdir               pgtype.Float4      `json:"wdir"`
	Wspd               pgtype.Float4      `json:"wspd"`
	Wspdx              pgtype.Float4      `json:"wspdx"`
	Srad               pgtype.Float4      `json:"srad"`
	Mslp               pgtype.Float4      `json:"mslp"`
	Hi                 pgtype.Float4      `json:"hi"`
	Wchill             pgtype.Float4      `json:"wchill"`
	Timestamp          pgtype.Timestamptz `json:"timestamp"`
	QcLevel            pgtype.Int4        `json:"qc_level"`
	StationID          int64              `json:"station_id"`
	ID                 int64              `json:"id"`
}

type UpdateStationParams

type UpdateStationParams struct {
	Name          pgtype.Text   `json:"name"`
	Lat           pgtype.Float4 `json:"lat"`
	Lon           pgtype.Float4 `json:"lon"`
	Elevation     pgtype.Float4 `json:"elevation"`
	DateInstalled pgtype.Date   `json:"date_installed"`
	MoStationID   pgtype.Text   `json:"mo_station_id"`
	SmsSystemType pgtype.Text   `json:"sms_system_type"`
	MobileNumber  pgtype.Text   `json:"mobile_number"`
	StationType   pgtype.Text   `json:"station_type"`
	StationType2  pgtype.Text   `json:"station_type2"`
	StationUrl    pgtype.Text   `json:"station_url"`
	Status        pgtype.Text   `json:"status"`
	LoggerVersion pgtype.Text   `json:"logger_version"`
	PriorityLevel pgtype.Text   `json:"priority_level"`
	ProviderID    pgtype.Text   `json:"provider_id"`
	Province      pgtype.Text   `json:"province"`
	Region        pgtype.Text   `json:"region"`
	Address       pgtype.Text   `json:"address"`
	ID            int64         `json:"id"`
}

type UpdateUserParams

type UpdateUserParams struct {
	Username          pgtype.Text        `json:"username"`
	Password          pgtype.Text        `json:"password"`
	PasswordChangedAt pgtype.Timestamptz `json:"password_changed_at"`
	FullName          pgtype.Text        `json:"full_name"`
	SetEmail          bool               `json:"set_email"`
	Email             pgtype.Text        `json:"email"`
	ID                int64              `json:"id"`
}

type UpsertUserAccessParams

type UpsertUserAccessParams struct {
	UserID         int64  `json:"user_id"`
	StationIds     []byte `json:"station_ids"`
	Variables      []byte `json:"variables"`
	MaxDaysHistory int32  `json:"max_days_history"`
}

type User

type User struct {
	ID                int64              `json:"id"`
	Username          string             `json:"username"`
	FullName          string             `json:"full_name"`
	Email             pgtype.Text        `json:"email"`
	Password          string             `json:"password"`
	EmailVerifiedAt   pgtype.Timestamptz `json:"email_verified_at"`
	PasswordChangedAt pgtype.Timestamptz `json:"password_changed_at"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
	Status            string             `json:"status"`
	ReviewedBy        pgtype.Int8        `json:"reviewed_by"`
	ReviewedAt        pgtype.Timestamptz `json:"reviewed_at"`
	ReviewNote        pgtype.Text        `json:"review_note"`
}

type UserAccess

type UserAccess struct {
	UserID         int64              `json:"user_id"`
	StationIds     []byte             `json:"station_ids"`
	Variables      []byte             `json:"variables"`
	MaxDaysHistory int32              `json:"max_days_history"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	UpdatedAt      pgtype.Timestamptz `json:"updated_at"`
}

type UserRolesParams

type UserRolesParams struct {
	Username string `json:"username"`
	RoleName string `json:"role_name"`
}

type UserToken

type UserToken struct {
	ID        int64              `json:"id"`
	UserID    int64              `json:"user_id"`
	Purpose   string             `json:"purpose"`
	TokenHash string             `json:"token_hash"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	UsedAt    pgtype.Timestamptz `json:"used_at"`
	CreatedBy pgtype.Int8        `json:"created_by"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type Weatherlink struct {
	ID        int64              `json:"id"`
	StationID int64              `json:"station_id"`
	Uuid      pgtype.Text        `json:"uuid"`
	APIKey    pgtype.Text        `json:"api_key"`
	APISecret pgtype.Text        `json:"api_secret"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}

Jump to

Keyboard shortcuts

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