Files
beacon-server/db/sqlc/models.go
T
MrAlders0n 98006a9364 feat(stats): serve historical stats from hourly rollups
Stats endpoints read hourly rollup tables filled once per closed hour by one
advisory-locked task, instead of materialized views that re-scanned every
observation on each refresh. IATA-set tables give exact distinct counts for any
IATA set or region. Cleanup holds raw rows for unrolled hours (up to 24h).

Adds /stats/series; ingest keeps packet observation counts, observer last IATA,
channel message counts and trace tag summaries. 001_baseline.sql is rewritten,
so pre-release 2.0 databases must be recreated. See docs/historical-stats.md.
2026-10-02 07:43:56 -04:00

494 lines
20 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package db
import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
)
type Account struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
DeactivatedAt pgtype.Timestamptz `json:"deactivated_at"`
}
type AnalyticsDirtyHour struct {
Hour pgtype.Timestamptz `json:"hour"`
EnqueuedAt pgtype.Timestamptz `json:"enqueued_at"`
}
type AnalyticsHourlyAdvertHearing struct {
Hour pgtype.Timestamptz `json:"hour"`
Iata string `json:"iata"`
OriginPubkey []byte `json:"origin_pubkey"`
Observations int64 `json:"observations"`
LastHeard pgtype.Timestamptz `json:"last_heard"`
Name *string `json:"name"`
NodeType *int16 `json:"node_type"`
}
type AnalyticsHourlyAdvertSet struct {
Hour pgtype.Timestamptz `json:"hour"`
OriginPubkey []byte `json:"origin_pubkey"`
Iatas []string `json:"iatas"`
AdvertPackets int64 `json:"advert_packets"`
FloodPackets int64 `json:"flood_packets"`
DirectPackets int64 `json:"direct_packets"`
}
type AnalyticsHourlyIataObservation struct {
Hour pgtype.Timestamptz `json:"hour"`
Iata string `json:"iata"`
ObservationCount int64 `json:"observation_count"`
}
type AnalyticsHourlyObserverActivity struct {
Hour pgtype.Timestamptz `json:"hour"`
ObserverID uuid.UUID `json:"observer_id"`
PayloadType int16 `json:"payload_type"`
Observations int64 `json:"observations"`
AirtimeMs *float32 `json:"airtime_ms"`
AirtimeN int64 `json:"airtime_n"`
SnrSum *float32 `json:"snr_sum"`
SnrN int64 `json:"snr_n"`
SnrMin *float32 `json:"snr_min"`
RssiSum *int64 `json:"rssi_sum"`
RssiN int64 `json:"rssi_n"`
}
type AnalyticsHourlyObserverIdentity struct {
Hour pgtype.Timestamptz `json:"hour"`
Iata string `json:"iata"`
ObserverID uuid.UUID `json:"observer_id"`
ObservationCount int64 `json:"observation_count"`
DisplayName *string `json:"display_name"`
ObserverType *string `json:"observer_type"`
}
type AnalyticsHourlyPacketSet struct {
Hour pgtype.Timestamptz `json:"hour"`
Iatas []string `json:"iatas"`
Packets int64 `json:"packets"`
}
type AnalyticsHourlyPath struct {
Hour pgtype.Timestamptz `json:"hour"`
Iata string `json:"iata"`
Category int32 `json:"category"`
HashBytes int32 `json:"hash_bytes"`
Entries int32 `json:"entries"`
Receptions int64 `json:"receptions"`
}
type AnalyticsHourlyPayloadBreakdown struct {
Hour pgtype.Timestamptz `json:"hour"`
Iata string `json:"iata"`
PayloadType int16 `json:"payload_type"`
Count int64 `json:"count"`
}
type AnalyticsHourlyScopeSet struct {
Hour pgtype.Timestamptz `json:"hour"`
Iatas []string `json:"iatas"`
ScopeID int32 `json:"scope_id"`
Packets int64 `json:"packets"`
}
type AnalyticsHourlySignal struct {
Hour pgtype.Timestamptz `json:"hour"`
Iata string `json:"iata"`
Kind int32 `json:"kind"`
SnrBin int32 `json:"snr_bin"`
RssiBin int32 `json:"rssi_bin"`
Receptions int64 `json:"receptions"`
SnrSamples int64 `json:"snr_samples"`
SnrSum float64 `json:"snr_sum"`
RssiSamples int64 `json:"rssi_samples"`
RssiSum float64 `json:"rssi_sum"`
}
type AnalyticsHourlyTalkerSet struct {
Hour pgtype.Timestamptz `json:"hour"`
SenderName string `json:"sender_name"`
Iatas []string `json:"iatas"`
Messages int64 `json:"messages"`
LastSent pgtype.Timestamptz `json:"last_sent"`
}
type AnalyticsRawState struct {
Singleton bool `json:"singleton"`
RawDeletedBefore pgtype.Timestamptz `json:"raw_deleted_before"`
Coverage int64 `json:"coverage"`
}
type AnalyticsRollupHour struct {
Hour pgtype.Timestamptz `json:"hour"`
Status string `json:"status"`
RolledAt pgtype.Timestamptz `json:"rolled_at"`
ContentHash *string `json:"content_hash"`
}
type AnalyticsState struct {
Singleton bool `json:"singleton"`
Revision int64 `json:"revision"`
}
type Channel struct {
ID int32 `json:"id"`
ChannelHash []byte `json:"channel_hash"`
KeyFingerprint []byte `json:"key_fingerprint"`
Name *string `json:"name"`
Hashtag *string `json:"hashtag"`
IsHashtag *bool `json:"is_hashtag"`
IsPublic *bool `json:"is_public"`
KeyKnown *bool `json:"key_known"`
FirstSeen pgtype.Timestamptz `json:"first_seen"`
LastSeen pgtype.Timestamptz `json:"last_seen"`
MessageCount int64 `json:"message_count"`
}
type ChannelConfigScope struct {
KeyFingerprint []byte `json:"key_fingerprint"`
RegionSlug *string `json:"region_slug"`
}
type ChannelIata struct {
ChannelHash []byte `json:"channel_hash"`
Iata string `json:"iata"`
LastHeard pgtype.Timestamptz `json:"last_heard"`
}
type ChannelKey struct {
ChannelID int32 `json:"channel_id"`
KeyBytes []byte `json:"key_bytes"`
KeyFingerprint []byte `json:"key_fingerprint"`
AddedAt pgtype.Timestamptz `json:"added_at"`
AddedBy *string `json:"added_by"`
}
type ChannelMessage struct {
ID int64 `json:"id"`
ChannelID int32 `json:"channel_id"`
PacketHash []byte `json:"packet_hash"`
SenderName *string `json:"sender_name"`
SenderPubkey []byte `json:"sender_pubkey"`
Content *string `json:"content"`
SentAt pgtype.Timestamptz `json:"sent_at"`
}
type IataCode struct {
Iata string `json:"iata"`
DisplayName *string `json:"display_name"`
ApproxLat *float64 `json:"approx_lat"`
ApproxLng *float64 `json:"approx_lng"`
AddedAt pgtype.Timestamptz `json:"added_at"`
Border []byte `json:"border"`
}
type KnownRoute struct {
ID int64 `json:"id"`
PathKey []byte `json:"path_key"`
NodeIds []uuid.UUID `json:"node_ids"`
HashPrefix [][]byte `json:"hash_prefix"`
Iata string `json:"iata"`
HopCount int32 `json:"hop_count"`
FirstSeen pgtype.Timestamptz `json:"first_seen"`
LastSeen pgtype.Timestamptz `json:"last_seen"`
ObservationCount int64 `json:"observation_count"`
LastReconfirmedAt pgtype.Timestamptz `json:"last_reconfirmed_at"`
}
type MeshmapperChannelCatalogue struct {
Iata string `json:"iata"`
Url string `json:"url"`
Payload []byte `json:"payload"`
Etag *string `json:"etag"`
CheckedAt pgtype.Timestamptz `json:"checked_at"`
AttemptedAt pgtype.Timestamptz `json:"attempted_at"`
NextAttempt pgtype.Timestamptz `json:"next_attempt"`
LastError string `json:"last_error"`
}
type MeshmapperChannelMember struct {
Iata string `json:"iata"`
KeyFingerprint []byte `json:"key_fingerprint"`
}
type MeshmapperScopeCatalogue struct {
Iata string `json:"iata"`
Url string `json:"url"`
Payload []byte `json:"payload"`
Etag *string `json:"etag"`
CheckedAt pgtype.Timestamptz `json:"checked_at"`
AttemptedAt pgtype.Timestamptz `json:"attempted_at"`
NextAttempt pgtype.Timestamptz `json:"next_attempt"`
LastError string `json:"last_error"`
}
type MeshmapperZoneBoundary struct {
Iata string `json:"iata"`
Url string `json:"url"`
Feature []byte `json:"feature"`
Etag *string `json:"etag"`
CheckedAt pgtype.Timestamptz `json:"checked_at"`
AttemptedAt pgtype.Timestamptz `json:"attempted_at"`
NextAttempt pgtype.Timestamptz `json:"next_attempt"`
LastError string `json:"last_error"`
}
type MeshmapperZoneList struct {
Country string `json:"country"`
Payload []byte `json:"payload"`
Etag *string `json:"etag"`
FetchedAt pgtype.Timestamptz `json:"fetched_at"`
AttemptedAt pgtype.Timestamptz `json:"attempted_at"`
NextAttempt pgtype.Timestamptz `json:"next_attempt"`
LastError string `json:"last_error"`
}
type MvRadioPreset struct {
Preset string `json:"preset"`
Iata *string `json:"iata"`
SourceType string `json:"source_type"`
Count int64 `json:"count"`
}
type Node struct {
ID uuid.UUID `json:"id"`
PublicKey []byte `json:"public_key"`
NodeType int16 `json:"node_type"`
Name *string `json:"name"`
Latitude *float64 `json:"latitude"`
Longitude *float64 `json:"longitude"`
LocationSource *string `json:"location_source"`
LastAdvertAt pgtype.Timestamptz `json:"last_advert_at"`
SupportsMultibytePaths bool `json:"supports_multibyte_paths"`
SupportsMultibyteTraces bool `json:"supports_multibyte_traces"`
DefaultScopeID *int32 `json:"default_scope_id"`
MinFirmwareVersion *string `json:"min_firmware_version"`
FirstSeen pgtype.Timestamptz `json:"first_seen"`
LastSeen pgtype.Timestamptz `json:"last_seen"`
RadioFreqMhz *float32 `json:"radio_freq_mhz"`
RadioSf *int16 `json:"radio_sf"`
RadioBwKhz *float32 `json:"radio_bw_khz"`
Metadata []byte `json:"metadata"`
DeviceClockDriftSeconds *int32 `json:"device_clock_drift_seconds"`
}
type NodeIata struct {
NodeID uuid.UUID `json:"node_id"`
Iata string `json:"iata"`
FirstHeard pgtype.Timestamptz `json:"first_heard"`
LastHeard pgtype.Timestamptz `json:"last_heard"`
ObservationCount *int64 `json:"observation_count"`
}
type NodeNeighbor struct {
NodeID uuid.UUID `json:"node_id"`
NeighborID uuid.UUID `json:"neighbor_id"`
Iata string `json:"iata"`
FirstSeen pgtype.Timestamptz `json:"first_seen"`
LastSeen pgtype.Timestamptz `json:"last_seen"`
ObservationCount int64 `json:"observation_count"`
Snr *float32 `json:"snr"`
RegionScope *string `json:"region_scope"`
}
type NodeShortID struct {
NodeID uuid.UUID `json:"node_id"`
Iata string `json:"iata"`
Prefix4 []byte `json:"prefix_4"`
Prefix1 []byte `json:"prefix_1"`
Prefix2 []byte `json:"prefix_2"`
Prefix3 []byte `json:"prefix_3"`
}
type Observer struct {
ID uuid.UUID `json:"id"`
PublicKey []byte `json:"public_key"`
DisplayName *string `json:"display_name"`
ObserverType *string `json:"observer_type"`
SoftwareVersion *string `json:"software_version"`
HardwareModel *string `json:"hardware_model"`
FirmwareVersion *string `json:"firmware_version"`
FirmwareBuild *string `json:"firmware_build"`
RadioFreqMhz *float32 `json:"radio_freq_mhz"`
RadioSf *int16 `json:"radio_sf"`
RadioBwKhz *float32 `json:"radio_bw_khz"`
RadioCr *int16 `json:"radio_cr"`
BatteryLevel *float32 `json:"battery_level"`
UptimeSeconds *int64 `json:"uptime_seconds"`
StatusMetadata []byte `json:"status_metadata"`
LastStatusAt pgtype.Timestamptz `json:"last_status_at"`
FirstSeen pgtype.Timestamptz `json:"first_seen"`
LastSeen pgtype.Timestamptz `json:"last_seen"`
ObservationCount *int64 `json:"observation_count"`
Metadata []byte `json:"metadata"`
RegionScope *string `json:"region_scope"`
LastIata *string `json:"last_iata"`
LastIataAt pgtype.Timestamptz `json:"last_iata_at"`
}
type ObserverBroker struct {
ObserverID uuid.UUID `json:"observer_id"`
BrokerName string `json:"broker_name"`
FirstSeen pgtype.Timestamptz `json:"first_seen"`
LastSeen pgtype.Timestamptz `json:"last_seen"`
LastPacketAt pgtype.Timestamptz `json:"last_packet_at"`
AuthOk *bool `json:"auth_ok"`
}
type ObserverLocation struct {
ObserverID uuid.UUID `json:"observer_id"`
Iata *string `json:"iata"`
Latitude *float64 `json:"latitude"`
Longitude *float64 `json:"longitude"`
ReportedAt pgtype.Timestamptz `json:"reported_at"`
}
type ObserverOwner struct {
ObserverID uuid.UUID `json:"observer_id"`
OwnerNodeID pgtype.UUID `json:"owner_node_id"`
OwnerPubkey []byte `json:"owner_pubkey"`
ContactName *string `json:"contact_name"`
ContactEmail *string `json:"contact_email"`
Notes *string `json:"notes"`
Source *string `json:"source"`
AddedAt pgtype.Timestamptz `json:"added_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type ObserverScope struct {
ObserverID uuid.UUID `json:"observer_id"`
ScopeID int32 `json:"scope_id"`
FirstSeen pgtype.Timestamptz `json:"first_seen"`
LastSeen pgtype.Timestamptz `json:"last_seen"`
}
type ObserverTelemetry struct {
ID int64 `json:"id"`
ObserverID uuid.UUID `json:"observer_id"`
ReportedAt pgtype.Timestamptz `json:"reported_at"`
BatteryVoltageMv *int32 `json:"battery_voltage_mv"`
AirtimeTxSecs *float32 `json:"airtime_tx_secs"`
AirtimeRxSecs *float32 `json:"airtime_rx_secs"`
NoiseFloorDb *float32 `json:"noise_floor_db"`
UptimeSeconds *int64 `json:"uptime_seconds"`
QueueLength *int32 `json:"queue_length"`
DebugFlags *int32 `json:"debug_flags"`
ReceiveErrors *int32 `json:"receive_errors"`
}
type Packet struct {
PacketHash []byte `json:"packet_hash"`
PayloadType int16 `json:"payload_type"`
PayloadVersion int16 `json:"payload_version"`
RouteType int16 `json:"route_type"`
TransportCodesPresent *bool `json:"transport_codes_present"`
RegionCode *int32 `json:"region_code"`
SubRegionCode *int32 `json:"sub_region_code"`
ScopeID *int32 `json:"scope_id"`
OriginPubkey []byte `json:"origin_pubkey"`
RawPayload []byte `json:"raw_payload"`
RawHeader []byte `json:"raw_header"`
ParsedPayload []byte `json:"parsed_payload"`
Decrypted *bool `json:"decrypted"`
ChannelHash []byte `json:"channel_hash"`
TraceTag []byte `json:"trace_tag"`
FirstHeardAt pgtype.Timestamptz `json:"first_heard_at"`
LastHeardAt pgtype.Timestamptz `json:"last_heard_at"`
ObservationCount int64 `json:"observation_count"`
}
type PacketObservation struct {
ID int64 `json:"id"`
PacketHash []byte `json:"packet_hash"`
ObserverID uuid.UUID `json:"observer_id"`
Iata string `json:"iata"`
HeardAt pgtype.Timestamptz `json:"heard_at"`
PathLengthByte int16 `json:"path_length_byte"`
HashSize int16 `json:"hash_size"`
HopCount int16 `json:"hop_count"`
PathBytes []byte `json:"path_bytes"`
Rssi *int16 `json:"rssi"`
Snr *float32 `json:"snr"`
PropagationTimeMs *int32 `json:"propagation_time_ms"`
RadioFreqMhz *float32 `json:"radio_freq_mhz"`
SpreadFactor *int16 `json:"spread_factor"`
BandwidthKhz *float32 `json:"bandwidth_khz"`
CodingRate *int16 `json:"coding_rate"`
SourceBroker *string `json:"source_broker"`
PayloadType *int16 `json:"payload_type"`
AirtimeMs *float32 `json:"airtime_ms"`
}
type Region struct {
ID int32 `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Description *string `json:"description"`
DisplayOrder *int32 `json:"display_order"`
CenterLat *float64 `json:"center_lat"`
CenterLng *float64 `json:"center_lng"`
ZoomLevel *int32 `json:"zoom_level"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
Imported bool `json:"imported"`
}
type RegionIata struct {
RegionID int32 `json:"region_id"`
Iata string `json:"iata"`
AddedAt pgtype.Timestamptz `json:"added_at"`
}
type RollupOb struct {
PacketHash []byte `json:"packet_hash"`
ObserverID uuid.UUID `json:"observer_id"`
Iata string `json:"iata"`
HeardAt pgtype.Timestamptz `json:"heard_at"`
PathLengthByte int16 `json:"path_length_byte"`
HashSize int16 `json:"hash_size"`
HopCount int16 `json:"hop_count"`
PathLen int32 `json:"path_len"`
Rssi *int16 `json:"rssi"`
Snr *float32 `json:"snr"`
AirtimeMs *float32 `json:"airtime_ms"`
PayloadType *int16 `json:"payload_type"`
RouteType int16 `json:"route_type"`
OriginPubkey []byte `json:"origin_pubkey"`
ScopeID *int32 `json:"scope_id"`
}
type TraceIata struct {
TraceTag []byte `json:"trace_tag"`
Iata string `json:"iata"`
LastHeard pgtype.Timestamptz `json:"last_heard"`
}
type TraceTag struct {
TraceTag []byte `json:"trace_tag"`
FirstHeardAt pgtype.Timestamptz `json:"first_heard_at"`
LastHeardAt pgtype.Timestamptz `json:"last_heard_at"`
PacketCount int64 `json:"packet_count"`
TraceType *string `json:"trace_type"`
ScopeID *int32 `json:"scope_id"`
BestPayload []byte `json:"best_payload"`
BestPathLen int32 `json:"best_path_len"`
Heard bool `json:"heard"`
}
type TransportScope struct {
ID int32 `json:"id"`
Name string `json:"name"`
DisplayName *string `json:"display_name"`
TransportKey []byte `json:"transport_key"`
KeyFingerprint []byte `json:"key_fingerprint"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
ImportedOnly bool `json:"imported_only"`
}