postgres

package
v0.0.0-...-28185e2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

README

PostgreSQL Storage Layer

This directory contains the PostgreSQL storage implementation using SQLc for type-safe SQL queries.

Directory Structure

internal/storage/postgres/
├── queries/          # SQLc query definitions (*.sql)
├── migrations/       # Database migrations (golang-migrate)
├── *.sql.go         # SQLc-generated Go code (DO NOT EDIT)
├── models.go        # SQLc-generated model types
└── README.md        # This file

Writing SQLc Queries

⚠️ CRITICAL: Nullable Parameters

Problem: SQLc cannot automatically infer nullable parameters from standard $N placeholders. Using $1::type IS NULL checks with numbered parameters generates non-nullable Go types (e.g., bool, string), causing runtime bugs when optional filters aren't provided.

Example Bug:

-- WRONG: Generates 'Column1 bool' parameter (not nullable)
SELECT * FROM users
WHERE ($1::boolean IS NULL OR is_active = $1);

When the Go code doesn't set params.Column1, it defaults to false (not NULL), breaking the SQL logic.

Correct Pattern:

-- CORRECT: Generates 'IsActive pgtype.Bool' parameter (nullable)
SELECT * FROM users
WHERE (sqlc.narg('is_active')::boolean IS NULL OR is_active = sqlc.narg('is_active'));
SQLc Parameter Functions
  • sqlc.arg('name') - Required parameter (generates non-nullable Go type)
  • sqlc.narg('name') - Nullable parameter (generates pgtype.Type with Valid flag)
Go Code Usage
// Service layer
func (s *Service) ListUsers(filters Filters) ([]User, error) {
    params := postgres.ListUsersParams{}
    
    // Only set nullable parameter when filter is provided
    if filters.IsActive != nil {
        params.IsActive = pgtype.Bool{
            Bool:  *filters.IsActive,
            Valid: true,  // Marks value as non-NULL
        }
    }
    // If not set, Valid=false and SQL receives NULL
    
    return s.queries.ListUsers(ctx, params)
}
Common Nullable Types
SQL Type pgtype Type
boolean pgtype.Bool
text / varchar pgtype.Text
integer / bigint pgtype.Int4 / pgtype.Int8
timestamp pgtype.Timestamptz
uuid pgtype.UUID
Warning Signs

If you see these in generated code, you likely have a nullable parameter bug:

  • Parameter names like Column1, Column2 (instead of descriptive names)
  • Non-pointer scalar types (bool, string, int) for optional filters
  • SQL with IS NULL checks but Go struct has non-nullable fields
Real-World Example

Bug: Users list page returning empty results despite users existing in database.

Before (Broken):

-- queries/auth.sql
-- name: ListUsersWithFilters :many
SELECT * FROM users
WHERE ($1::boolean IS NULL OR is_active = $1)
  AND ($2::text IS NULL OR role = $2);

Generated:

type ListUsersWithFiltersParams struct {
    Column1 bool   // ❌ Not nullable, defaults to false
    Column2 string // ❌ Not nullable, defaults to ""
}

After (Fixed):

-- queries/auth.sql
-- name: ListUsersWithFilters :many
SELECT * FROM users
WHERE (sqlc.narg('is_active')::boolean IS NULL OR is_active = sqlc.narg('is_active'))
  AND (sqlc.narg('role')::text IS NULL OR role = sqlc.narg('role'));

Generated:

type ListUsersWithFiltersParams struct {
    IsActive pgtype.Bool // ✅ Nullable with Valid flag
    Role     pgtype.Text // ✅ Nullable with Valid flag
}

Regenerating SQLc Code

After modifying .sql files in queries/, regenerate Go code:

make sqlc
# or
make generate

Migrations

Database migrations are managed by golang-migrate.

Create migration:

migrate create -ext sql -dir internal/storage/postgres/migrations -seq migration_name

Run migrations:

make migrate-up

Testing

  • Unit tests: Mock the Queries interface
  • Integration tests: Use real PostgreSQL with test database
  • Transaction tests: Verify rollback behavior

References

Troubleshooting

Query returns empty results despite data existing

Check if the query uses nullable parameters correctly. Search for Column1, Column2 in generated *.sql.go files - this indicates missing sqlc.narg().

"cannot use X (type T) as type pgtype.T"

You're likely passing a raw value to a nullable parameter. Wrap it:

params.Field = pgtype.Text{String: value, Valid: true}
SQLc generation fails
  1. Check SQL syntax in .sql files
  2. Verify sqlc.yaml configuration
  3. Run sqlc verify to validate queries

Documentation

Index

Constants

View Source
const DefaultMigrationsPath = "internal/storage/postgres/migrations"

Variables

This section is empty.

Functions

func MigrateDown

func MigrateDown(databaseURL string, migrationsPath string, steps int) error

func MigrateUp

func MigrateUp(databaseURL string, migrationsPath string) error

func NormalizeQuery

func NormalizeQuery(q string) string

NormalizeQuery normalizes a geocoding query for cache lookups. Converts to lowercase, trims whitespace, and collapses multiple spaces.

Types

type APIKeyRepository

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

func (*APIKeyRepository) LookupByPrefix

func (r *APIKeyRepository) LookupByPrefix(ctx context.Context, prefix string) (*auth.APIKey, error)

func (*APIKeyRepository) UpdateLastUsed

func (r *APIKeyRepository) UpdateLastUsed(ctx context.Context, id string) error

type ApiKey

type ApiKey struct {
	ID            pgtype.UUID        `json:"id"`
	Prefix        string             `json:"prefix"`
	KeyHash       string             `json:"key_hash"`
	HashVersion   int32              `json:"hash_version"`
	Name          string             `json:"name"`
	SourceID      pgtype.UUID        `json:"source_id"`
	Role          string             `json:"role"`
	RateLimitTier string             `json:"rate_limit_tier"`
	IsActive      bool               `json:"is_active"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	LastUsedAt    pgtype.Timestamptz `json:"last_used_at"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
	DeveloperID   pgtype.UUID        `json:"developer_id"`
}

type ApiKeyUsage

type ApiKeyUsage struct {
	ApiKeyID     pgtype.UUID `json:"api_key_id"`
	Date         pgtype.Date `json:"date"`
	RequestCount int64       `json:"request_count"`
	ErrorCount   int64       `json:"error_count"`
}

type ApiKeyUsageIp

type ApiKeyUsageIp struct {
	ApiKeyID     pgtype.UUID `json:"api_key_id"`
	Date         pgtype.Date `json:"date"`
	Ip           netip.Addr  `json:"ip"`
	RequestCount int64       `json:"request_count"`
	ErrorCount   int64       `json:"error_count"`
}

type ApproveReviewParams

type ApproveReviewParams struct {
	ReviewedBy pgtype.Text `json:"reviewed_by"`
	Notes      pgtype.Text `json:"notes"`
	ID         int32       `json:"id"`
}

type AuthRepository

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

AuthRepository wraps API key operations

func (*AuthRepository) APIKeys

APIKeys returns the API key repository

type BatchIngestionResult

type BatchIngestionResult struct {
	// Unique identifier for the batch job (PRIMARY KEY provides implicit index for lookups)
	BatchID string `json:"batch_id"`
	// JSON array of ingestion results per event
	Results []byte `json:"results"`
	// When the batch job completed
	CompletedAt pgtype.Timestamptz `json:"completed_at"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
}

Stores results of batch event ingestion jobs

type CachedGeocode

type CachedGeocode struct {
	ID              int64
	QueryNormalized string
	CountryCodes    string
	Latitude        float64
	Longitude       float64
	DisplayName     string
	PlaceType       string
	OSMID           *int64
	RawResponse     []byte // JSONB
	Source          string
	HitCount        int
	CreatedAt       time.Time
	ExpiresAt       *time.Time
}

CachedGeocode represents a cached forward geocoding result.

type CachedGeocodingFailure

type CachedGeocodingFailure struct {
	ID              int64
	QueryNormalized string
	CountryCodes    string
	FailureReason   string
	AttemptCount    int
	RetryAfter      *time.Time
	CreatedAt       time.Time
	ExpiresAt       *time.Time
}

CachedGeocodingFailure represents a tracked geocoding failure.

type CachedReverse

type CachedReverse struct {
	ID              int64
	Latitude        float64
	Longitude       float64
	DisplayName     string
	AddressRoad     *string
	AddressSuburb   *string
	AddressCity     *string
	AddressState    *string
	AddressPostcode *string
	AddressCountry  *string
	OSMID           *int64
	RawResponse     []byte // JSONB
	HitCount        int
	CreatedAt       time.Time
	ExpiresAt       *time.Time
}

CachedReverse represents a cached reverse geocoding result.

type ChangeFeedRepository

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

ChangeFeedRepository implements federation.ChangeFeedRepository using SQLc queries.

func NewChangeFeedRepository

func NewChangeFeedRepository(queries *Queries) *ChangeFeedRepository

NewChangeFeedRepository creates a new change feed repository.

func (*ChangeFeedRepository) ListEventChanges

ListEventChanges fetches event changes from the database.

type CheckAPIKeyOwnershipParams

type CheckAPIKeyOwnershipParams struct {
	ID          pgtype.UUID `json:"id"`
	DeveloperID pgtype.UUID `json:"developer_id"`
}

type CountRecentSubmissionsByIPParams

type CountRecentSubmissionsByIPParams struct {
	SubmitterIp netip.Addr      `json:"submitter_ip"`
	Interval    pgtype.Interval `json:"interval"`
}

type CountUsersParams

type CountUsersParams struct {
	IsActive pgtype.Bool `json:"is_active"`
	Role     pgtype.Text `json:"role"`
}

type CreateAPIKeyParams

type CreateAPIKeyParams struct {
	Prefix        string             `json:"prefix"`
	KeyHash       string             `json:"key_hash"`
	HashVersion   int32              `json:"hash_version"`
	Name          string             `json:"name"`
	SourceID      pgtype.UUID        `json:"source_id"`
	Role          string             `json:"role"`
	RateLimitTier string             `json:"rate_limit_tier"`
	IsActive      bool               `json:"is_active"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
}

type CreateAPIKeyRow

type CreateAPIKeyRow struct {
	ID            pgtype.UUID        `json:"id"`
	Prefix        string             `json:"prefix"`
	Name          string             `json:"name"`
	Role          string             `json:"role"`
	RateLimitTier string             `json:"rate_limit_tier"`
	IsActive      bool               `json:"is_active"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
}

type CreateBatchIngestionResultParams

type CreateBatchIngestionResultParams struct {
	BatchID     string             `json:"batch_id"`
	Results     []byte             `json:"results"`
	CompletedAt pgtype.Timestamptz `json:"completed_at"`
}

type CreateDeveloperAPIKeyParams

type CreateDeveloperAPIKeyParams struct {
	Prefix        string             `json:"prefix"`
	KeyHash       string             `json:"key_hash"`
	HashVersion   int32              `json:"hash_version"`
	Name          string             `json:"name"`
	DeveloperID   pgtype.UUID        `json:"developer_id"`
	Role          string             `json:"role"`
	RateLimitTier string             `json:"rate_limit_tier"`
	IsActive      bool               `json:"is_active"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
}

type CreateDeveloperAPIKeyRow

type CreateDeveloperAPIKeyRow struct {
	ID            pgtype.UUID        `json:"id"`
	Prefix        string             `json:"prefix"`
	Name          string             `json:"name"`
	Role          string             `json:"role"`
	RateLimitTier string             `json:"rate_limit_tier"`
	IsActive      bool               `json:"is_active"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
}

type CreateDeveloperInvitationParams

type CreateDeveloperInvitationParams struct {
	Email     string             `json:"email"`
	TokenHash string             `json:"token_hash"`
	InvitedBy pgtype.UUID        `json:"invited_by"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
}

func NewCreateDeveloperInvitationParams

func NewCreateDeveloperInvitationParams(email, tokenHash string, invitedBy pgtype.UUID, expiresAt time.Time) CreateDeveloperInvitationParams

Helper function for creating developer invitations

type CreateDeveloperParams

type CreateDeveloperParams struct {
	Email          string      `json:"email"`
	Name           string      `json:"name"`
	GithubID       pgtype.Int8 `json:"github_id"`
	GithubUsername pgtype.Text `json:"github_username"`
	PasswordHash   pgtype.Text `json:"password_hash"`
	MaxKeys        int32       `json:"max_keys"`
}

func NewCreateDeveloperParams

func NewCreateDeveloperParams(email, name string, maxKeys int32) CreateDeveloperParams

Helper function for creating a CreateDeveloperParams

func (*CreateDeveloperParams) SetGitHub

func (p *CreateDeveloperParams) SetGitHub(id int64, username string)

SetGitHub sets GitHub OAuth details

func (*CreateDeveloperParams) SetPasswordHash

func (p *CreateDeveloperParams) SetPasswordHash(hash string)

SetPasswordHash sets the password hash (for email/password auth)

type CreateEventTombstoneParams

type CreateEventTombstoneParams struct {
	EventID         pgtype.UUID        `json:"event_id"`
	EventUri        string             `json:"event_uri"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason  pgtype.Text        `json:"deletion_reason"`
	SupersededByUri pgtype.Text        `json:"superseded_by_uri"`
	Payload         []byte             `json:"payload"`
}

type CreateFederatedEventOccurrenceParams

type CreateFederatedEventOccurrenceParams struct {
	EventID    pgtype.UUID        `json:"event_id"`
	StartTime  pgtype.Timestamptz `json:"start_time"`
	EndTime    pgtype.Timestamptz `json:"end_time"`
	Timezone   string             `json:"timezone"`
	VirtualUrl pgtype.Text        `json:"virtual_url"`
}

type CreateFederationNodeParams

type CreateFederationNodeParams struct {
	NodeDomain       string      `json:"node_domain"`
	NodeName         string      `json:"node_name"`
	BaseUrl          string      `json:"base_url"`
	ApiVersion       string      `json:"api_version"`
	GeographicScope  pgtype.Text `json:"geographic_scope"`
	TrustLevel       int32       `json:"trust_level"`
	FederationStatus string      `json:"federation_status"`
	SyncEnabled      pgtype.Bool `json:"sync_enabled"`
	SyncDirection    pgtype.Text `json:"sync_direction"`
	ContactEmail     pgtype.Text `json:"contact_email"`
	ContactName      pgtype.Text `json:"contact_name"`
	Notes            pgtype.Text `json:"notes"`
}

type CreateOrganizationTombstoneParams

type CreateOrganizationTombstoneParams struct {
	OrganizationID  pgtype.UUID        `json:"organization_id"`
	OrganizationUri string             `json:"organization_uri"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason  pgtype.Text        `json:"deletion_reason"`
	SupersededByUri pgtype.Text        `json:"superseded_by_uri"`
	Payload         []byte             `json:"payload"`
}

type CreatePlaceTombstoneParams

type CreatePlaceTombstoneParams struct {
	PlaceID         pgtype.UUID        `json:"place_id"`
	PlaceUri        string             `json:"place_uri"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason  pgtype.Text        `json:"deletion_reason"`
	SupersededByUri pgtype.Text        `json:"superseded_by_uri"`
	Payload         []byte             `json:"payload"`
}

type CreateReviewQueueEntryParams

type CreateReviewQueueEntryParams struct {
	EventID            pgtype.UUID        `json:"event_id"`
	OriginalPayload    []byte             `json:"original_payload"`
	NormalizedPayload  []byte             `json:"normalized_payload"`
	Warnings           []byte             `json:"warnings"`
	SourceID           pgtype.Text        `json:"source_id"`
	SourceExternalID   pgtype.Text        `json:"source_external_id"`
	DedupHash          pgtype.Text        `json:"dedup_hash"`
	EventStartTime     pgtype.Timestamptz `json:"event_start_time"`
	EventEndTime       pgtype.Timestamptz `json:"event_end_time"`
	DuplicateOfEventID pgtype.UUID        `json:"duplicate_of_event_id"`
}

type CreateUserInvitationParams

type CreateUserInvitationParams struct {
	UserID    pgtype.UUID        `json:"user_id"`
	TokenHash string             `json:"token_hash"`
	Email     string             `json:"email"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	CreatedBy pgtype.UUID        `json:"created_by"`
}

type CreateUserInvitationRow

type CreateUserInvitationRow struct {
	ID        pgtype.UUID        `json:"id"`
	TokenHash string             `json:"token_hash"`
	Email     string             `json:"email"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type CreateUserParams

type CreateUserParams struct {
	Username     string `json:"username"`
	Email        string `json:"email"`
	PasswordHash string `json:"password_hash"`
	Role         string `json:"role"`
	IsActive     bool   `json:"is_active"`
}

type CreateUserRow

type CreateUserRow struct {
	ID        pgtype.UUID        `json:"id"`
	Username  string             `json:"username"`
	Email     string             `json:"email"`
	Role      string             `json:"role"`
	IsActive  bool               `json:"is_active"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

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
}

type DeleteOccurrenceByIDParams

type DeleteOccurrenceByIDParams struct {
	ID      pgtype.UUID `json:"id"`
	EventID pgtype.UUID `json:"event_id"`
}

type Developer

type Developer struct {
	ID             pgtype.UUID        `json:"id"`
	Email          string             `json:"email"`
	Name           string             `json:"name"`
	GithubID       pgtype.Int8        `json:"github_id"`
	GithubUsername pgtype.Text        `json:"github_username"`
	PasswordHash   pgtype.Text        `json:"password_hash"`
	MaxKeys        int32              `json:"max_keys"`
	IsActive       bool               `json:"is_active"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	LastLoginAt    pgtype.Timestamptz `json:"last_login_at"`
}

type DeveloperInvitation

type DeveloperInvitation struct {
	ID         pgtype.UUID        `json:"id"`
	Email      string             `json:"email"`
	TokenHash  string             `json:"token_hash"`
	InvitedBy  pgtype.UUID        `json:"invited_by"`
	ExpiresAt  pgtype.Timestamptz `json:"expires_at"`
	AcceptedAt pgtype.Timestamptz `json:"accepted_at"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
}

type DeveloperRepository

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

DeveloperRepository handles developer-related database operations

func NewDeveloperRepository

func NewDeveloperRepository(pool *pgxpool.Pool) *DeveloperRepository

NewDeveloperRepository creates a new DeveloperRepository

func (*DeveloperRepository) AcceptDeveloperInvitation

func (r *DeveloperRepository) AcceptDeveloperInvitation(ctx context.Context, id pgtype.UUID) error

AcceptDeveloperInvitation marks an invitation as accepted

func (*DeveloperRepository) BeginTx

func (r *DeveloperRepository) BeginTx(ctx context.Context) (*DeveloperRepository, *developerTxCommitter, error)

BeginTx starts a new transaction and returns a transaction-scoped repository

func (*DeveloperRepository) CheckAPIKeyOwnership

func (r *DeveloperRepository) CheckAPIKeyOwnership(ctx context.Context, keyID, developerID pgtype.UUID) (bool, error)

CheckAPIKeyOwnership verifies that a specific API key belongs to a developer

func (*DeveloperRepository) CountDeveloperAPIKeys

func (r *DeveloperRepository) CountDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) (int64, error)

CountDeveloperAPIKeys counts active API keys for a developer

func (*DeveloperRepository) CountDevelopers

func (r *DeveloperRepository) CountDevelopers(ctx context.Context) (int64, error)

CountDevelopers returns the total number of developers

func (*DeveloperRepository) CreateDeveloper

func (r *DeveloperRepository) CreateDeveloper(ctx context.Context, params CreateDeveloperParams) (Developer, error)

CreateDeveloper creates a new developer account

func (*DeveloperRepository) CreateDeveloperInvitation

func (r *DeveloperRepository) CreateDeveloperInvitation(ctx context.Context, params CreateDeveloperInvitationParams) (DeveloperInvitation, error)

CreateDeveloperInvitation creates a new developer invitation

func (*DeveloperRepository) DeactivateDeveloper

func (r *DeveloperRepository) DeactivateDeveloper(ctx context.Context, id pgtype.UUID) error

DeactivateDeveloper marks a developer account as inactive

func (*DeveloperRepository) GetDeveloperByEmail

func (r *DeveloperRepository) GetDeveloperByEmail(ctx context.Context, email string) (Developer, error)

GetDeveloperByEmail retrieves a developer by their email

func (*DeveloperRepository) GetDeveloperByGitHubID

func (r *DeveloperRepository) GetDeveloperByGitHubID(ctx context.Context, githubID int64) (Developer, error)

GetDeveloperByGitHubID retrieves a developer by their GitHub ID

func (*DeveloperRepository) GetDeveloperByID

func (r *DeveloperRepository) GetDeveloperByID(ctx context.Context, id pgtype.UUID) (Developer, error)

GetDeveloperByID retrieves a developer by their ID

func (*DeveloperRepository) GetDeveloperInvitationByTokenHash

func (r *DeveloperRepository) GetDeveloperInvitationByTokenHash(ctx context.Context, tokenHash string) (DeveloperInvitation, error)

GetDeveloperInvitationByTokenHash retrieves an unaccepted invitation by token hash

func (*DeveloperRepository) ListActiveDeveloperInvitations

func (r *DeveloperRepository) ListActiveDeveloperInvitations(ctx context.Context) ([]DeveloperInvitation, error)

ListActiveDeveloperInvitations retrieves all active (unaccepted, non-expired) invitations

func (*DeveloperRepository) ListDeveloperAPIKeys

func (r *DeveloperRepository) ListDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) ([]ApiKey, error)

ListDeveloperAPIKeys retrieves all API keys for a developer

func (*DeveloperRepository) ListDevelopers

func (r *DeveloperRepository) ListDevelopers(ctx context.Context, limit, offset int32) ([]Developer, error)

ListDevelopers retrieves a paginated list of developers

func (*DeveloperRepository) RevokeAllDeveloperAPIKeys

func (r *DeveloperRepository) RevokeAllDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) (int64, error)

RevokeAllDeveloperAPIKeys revokes all active API keys for a developer

func (*DeveloperRepository) UpdateDeveloper

func (r *DeveloperRepository) UpdateDeveloper(ctx context.Context, params UpdateDeveloperParams) (Developer, error)

UpdateDeveloper updates developer fields (nullable parameters only update if provided)

func (*DeveloperRepository) UpdateDeveloperLastLogin

func (r *DeveloperRepository) UpdateDeveloperLastLogin(ctx context.Context, id pgtype.UUID) error

UpdateDeveloperLastLogin updates the last login timestamp for a developer

func (*DeveloperRepository) WithTx

WithTx returns a new repository instance that will use the provided transaction

type DeveloperRepositoryAdapter

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

DeveloperRepositoryAdapter adapts postgres.DeveloperRepository to implement developers.Repository It converts between postgres models and domain models.

func NewDeveloperRepositoryAdapter

func NewDeveloperRepositoryAdapter(pool *pgxpool.Pool) *DeveloperRepositoryAdapter

NewDeveloperRepositoryAdapter creates a new adapter for the developer repository

func (*DeveloperRepositoryAdapter) AcceptInvitation

func (a *DeveloperRepositoryAdapter) AcceptInvitation(ctx context.Context, id uuid.UUID) error

AcceptInvitation marks an invitation as accepted

func (*DeveloperRepositoryAdapter) BeginTx

BeginTx starts a new transaction and returns a transaction-scoped repository adapter

func (*DeveloperRepositoryAdapter) CheckAPIKeyOwnership

func (a *DeveloperRepositoryAdapter) CheckAPIKeyOwnership(ctx context.Context, keyID uuid.UUID, developerID uuid.UUID) (bool, error)

CheckAPIKeyOwnership verifies that a specific API key belongs to a developer

func (*DeveloperRepositoryAdapter) CountDeveloperAPIKeys

func (a *DeveloperRepositoryAdapter) CountDeveloperAPIKeys(ctx context.Context, developerID uuid.UUID) (int64, error)

CountDeveloperAPIKeys counts active API keys for a developer

func (*DeveloperRepositoryAdapter) CountDevelopers

func (a *DeveloperRepositoryAdapter) CountDevelopers(ctx context.Context) (int64, error)

CountDevelopers returns the total number of developers

func (*DeveloperRepositoryAdapter) CreateAPIKey

CreateAPIKey creates a new API key

func (*DeveloperRepositoryAdapter) CreateDeveloper

CreateDeveloper creates a new developer account

func (*DeveloperRepositoryAdapter) CreateInvitation

CreateInvitation creates a new developer invitation

func (*DeveloperRepositoryAdapter) DeactivateAPIKey

func (a *DeveloperRepositoryAdapter) DeactivateAPIKey(ctx context.Context, id uuid.UUID) error

DeactivateAPIKey deactivates an API key

func (*DeveloperRepositoryAdapter) DeactivateDeveloper

func (a *DeveloperRepositoryAdapter) DeactivateDeveloper(ctx context.Context, id uuid.UUID) error

DeactivateDeveloper marks a developer account as inactive

func (*DeveloperRepositoryAdapter) GetAPIKeyByID

func (a *DeveloperRepositoryAdapter) GetAPIKeyByID(ctx context.Context, id uuid.UUID) (*developers.APIKey, error)

GetAPIKeyByID retrieves an API key by ID

func (*DeveloperRepositoryAdapter) GetAPIKeyUsage

func (a *DeveloperRepositoryAdapter) GetAPIKeyUsage(ctx context.Context, apiKeyID uuid.UUID, startDate, endDate time.Time) ([]developers.DailyUsage, error)

GetAPIKeyUsage retrieves daily usage records for an API key in a date range

func (*DeveloperRepositoryAdapter) GetAPIKeyUsageTotal

func (a *DeveloperRepositoryAdapter) GetAPIKeyUsageTotal(ctx context.Context, apiKeyID uuid.UUID, startDate, endDate time.Time) (totalRequests, totalErrors int64, err error)

GetAPIKeyUsageTotal retrieves total usage for an API key in a date range

func (*DeveloperRepositoryAdapter) GetDeveloperByEmail

func (a *DeveloperRepositoryAdapter) GetDeveloperByEmail(ctx context.Context, email string) (*developers.Developer, error)

GetDeveloperByEmail retrieves a developer by their email

func (*DeveloperRepositoryAdapter) GetDeveloperByGitHubID

func (a *DeveloperRepositoryAdapter) GetDeveloperByGitHubID(ctx context.Context, githubID int64) (*developers.Developer, error)

GetDeveloperByGitHubID retrieves a developer by their GitHub ID

func (*DeveloperRepositoryAdapter) GetDeveloperByID

func (a *DeveloperRepositoryAdapter) GetDeveloperByID(ctx context.Context, id uuid.UUID) (*developers.Developer, error)

GetDeveloperByID retrieves a developer by their ID

func (*DeveloperRepositoryAdapter) GetDeveloperUsageTotal

func (a *DeveloperRepositoryAdapter) GetDeveloperUsageTotal(ctx context.Context, developerID uuid.UUID, startDate, endDate time.Time) (totalRequests, totalErrors int64, err error)

GetDeveloperUsageTotal retrieves total usage for all of a developer's keys in a date range

func (*DeveloperRepositoryAdapter) GetInvitationByTokenHash

func (a *DeveloperRepositoryAdapter) GetInvitationByTokenHash(ctx context.Context, tokenHash string) (*developers.DeveloperInvitation, error)

GetInvitationByTokenHash retrieves an invitation by token hash

func (*DeveloperRepositoryAdapter) ListActiveInvitations

func (a *DeveloperRepositoryAdapter) ListActiveInvitations(ctx context.Context) ([]*developers.DeveloperInvitation, error)

ListActiveInvitations retrieves all active invitations

func (*DeveloperRepositoryAdapter) ListDeveloperAPIKeys

func (a *DeveloperRepositoryAdapter) ListDeveloperAPIKeys(ctx context.Context, developerID uuid.UUID) ([]developers.APIKey, error)

ListDeveloperAPIKeys retrieves all API keys for a developer

func (*DeveloperRepositoryAdapter) ListDevelopers

func (a *DeveloperRepositoryAdapter) ListDevelopers(ctx context.Context, limit, offset int) ([]*developers.Developer, error)

ListDevelopers retrieves a paginated list of developers

func (*DeveloperRepositoryAdapter) RevokeAllDeveloperAPIKeys

func (a *DeveloperRepositoryAdapter) RevokeAllDeveloperAPIKeys(ctx context.Context, developerID uuid.UUID) (int64, error)

RevokeAllDeveloperAPIKeys revokes all active API keys for a developer

func (*DeveloperRepositoryAdapter) UpdateDeveloper

UpdateDeveloper updates developer fields

func (*DeveloperRepositoryAdapter) UpdateDeveloperLastLogin

func (a *DeveloperRepositoryAdapter) UpdateDeveloperLastLogin(ctx context.Context, id uuid.UUID) error

UpdateDeveloperLastLogin updates the last login timestamp

func (*DeveloperRepositoryAdapter) ValidateDeveloperPassword

func (a *DeveloperRepositoryAdapter) ValidateDeveloperPassword(ctx context.Context, id uuid.UUID, password string) (bool, error)

ValidateDeveloperPassword validates a developer's password against the stored hash

type DismissAllCompanionWarningsParams

type DismissAllCompanionWarningsParams struct {
	ReviewID  int32  `json:"review_id"`
	EventUlid string `json:"event_ulid"`
}

type DismissCompanionWarningMatchParams

type DismissCompanionWarningMatchParams struct {
	EventUlid     string `json:"event_ulid"`
	CompanionUlid string `json:"companion_ulid"`
}

type DismissWarningMatchByReviewIDParams

type DismissWarningMatchByReviewIDParams struct {
	EventUlid string `json:"event_ulid"`
	ReviewID  int32  `json:"review_id"`
}

type EntityIdentifier

type EntityIdentifier struct {
	ID                   int32              `json:"id"`
	EntityType           string             `json:"entity_type"`
	EntityID             string             `json:"entity_id"`
	AuthorityCode        string             `json:"authority_code"`
	IdentifierUri        string             `json:"identifier_uri"`
	Confidence           pgtype.Numeric     `json:"confidence"`
	ReconciliationMethod string             `json:"reconciliation_method"`
	IsCanonical          bool               `json:"is_canonical"`
	Metadata             []byte             `json:"metadata"`
	CreatedAt            pgtype.Timestamptz `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz `json:"updated_at"`
}

type Event

type Event struct {
	ID                    pgtype.UUID        `json:"id"`
	Ulid                  string             `json:"ulid"`
	Name                  string             `json:"name"`
	Description           pgtype.Text        `json:"description"`
	LifecycleState        string             `json:"lifecycle_state"`
	EventStatus           pgtype.Text        `json:"event_status"`
	AttendanceMode        pgtype.Text        `json:"attendance_mode"`
	OrganizerID           pgtype.UUID        `json:"organizer_id"`
	PrimaryVenueID        pgtype.UUID        `json:"primary_venue_id"`
	SeriesID              pgtype.UUID        `json:"series_id"`
	ImageUrl              pgtype.Text        `json:"image_url"`
	PublicUrl             pgtype.Text        `json:"public_url"`
	VirtualUrl            pgtype.Text        `json:"virtual_url"`
	Keywords              []string           `json:"keywords"`
	InLanguage            []string           `json:"in_language"`
	DefaultLanguage       pgtype.Text        `json:"default_language"`
	IsAccessibleForFree   pgtype.Bool        `json:"is_accessible_for_free"`
	AccessibilityFeatures []string           `json:"accessibility_features"`
	EventDomain           pgtype.Text        `json:"event_domain"`
	OriginNodeID          pgtype.UUID        `json:"origin_node_id"`
	FederationUri         pgtype.Text        `json:"federation_uri"`
	DedupHash             pgtype.Text        `json:"dedup_hash"`
	LicenseUrl            string             `json:"license_url"`
	LicenseStatus         string             `json:"license_status"`
	TakedownRequested     bool               `json:"takedown_requested"`
	TakedownRequestedAt   pgtype.Timestamptz `json:"takedown_requested_at"`
	TakedownRequestNotes  pgtype.Text        `json:"takedown_request_notes"`
	Confidence            pgtype.Numeric     `json:"confidence"`
	QualityScore          pgtype.Int4        `json:"quality_score"`
	Version               int32              `json:"version"`
	CreatedAt             pgtype.Timestamptz `json:"created_at"`
	UpdatedAt             pgtype.Timestamptz `json:"updated_at"`
	PublishedAt           pgtype.Timestamptz `json:"published_at"`
	DeletedAt             pgtype.Timestamptz `json:"deleted_at"`
	MergedIntoID          pgtype.UUID        `json:"merged_into_id"`
	DeletionReason        pgtype.Text        `json:"deletion_reason"`
}

type EventChange

type EventChange struct {
	ID             pgtype.UUID        `json:"id"`
	EventID        pgtype.UUID        `json:"event_id"`
	Action         string             `json:"action"`
	ChangedFields  []byte             `json:"changed_fields"`
	Snapshot       []byte             `json:"snapshot"`
	ChangedAt      pgtype.Timestamptz `json:"changed_at"`
	SequenceNumber pgtype.Int8        `json:"sequence_number"`
	SourceID       pgtype.UUID        `json:"source_id"`
	UserID         pgtype.UUID        `json:"user_id"`
}

type EventNotDuplicate

type EventNotDuplicate struct {
	EventIDA  string             `json:"event_id_a"`
	EventIDB  string             `json:"event_id_b"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	CreatedBy pgtype.Text        `json:"created_by"`
}

type EventOccurrence

type EventOccurrence struct {
	ID                 pgtype.UUID        `json:"id"`
	EventID            pgtype.UUID        `json:"event_id"`
	StartTime          pgtype.Timestamptz `json:"start_time"`
	EndTime            pgtype.Timestamptz `json:"end_time"`
	Timezone           string             `json:"timezone"`
	DoorTime           pgtype.Timestamptz `json:"door_time"`
	LocalDate          pgtype.Date        `json:"local_date"`
	LocalStartTime     pgtype.Time        `json:"local_start_time"`
	LocalDayOfWeek     pgtype.Int4        `json:"local_day_of_week"`
	VenueID            pgtype.UUID        `json:"venue_id"`
	VirtualUrl         pgtype.Text        `json:"virtual_url"`
	StatusOverride     pgtype.Text        `json:"status_override"`
	CancellationReason pgtype.Text        `json:"cancellation_reason"`
	OccurrenceIndex    pgtype.Int4        `json:"occurrence_index"`
	TicketUrl          pgtype.Text        `json:"ticket_url"`
	PriceMin           pgtype.Numeric     `json:"price_min"`
	PriceMax           pgtype.Numeric     `json:"price_max"`
	PriceCurrency      pgtype.Text        `json:"price_currency"`
	Availability       pgtype.Text        `json:"availability"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
}

type EventRepository

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

func NewEventRepository

func NewEventRepository(pool *pgxpool.Pool, logger zerolog.Logger) *EventRepository

func (*EventRepository) ApproveReview

func (r *EventRepository) ApproveReview(ctx context.Context, id int, reviewedBy string, notes *string) (*events.ReviewQueueEntry, error)

ApproveReview marks a review as approved

func (*EventRepository) BeginTx

BeginTx starts a new transaction and returns a transaction-scoped repository

func (*EventRepository) CheckOccurrenceOverlap

func (r *EventRepository) CheckOccurrenceOverlap(ctx context.Context, eventID string, startTime time.Time, endTime *time.Time) (bool, error)

CheckOccurrenceOverlap returns true if [startTime, endTime) overlaps any existing occurrence on the given event. When endTime is nil the new occurrence is treated as a point-in-time event; overlap is detected if that instant falls inside any existing occurrence whose end_time is non-null, or equals the start_time of any occurrence without an end_time.

func (*EventRepository) CheckOccurrenceOverlapExcluding

func (r *EventRepository) CheckOccurrenceOverlapExcluding(ctx context.Context, eventID string, startTime time.Time, endTime *time.Time, excludeOccurrenceID string) (bool, error)

CheckOccurrenceOverlapExcluding returns true if [startTime, endTime) overlaps any existing occurrence on the given event, excluding the occurrence identified by excludeOccurrenceID.

func (*EventRepository) CleanupExpiredReviews

func (r *EventRepository) CleanupExpiredReviews(ctx context.Context) error

CleanupExpiredReviews runs all cleanup operations for the review queue

func (*EventRepository) CountOccurrences

func (r *EventRepository) CountOccurrences(ctx context.Context, eventID string) (int64, error)

CountOccurrences returns the number of occurrences for the event identified by eventID (UUID).

func (*EventRepository) Create

func (*EventRepository) CreateOccurrence

func (r *EventRepository) CreateOccurrence(ctx context.Context, params events.OccurrenceCreateParams) error

func (*EventRepository) CreateReviewQueueEntry

func (r *EventRepository) CreateReviewQueueEntry(ctx context.Context, params events.ReviewQueueCreateParams) (*events.ReviewQueueEntry, error)

CreateReviewQueueEntry creates a new review queue entry

func (*EventRepository) CreateSource

func (r *EventRepository) CreateSource(ctx context.Context, params events.EventSourceCreateParams) error

func (*EventRepository) CreateTombstone

func (r *EventRepository) CreateTombstone(ctx context.Context, params events.TombstoneCreateParams) error

CreateTombstone creates a tombstone record for a deleted event

func (*EventRepository) DeleteOccurrenceByID

func (r *EventRepository) DeleteOccurrenceByID(ctx context.Context, eventID string, occurrenceID string) error

DeleteOccurrenceByID deletes a single occurrence row by its UUID, scoped to the given event. Returns ErrNotFound if the row does not exist or belongs to a different event.

func (*EventRepository) DeleteOccurrencesByEventULID

func (r *EventRepository) DeleteOccurrencesByEventULID(ctx context.Context, eventULID string) error

DeleteOccurrencesByEventULID removes all occurrence rows for an event identified by ULID. Used after absorbing an occurrence into a target series to clean up orphaned rows on the soft-deleted source event (soft-delete does not trigger ON DELETE CASCADE).

func (*EventRepository) DismissAllCompanionWarnings

func (r *EventRepository) DismissAllCompanionWarnings(ctx context.Context, reviewID int, eventULID string) (bool, error)

DismissAllCompanionWarnings atomically strips all companion warning entries (near_duplicate_of_new_event, potential_duplicate, cross_week_series_companion) referencing the given eventULID from a specific review row. Also clears duplicate_of_event_id if it points to the given event. Returns true when the resulting warnings array is empty (all warnings stripped).

func (*EventRepository) DismissCompanionWarningMatch

func (r *EventRepository) DismissCompanionWarningMatch(ctx context.Context, companionULID string, eventULID string) error

DismissCompanionWarningMatch atomically removes any potential_duplicate match whose ulid equals eventULID from the companion review's warnings JSONB. This is a single-statement UPDATE with no read-modify-write race. NOTE: This targets any pending row for the companion event; prefer DismissWarningMatchByReviewID when the exact review row ID is known.

func (*EventRepository) DismissPendingReviewsByEventULIDs

func (r *EventRepository) DismissPendingReviewsByEventULIDs(ctx context.Context, eventULIDs []string, reviewedBy string) ([]int, error)

DismissPendingReviewsByEventULIDs batch-dismisses all pending review queue entries for the given event ULIDs, setting their status to 'dismissed' and reviewer to reviewedBy. Returns the IDs of dismissed entries (may be empty if none were pending).

func (*EventRepository) DismissWarningMatchByReviewID

func (r *EventRepository) DismissWarningMatchByReviewID(ctx context.Context, id int, eventULID string) error

DismissWarningMatchByReviewID atomically removes any potential_duplicate match whose ulid equals eventULID from the specific review row identified by id. This is strictly narrower than DismissCompanionWarningMatch and should be used whenever the exact companion review row is already known.

func (*EventRepository) FindByDedupHash

func (r *EventRepository) FindByDedupHash(ctx context.Context, dedupHash string) (*events.Event, error)

func (*EventRepository) FindBySourceExternalID

func (r *EventRepository) FindBySourceExternalID(ctx context.Context, sourceID string, sourceEventID string) (*events.Event, error)

func (*EventRepository) FindCrossWeekCompanionTargets

func (r *EventRepository) FindCrossWeekCompanionTargets(ctx context.Context, retireULIDs []string) ([]events.CrossWeekCompanionTarget, error)

FindCrossWeekCompanionTargets finds all pending review entries whose cross_week_series_companion warnings reference any of the given retire ULIDs.

func (*EventRepository) FindNearDuplicates

func (r *EventRepository) FindNearDuplicates(ctx context.Context, venueID string, startTime time.Time, eventName string, threshold float64) ([]events.NearDuplicateCandidate, error)

FindNearDuplicates finds events at the same venue on the same date with similar names. Uses pg_trgm similarity() for fuzzy name matching. Returns candidates above the threshold.

func (*EventRepository) FindReviewByDedup

func (r *EventRepository) FindReviewByDedup(ctx context.Context, sourceID *string, externalID *string, dedupHash *string) (*events.ReviewQueueEntry, error)

FindReviewByDedup finds an existing review by deduplication keys

func (*EventRepository) FindSeriesCompanion

func (r *EventRepository) FindSeriesCompanion(ctx context.Context, params events.SeriesCompanionQuery) (*events.CrossWeekCompanion, error)

func (*EventRepository) FindSimilarOrganizations

func (r *EventRepository) FindSimilarOrganizations(ctx context.Context, name string, locality string, region string, threshold float64) ([]events.SimilarOrgCandidate, error)

FindSimilarOrganizations returns organizations with similar normalized names in the same locality/region. Uses pg_trgm similarity() against the normalized_name column, which has a GIN trgm index. Excludes organizations that have already been merged into another organization.

func (*EventRepository) FindSimilarPlaces

func (r *EventRepository) FindSimilarPlaces(ctx context.Context, name string, locality string, region string, threshold float64) ([]events.SimilarPlaceCandidate, error)

FindSimilarPlaces returns places with similar normalized names in the same locality/region. Uses pg_trgm similarity() against the normalized_name column, which has a GIN trgm index. Excludes places that have already been merged into another place.

func (*EventRepository) GetByULID

func (r *EventRepository) GetByULID(ctx context.Context, ulid string) (*events.Event, error)

func (*EventRepository) GetIdempotencyKey

func (r *EventRepository) GetIdempotencyKey(ctx context.Context, key string) (*events.IdempotencyKey, error)

func (*EventRepository) GetOccurrenceByID

func (r *EventRepository) GetOccurrenceByID(ctx context.Context, eventID string, occurrenceID string) (*events.Occurrence, error)

GetOccurrenceByID fetches a single occurrence by its UUID, scoped to the given event. Returns ErrNotFound if the row does not exist or belongs to a different event.

func (*EventRepository) GetOrCreateSource

func (r *EventRepository) GetOrCreateSource(ctx context.Context, params events.SourceLookupParams) (string, error)

func (*EventRepository) GetPendingReviewByEventUlid

func (r *EventRepository) GetPendingReviewByEventUlid(ctx context.Context, eventULID string) (*events.ReviewQueueEntry, error)

GetPendingReviewByEventUlid returns the pending review queue entry for the given event ULID, or (nil, nil) if no pending review exists.

func (*EventRepository) GetPendingReviewByEventUlidAndDuplicateUlid

func (r *EventRepository) GetPendingReviewByEventUlidAndDuplicateUlid(ctx context.Context, eventULID string, duplicateULID string) (*events.ReviewQueueEntry, error)

GetPendingReviewByEventUlidAndDuplicateUlid returns the pending review queue entry for the given event ULID that is specifically linked to duplicateULID via duplicate_of_event_id. Returns (nil, nil) if no matching pending review exists. This narrows companion-review selection to the exact counterpart in a consolidation pair, preventing the wrong unrelated pending review from being dismissed when an event has multiple pending review rows.

func (*EventRepository) GetPlaceByULID

func (r *EventRepository) GetPlaceByULID(ctx context.Context, ulid string) (*events.PlaceRecord, error)

GetPlaceByULID looks up a place by its ULID and returns the (UUID, ULID, Name) triple. Name is returned so the caller can detect @id+name mismatches at ingest time. Returns events.ErrNotFound when no matching row exists.

func (*EventRepository) GetReviewQueueEntry

func (r *EventRepository) GetReviewQueueEntry(ctx context.Context, id int) (*events.ReviewQueueEntry, error)

GetReviewQueueEntry retrieves a single review queue entry by ID

func (*EventRepository) GetSourceTrustLevel

func (r *EventRepository) GetSourceTrustLevel(ctx context.Context, eventID string) (int, error)

GetSourceTrustLevel returns the highest trust level among sources linked to an event. Trust levels are 1-10 where higher values mean more trusted (10 = most trusted). Returns the default trust level of 5 if no sources are linked.

func (*EventRepository) GetSourceTrustLevelBySourceID

func (r *EventRepository) GetSourceTrustLevelBySourceID(ctx context.Context, sourceID string) (int, error)

GetSourceTrustLevelBySourceID returns the trust level for a specific source.

func (*EventRepository) GetTombstoneByEventID

func (r *EventRepository) GetTombstoneByEventID(ctx context.Context, eventID string) (*events.Tombstone, error)

GetTombstoneByEventID retrieves the tombstone for a deleted event by UUID

func (*EventRepository) GetTombstoneByEventULID

func (r *EventRepository) GetTombstoneByEventULID(ctx context.Context, eventULID string) (*events.Tombstone, error)

GetTombstoneByEventULID retrieves the tombstone for a deleted event by ULID

func (*EventRepository) InsertIdempotencyKey

func (*EventRepository) InsertNotDuplicate

func (r *EventRepository) InsertNotDuplicate(ctx context.Context, eventIDa string, eventIDb string, createdBy string) error

InsertNotDuplicate records that two events are confirmed as NOT duplicates. The pair is stored with canonical ordering (LEAST/GREATEST) so that (A,B) and (B,A) are equivalent.

func (*EventRepository) InsertOccurrence

func (r *EventRepository) InsertOccurrence(ctx context.Context, params events.OccurrenceCreateParams) (*events.Occurrence, error)

InsertOccurrence inserts a new occurrence for the given event and returns the created domain Occurrence (including the generated UUID).

func (*EventRepository) IsNotDuplicate

func (r *EventRepository) IsNotDuplicate(ctx context.Context, eventIDa string, eventIDb string) (bool, error)

IsNotDuplicate checks if a pair of events has been marked as not-duplicates.

func (*EventRepository) List

func (r *EventRepository) List(ctx context.Context, filters events.Filters, paginationArgs events.Pagination) (events.ListResult, error)

func (*EventRepository) ListReviewQueue

ListReviewQueue lists review queue entries with filters and pagination

func (*EventRepository) LockEventForUpdate

func (r *EventRepository) LockEventForUpdate(ctx context.Context, eventID string) error

LockEventForUpdate acquires a row-level FOR UPDATE lock on the given event (identified by UUID). Must be called inside a transaction. This serialises concurrent add-occurrence requests for the same target event so that the overlap check and occurrence insert are atomic from the database's perspective.

func (*EventRepository) LockReviewQueueEntryForUpdate

func (r *EventRepository) LockReviewQueueEntryForUpdate(ctx context.Context, id int) (*events.ReviewQueueEntry, error)

LockReviewQueueEntryForUpdate acquires a row-level FOR UPDATE lock on the review queue row identified by id and returns the current row state. Must be called inside a transaction. This serialises concurrent admin actions (approve, reject, merge, add-occurrence) on the same review entry so that only the first request observes status="pending" and the second sees the already-updated status and returns ErrConflict.

func (*EventRepository) MergeEvents

func (r *EventRepository) MergeEvents(ctx context.Context, duplicateULID string, primaryULID string) error

MergeEvents merges a duplicate event into a primary event. Implements transitive chain resolution: if the primary event has itself been merged into another event, follows the chain to find the final canonical event and merges into that instead. Also flattens any existing chains pointing to intermediate targets. This prevents stale merged_into_id references.

func (*EventRepository) MergeOrganizations

func (r *EventRepository) MergeOrganizations(ctx context.Context, duplicateID string, primaryID string) (*events.MergeResult, error)

MergeOrganizations merges a duplicate organization into a primary organization. Sets merged_into_id on the duplicate, reassigns all events pointing to the duplicate, fills empty fields on the primary from the duplicate, and soft-deletes the duplicate.

Handles concurrent merge races gracefully (same pattern as MergePlaces).

func (*EventRepository) MergePlaces

func (r *EventRepository) MergePlaces(ctx context.Context, duplicateID string, primaryID string) (*events.MergeResult, error)

MergePlaces merges a duplicate place into a primary place. Sets merged_into_id on the duplicate, reassigns all events pointing to the duplicate, fills empty fields on the primary from the duplicate, and soft-deletes the duplicate.

Handles concurrent merge races gracefully:

  • If the duplicate was already merged by another goroutine, follows the merge chain and returns the canonical place ID (AlreadyMerged=true).
  • If the primary was itself merged, follows that chain to find the real canonical.
  • Uses FOR UPDATE SKIP LOCKED to prevent two goroutines from merging the same duplicate simultaneously.

func (*EventRepository) MergeReview

func (r *EventRepository) MergeReview(ctx context.Context, id int, reviewedBy string, primaryEventULID string) (*events.ReviewQueueEntry, error)

MergeReview marks a review as merged, linking it to the primary event it was merged into. The duplicate event (from the review entry) is merged into primaryEventULID via AdminService.MergeEvents. This method only updates the review queue status — the caller is responsible for the actual event merge.

func (*EventRepository) RejectReview

func (r *EventRepository) RejectReview(ctx context.Context, id int, reviewedBy string, reason string) (*events.ReviewQueueEntry, error)

RejectReview marks a review as rejected

func (*EventRepository) Rollback

func (r *EventRepository) Rollback(ctx context.Context) error

func (*EventRepository) SoftDeleteEvent

func (r *EventRepository) SoftDeleteEvent(ctx context.Context, ulid string, reason string) error

SoftDeleteEvent marks an event as deleted

func (*EventRepository) StripRetiredDupWarnings

func (r *EventRepository) StripRetiredDupWarnings(ctx context.Context, reviewID int, retireULIDs []string) (bool, error)

StripRetiredDupWarnings atomically strips all duplicate warning entries referencing any of the given retireULIDs from a specific review row. Handles three warning types (near_duplicate_of_new_event, potential_duplicate, cross_week_series_companion). Also clears duplicate_of_event_id if it points to a retired event. Companion replacement is handled in Go after this returns.

func (*EventRepository) UpdateEvent

func (r *EventRepository) UpdateEvent(ctx context.Context, ulid string, params events.UpdateEventParams) (*events.Event, error)

UpdateEvent updates an event by ULID with the provided parameters

func (*EventRepository) UpdateIdempotencyKeyEvent

func (r *EventRepository) UpdateIdempotencyKeyEvent(ctx context.Context, key string, eventID string, eventULID string) error

func (*EventRepository) UpdateOccurrence

func (r *EventRepository) UpdateOccurrence(ctx context.Context, eventID string, occurrenceID string, params events.OccurrenceUpdateParams) (*events.Occurrence, error)

UpdateOccurrence applies a PATCH-semantic partial update to an occurrence, scoped to the given event. Returns ErrNotFound if the row does not exist or belongs to a different event.

func (*EventRepository) UpdateOccurrenceDates

func (r *EventRepository) UpdateOccurrenceDates(ctx context.Context, eventULID string, startTime time.Time, endTime *time.Time) error

UpdateOccurrenceDates updates the start_time and end_time of all occurrences for an event. Used by the FixReview workflow to correct occurrence dates during admin review.

func (*EventRepository) UpdateReviewQueueEntry

func (r *EventRepository) UpdateReviewQueueEntry(ctx context.Context, id int, params events.ReviewQueueUpdateParams) (*events.ReviewQueueEntry, error)

UpdateReviewQueueEntry updates an existing review queue entry

func (*EventRepository) UpdateReviewWarnings

func (r *EventRepository) UpdateReviewWarnings(ctx context.Context, id int, warnings []byte) error

Used for best-effort companion warning dismissal after a not-duplicate decision.

func (*EventRepository) UpsertEventSeries

func (*EventRepository) UpsertOrganization

func (*EventRepository) UpsertPlace

type EventReviewQueue

type EventReviewQueue struct {
	ID                 int32              `json:"id"`
	EventID            pgtype.UUID        `json:"event_id"`
	OriginalPayload    []byte             `json:"original_payload"`
	NormalizedPayload  []byte             `json:"normalized_payload"`
	Warnings           []byte             `json:"warnings"`
	SourceID           pgtype.Text        `json:"source_id"`
	SourceExternalID   pgtype.Text        `json:"source_external_id"`
	DedupHash          pgtype.Text        `json:"dedup_hash"`
	EventStartTime     pgtype.Timestamptz `json:"event_start_time"`
	EventEndTime       pgtype.Timestamptz `json:"event_end_time"`
	Status             string             `json:"status"`
	ReviewedBy         pgtype.Text        `json:"reviewed_by"`
	ReviewedAt         pgtype.Timestamptz `json:"reviewed_at"`
	ReviewNotes        pgtype.Text        `json:"review_notes"`
	RejectionReason    pgtype.Text        `json:"rejection_reason"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DuplicateOfEventID pgtype.UUID        `json:"duplicate_of_event_id"`
}

func (EventReviewQueue) GetCreatedAt

func (r EventReviewQueue) GetCreatedAt() pgtype.Timestamptz

func (EventReviewQueue) GetDedupHash

func (r EventReviewQueue) GetDedupHash() pgtype.Text

func (EventReviewQueue) GetDuplicateOfEventID

func (r EventReviewQueue) GetDuplicateOfEventID() pgtype.UUID

func (EventReviewQueue) GetDuplicateOfEventUlid

func (r EventReviewQueue) GetDuplicateOfEventUlid() pgtype.Text

func (EventReviewQueue) GetEventEndTime

func (r EventReviewQueue) GetEventEndTime() pgtype.Timestamptz

func (EventReviewQueue) GetEventID

func (r EventReviewQueue) GetEventID() pgtype.UUID

func (EventReviewQueue) GetEventStartTime

func (r EventReviewQueue) GetEventStartTime() pgtype.Timestamptz

func (EventReviewQueue) GetEventUlid

func (r EventReviewQueue) GetEventUlid() string

func (EventReviewQueue) GetID

func (r EventReviewQueue) GetID() int32

Implement reviewQueueRowFields for EventReviewQueue (standard row type without JOIN)

func (EventReviewQueue) GetNormalizedPayload

func (r EventReviewQueue) GetNormalizedPayload() []byte

func (EventReviewQueue) GetOriginalPayload

func (r EventReviewQueue) GetOriginalPayload() []byte

func (EventReviewQueue) GetRejectionReason

func (r EventReviewQueue) GetRejectionReason() pgtype.Text

func (EventReviewQueue) GetReviewNotes

func (r EventReviewQueue) GetReviewNotes() pgtype.Text

func (EventReviewQueue) GetReviewedAt

func (r EventReviewQueue) GetReviewedAt() pgtype.Timestamptz

func (EventReviewQueue) GetReviewedBy

func (r EventReviewQueue) GetReviewedBy() pgtype.Text

func (EventReviewQueue) GetSourceExternalID

func (r EventReviewQueue) GetSourceExternalID() pgtype.Text

func (EventReviewQueue) GetSourceID

func (r EventReviewQueue) GetSourceID() pgtype.Text

func (EventReviewQueue) GetStatus

func (r EventReviewQueue) GetStatus() string

func (EventReviewQueue) GetUpdatedAt

func (r EventReviewQueue) GetUpdatedAt() pgtype.Timestamptz

func (EventReviewQueue) GetWarnings

func (r EventReviewQueue) GetWarnings() []byte

type EventSeries

type EventSeries struct {
	ID               pgtype.UUID          `json:"id"`
	Name             string               `json:"name"`
	Description      pgtype.Text          `json:"description"`
	SeriesStartDate  pgtype.Date          `json:"series_start_date"`
	SeriesEndDate    pgtype.Date          `json:"series_end_date"`
	ScheduleTimezone string               `json:"schedule_timezone"`
	DefaultVenueID   pgtype.UUID          `json:"default_venue_id"`
	DefaultStartTime pgtype.Time          `json:"default_start_time"`
	DefaultEndTime   pgtype.Time          `json:"default_end_time"`
	OrganizerID      pgtype.UUID          `json:"organizer_id"`
	CreatedAt        pgtype.Timestamptz   `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz   `json:"updated_at"`
	Rrule            pgtype.Text          `json:"rrule"`
	Exdates          []pgtype.Timestamptz `json:"exdates"`
	Rdates           []pgtype.Timestamptz `json:"rdates"`
	ExternalKey      pgtype.Text          `json:"external_key"`
}

type EventSource

type EventSource struct {
	ID            pgtype.UUID        `json:"id"`
	EventID       pgtype.UUID        `json:"event_id"`
	SourceID      pgtype.UUID        `json:"source_id"`
	SourceUrl     string             `json:"source_url"`
	SourceEventID pgtype.Text        `json:"source_event_id"`
	RetrievedAt   pgtype.Timestamptz `json:"retrieved_at"`
	Payload       []byte             `json:"payload"`
	PayloadHash   string             `json:"payload_hash"`
	Confidence    pgtype.Numeric     `json:"confidence"`
}

type EventTombstone

type EventTombstone struct {
	ID              pgtype.UUID        `json:"id"`
	EventID         pgtype.UUID        `json:"event_id"`
	EventUri        string             `json:"event_uri"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason  pgtype.Text        `json:"deletion_reason"`
	SupersededByUri pgtype.Text        `json:"superseded_by_uri"`
	Payload         []byte             `json:"payload"`
}

type FederationNode

type FederationNode struct {
	ID                     pgtype.UUID        `json:"id"`
	NodeDomain             string             `json:"node_domain"`
	NodeName               string             `json:"node_name"`
	BaseUrl                string             `json:"base_url"`
	ApiVersion             string             `json:"api_version"`
	GeographicScope        pgtype.Text        `json:"geographic_scope"`
	ServiceAreaGeojson     []byte             `json:"service_area_geojson"`
	TrustLevel             int32              `json:"trust_level"`
	FederationStatus       string             `json:"federation_status"`
	SyncEnabled            pgtype.Bool        `json:"sync_enabled"`
	SyncDirection          pgtype.Text        `json:"sync_direction"`
	LastSyncAt             pgtype.Timestamptz `json:"last_sync_at"`
	LastSuccessfulSyncAt   pgtype.Timestamptz `json:"last_successful_sync_at"`
	SyncCursor             pgtype.Text        `json:"sync_cursor"`
	RequiresAuthentication pgtype.Bool        `json:"requires_authentication"`
	ApiKeyEncrypted        []byte             `json:"api_key_encrypted"`
	ContactEmail           pgtype.Text        `json:"contact_email"`
	ContactName            pgtype.Text        `json:"contact_name"`
	Config                 []byte             `json:"config"`
	IsOnline               pgtype.Bool        `json:"is_online"`
	LastHealthCheckAt      pgtype.Timestamptz `json:"last_health_check_at"`
	LastErrorAt            pgtype.Timestamptz `json:"last_error_at"`
	LastErrorMessage       pgtype.Text        `json:"last_error_message"`
	Notes                  pgtype.Text        `json:"notes"`
	CreatedAt              pgtype.Timestamptz `json:"created_at"`
	UpdatedAt              pgtype.Timestamptz `json:"updated_at"`
}

type FederationRepository

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

func NewFederationRepository

func NewFederationRepository(pool *pgxpool.Pool) *FederationRepository

func (*FederationRepository) Create

func (*FederationRepository) Delete

func (r *FederationRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*FederationRepository) GetByDomain

func (r *FederationRepository) GetByDomain(ctx context.Context, domain string) (*federation.Node, error)

func (*FederationRepository) GetByID

func (*FederationRepository) List

func (*FederationRepository) Update

type FieldConflict

type FieldConflict struct {
	EventID           pgtype.UUID `json:"event_id"`
	FieldPath         string      `json:"field_path"`
	ValueCount        int64       `json:"value_count"`
	ConflictingValues interface{} `json:"conflicting_values"`
}

type FieldProvenance

type FieldProvenance struct {
	ID                 pgtype.UUID        `json:"id"`
	EventID            pgtype.UUID        `json:"event_id"`
	FieldPath          string             `json:"field_path"`
	ValueHash          string             `json:"value_hash"`
	ValuePreview       pgtype.Text        `json:"value_preview"`
	SourceID           pgtype.UUID        `json:"source_id"`
	Confidence         pgtype.Numeric     `json:"confidence"`
	ObservedAt         pgtype.Timestamptz `json:"observed_at"`
	AppliedToCanonical bool               `json:"applied_to_canonical"`
	SupersededAt       pgtype.Timestamptz `json:"superseded_at"`
	SupersededByID     pgtype.UUID        `json:"superseded_by_id"`
}

type FindCrossWeekCompanionTargetsRow

type FindCrossWeekCompanionTargetsRow struct {
	ReviewID  int32  `json:"review_id"`
	EventUlid string `json:"event_ulid"`
}

type FindReviewByDedupParams

type FindReviewByDedupParams struct {
	SourceID         pgtype.Text `json:"source_id"`
	SourceExternalID pgtype.Text `json:"source_external_id"`
	DedupHash        pgtype.Text `json:"dedup_hash"`
}

type FindReviewByDedupRow

type FindReviewByDedupRow struct {
	ID                   int32              `json:"id"`
	EventID              pgtype.UUID        `json:"event_id"`
	EventUlid            string             `json:"event_ulid"`
	OriginalPayload      []byte             `json:"original_payload"`
	NormalizedPayload    []byte             `json:"normalized_payload"`
	Warnings             []byte             `json:"warnings"`
	SourceID             pgtype.Text        `json:"source_id"`
	SourceExternalID     pgtype.Text        `json:"source_external_id"`
	DedupHash            pgtype.Text        `json:"dedup_hash"`
	EventStartTime       pgtype.Timestamptz `json:"event_start_time"`
	EventEndTime         pgtype.Timestamptz `json:"event_end_time"`
	Status               string             `json:"status"`
	ReviewedBy           pgtype.Text        `json:"reviewed_by"`
	ReviewedAt           pgtype.Timestamptz `json:"reviewed_at"`
	ReviewNotes          pgtype.Text        `json:"review_notes"`
	RejectionReason      pgtype.Text        `json:"rejection_reason"`
	CreatedAt            pgtype.Timestamptz `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz `json:"updated_at"`
	DuplicateOfEventID   pgtype.UUID        `json:"duplicate_of_event_id"`
	DuplicateOfEventUlid pgtype.Text        `json:"duplicate_of_event_ulid"`
}

func (FindReviewByDedupRow) GetCreatedAt

func (r FindReviewByDedupRow) GetCreatedAt() pgtype.Timestamptz

func (FindReviewByDedupRow) GetDedupHash

func (r FindReviewByDedupRow) GetDedupHash() pgtype.Text

func (FindReviewByDedupRow) GetDuplicateOfEventID

func (r FindReviewByDedupRow) GetDuplicateOfEventID() pgtype.UUID

func (FindReviewByDedupRow) GetDuplicateOfEventUlid

func (r FindReviewByDedupRow) GetDuplicateOfEventUlid() pgtype.Text

func (FindReviewByDedupRow) GetEventEndTime

func (r FindReviewByDedupRow) GetEventEndTime() pgtype.Timestamptz

func (FindReviewByDedupRow) GetEventID

func (r FindReviewByDedupRow) GetEventID() pgtype.UUID

func (FindReviewByDedupRow) GetEventStartTime

func (r FindReviewByDedupRow) GetEventStartTime() pgtype.Timestamptz

func (FindReviewByDedupRow) GetEventUlid

func (r FindReviewByDedupRow) GetEventUlid() string

func (FindReviewByDedupRow) GetID

func (r FindReviewByDedupRow) GetID() int32

Implement reviewQueueRowFields for FindReviewByDedupRow

func (FindReviewByDedupRow) GetNormalizedPayload

func (r FindReviewByDedupRow) GetNormalizedPayload() []byte

func (FindReviewByDedupRow) GetOriginalPayload

func (r FindReviewByDedupRow) GetOriginalPayload() []byte

func (FindReviewByDedupRow) GetRejectionReason

func (r FindReviewByDedupRow) GetRejectionReason() pgtype.Text

func (FindReviewByDedupRow) GetReviewNotes

func (r FindReviewByDedupRow) GetReviewNotes() pgtype.Text

func (FindReviewByDedupRow) GetReviewedAt

func (r FindReviewByDedupRow) GetReviewedAt() pgtype.Timestamptz

func (FindReviewByDedupRow) GetReviewedBy

func (r FindReviewByDedupRow) GetReviewedBy() pgtype.Text

func (FindReviewByDedupRow) GetSourceExternalID

func (r FindReviewByDedupRow) GetSourceExternalID() pgtype.Text

func (FindReviewByDedupRow) GetSourceID

func (r FindReviewByDedupRow) GetSourceID() pgtype.Text

func (FindReviewByDedupRow) GetStatus

func (r FindReviewByDedupRow) GetStatus() string

func (FindReviewByDedupRow) GetUpdatedAt

func (r FindReviewByDedupRow) GetUpdatedAt() pgtype.Timestamptz

func (FindReviewByDedupRow) GetWarnings

func (r FindReviewByDedupRow) GetWarnings() []byte

type GeocodingCache

type GeocodingCache struct {
	ID              int64              `json:"id"`
	QueryNormalized string             `json:"query_normalized"`
	CountryCodes    string             `json:"country_codes"`
	Latitude        float64            `json:"latitude"`
	Longitude       float64            `json:"longitude"`
	DisplayName     string             `json:"display_name"`
	PlaceType       string             `json:"place_type"`
	OsmID           pgtype.Int8        `json:"osm_id"`
	RawResponse     []byte             `json:"raw_response"`
	Source          string             `json:"source"`
	HitCount        int32              `json:"hit_count"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	ExpiresAt       pgtype.Timestamptz `json:"expires_at"`
}

type GeocodingCacheRepository

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

GeocodingCacheRepository manages geocoding cache operations.

func NewGeocodingCacheRepository

func NewGeocodingCacheRepository(pool *pgxpool.Pool) *GeocodingCacheRepository

NewGeocodingCacheRepository creates a new geocoding cache repository.

func (*GeocodingCacheRepository) CacheGeocode

func (r *GeocodingCacheRepository) CacheGeocode(ctx context.Context, result CachedGeocode) error

CacheGeocode stores a forward geocoding result in the cache. Uses upsert (ON CONFLICT) to update existing entries.

func (*GeocodingCacheRepository) CacheReverse

func (r *GeocodingCacheRepository) CacheReverse(ctx context.Context, result CachedReverse) error

CacheReverse stores a reverse geocoding result in the cache.

func (*GeocodingCacheRepository) GetCachedGeocode

func (r *GeocodingCacheRepository) GetCachedGeocode(ctx context.Context, queryNormalized, countryCodes string) (*CachedGeocode, error)

GetCachedGeocode retrieves a cached forward geocoding result. Returns nil if not found or expired.

func (*GeocodingCacheRepository) GetCachedReverse

func (r *GeocodingCacheRepository) GetCachedReverse(ctx context.Context, lat, lon float64) (*CachedReverse, error)

GetCachedReverse retrieves a cached reverse geocoding result. Uses ST_DWithin with 100m radius to find nearby cached results. Returns nil if not found or expired.

func (*GeocodingCacheRepository) GetRecentFailure

func (r *GeocodingCacheRepository) GetRecentFailure(ctx context.Context, queryNormalized, countryCodes string) (*CachedGeocodingFailure, error)

GetRecentFailure checks if a query has recently failed. Returns nil if no recent failure found or failure has expired.

func (*GeocodingCacheRepository) IncrementHitCount

func (r *GeocodingCacheRepository) IncrementHitCount(ctx context.Context, id int64, table string) error

IncrementHitCount increments the hit_count for a cache entry.

func (*GeocodingCacheRepository) RecordFailure

func (r *GeocodingCacheRepository) RecordFailure(ctx context.Context, queryNormalized, countryCodes, reason string) error

RecordFailure records a geocoding failure to avoid repeated failed lookups.

type GeocodingFailure

type GeocodingFailure struct {
	ID              int64              `json:"id"`
	QueryNormalized string             `json:"query_normalized"`
	CountryCodes    string             `json:"country_codes"`
	FailureReason   string             `json:"failure_reason"`
	AttemptCount    int32              `json:"attempt_count"`
	RetryAfter      pgtype.Timestamptz `json:"retry_after"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	ExpiresAt       pgtype.Timestamptz `json:"expires_at"`
}

type GetAPIKeyByPrefixRow

type GetAPIKeyByPrefixRow struct {
	ID            pgtype.UUID        `json:"id"`
	Prefix        string             `json:"prefix"`
	KeyHash       string             `json:"key_hash"`
	HashVersion   int32              `json:"hash_version"`
	Name          string             `json:"name"`
	SourceID      pgtype.UUID        `json:"source_id"`
	Role          string             `json:"role"`
	RateLimitTier string             `json:"rate_limit_tier"`
	IsActive      bool               `json:"is_active"`
	LastUsedAt    pgtype.Timestamptz `json:"last_used_at"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
}

type GetAPIKeyUsageParams

type GetAPIKeyUsageParams struct {
	ApiKeyID pgtype.UUID `json:"api_key_id"`
	Date     pgtype.Date `json:"date"`
	Date_2   pgtype.Date `json:"date_2"`
}

type GetAPIKeyUsageTotalParams

type GetAPIKeyUsageTotalParams struct {
	ApiKeyID pgtype.UUID `json:"api_key_id"`
	Date     pgtype.Date `json:"date"`
	Date_2   pgtype.Date `json:"date_2"`
}

type GetAPIKeyUsageTotalRow

type GetAPIKeyUsageTotalRow struct {
	TotalRequests int64 `json:"total_requests"`
	TotalErrors   int64 `json:"total_errors"`
}

type GetAllFieldProvenanceHistoryParams

type GetAllFieldProvenanceHistoryParams struct {
	EventID   pgtype.UUID `json:"event_id"`
	FieldPath string      `json:"field_path"`
}

type GetAllFieldProvenanceHistoryRow

type GetAllFieldProvenanceHistoryRow struct {
	ID                 pgtype.UUID        `json:"id"`
	EventID            pgtype.UUID        `json:"event_id"`
	FieldPath          string             `json:"field_path"`
	ValueHash          string             `json:"value_hash"`
	ValuePreview       pgtype.Text        `json:"value_preview"`
	SourceID           pgtype.UUID        `json:"source_id"`
	Confidence         pgtype.Numeric     `json:"confidence"`
	ObservedAt         pgtype.Timestamptz `json:"observed_at"`
	AppliedToCanonical bool               `json:"applied_to_canonical"`
	SupersededAt       pgtype.Timestamptz `json:"superseded_at"`
	SupersededByID     pgtype.UUID        `json:"superseded_by_id"`
	SourceName         string             `json:"source_name"`
	SourceType         string             `json:"source_type"`
	TrustLevel         int32              `json:"trust_level"`
	LicenseUrl         string             `json:"license_url"`
	LicenseType        string             `json:"license_type"`
}

type GetCanonicalFieldValueParams

type GetCanonicalFieldValueParams struct {
	EventID   pgtype.UUID `json:"event_id"`
	FieldPath string      `json:"field_path"`
}

type GetCanonicalFieldValueRow

type GetCanonicalFieldValueRow struct {
	ID                 pgtype.UUID        `json:"id"`
	EventID            pgtype.UUID        `json:"event_id"`
	FieldPath          string             `json:"field_path"`
	ValueHash          string             `json:"value_hash"`
	ValuePreview       pgtype.Text        `json:"value_preview"`
	SourceID           pgtype.UUID        `json:"source_id"`
	Confidence         pgtype.Numeric     `json:"confidence"`
	ObservedAt         pgtype.Timestamptz `json:"observed_at"`
	AppliedToCanonical bool               `json:"applied_to_canonical"`
	SourceName         string             `json:"source_name"`
	SourceType         string             `json:"source_type"`
	TrustLevel         int32              `json:"trust_level"`
	LicenseUrl         string             `json:"license_url"`
	LicenseType        string             `json:"license_type"`
}

type GetDailyUsageReportDataParams

type GetDailyUsageReportDataParams struct {
	Date   pgtype.Date `json:"date"`
	Date_2 pgtype.Date `json:"date_2"`
}

type GetDailyUsageReportDataRow

type GetDailyUsageReportDataRow struct {
	ApiKeyID       pgtype.UUID `json:"api_key_id"`
	KeyName        string      `json:"key_name"`
	KeyPrefix      string      `json:"key_prefix"`
	DeveloperID    pgtype.UUID `json:"developer_id"`
	DeveloperName  string      `json:"developer_name"`
	DeveloperEmail string      `json:"developer_email"`
	Date           pgtype.Date `json:"date"`
	Ip             netip.Addr  `json:"ip"`
	RequestCount   int64       `json:"request_count"`
	ErrorCount     int64       `json:"error_count"`
}

type GetDeveloperUsageTotalParams

type GetDeveloperUsageTotalParams struct {
	DeveloperID pgtype.UUID `json:"developer_id"`
	Date        pgtype.Date `json:"date"`
	Date_2      pgtype.Date `json:"date_2"`
}

type GetDeveloperUsageTotalRow

type GetDeveloperUsageTotalRow struct {
	TotalRequests int64 `json:"total_requests"`
	TotalErrors   int64 `json:"total_errors"`
}

type GetEntityIdentifiersByAuthorityParams

type GetEntityIdentifiersByAuthorityParams struct {
	EntityType    string `json:"entity_type"`
	EntityID      string `json:"entity_id"`
	AuthorityCode string `json:"authority_code"`
}

type GetEntityIdentifiersParams

type GetEntityIdentifiersParams struct {
	EntityType string `json:"entity_type"`
	EntityID   string `json:"entity_id"`
}

type GetEventByULIDRow

type GetEventByULIDRow struct {
	ID             pgtype.UUID        `json:"id"`
	Ulid           string             `json:"ulid"`
	Name           string             `json:"name"`
	Description    pgtype.Text        `json:"description"`
	LifecycleState string             `json:"lifecycle_state"`
	EventDomain    pgtype.Text        `json:"event_domain"`
	OrganizerID    pgtype.UUID        `json:"organizer_id"`
	PrimaryVenueID pgtype.UUID        `json:"primary_venue_id"`
	Keywords       []string           `json:"keywords"`
	FederationUri  pgtype.Text        `json:"federation_uri"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	UpdatedAt      pgtype.Timestamptz `json:"updated_at"`
	OccurrenceID   pgtype.UUID        `json:"occurrence_id"`
	StartTime      pgtype.Timestamptz `json:"start_time"`
	EndTime        pgtype.Timestamptz `json:"end_time"`
	Timezone       pgtype.Text        `json:"timezone"`
	VenueID        pgtype.UUID        `json:"venue_id"`
	VirtualUrl     pgtype.Text        `json:"virtual_url"`
}

type GetEventChangeByIDRow

type GetEventChangeByIDRow struct {
	ID                pgtype.UUID        `json:"id"`
	EventID           pgtype.UUID        `json:"event_id"`
	Action            string             `json:"action"`
	ChangedFields     []byte             `json:"changed_fields"`
	Snapshot          []byte             `json:"snapshot"`
	ChangedAt         pgtype.Timestamptz `json:"changed_at"`
	SequenceNumber    pgtype.Int8        `json:"sequence_number"`
	EventUlid         string             `json:"event_ulid"`
	FederationUri     pgtype.Text        `json:"federation_uri"`
	LicenseUrl        string             `json:"license_url"`
	LicenseStatus     string             `json:"license_status"`
	SourceTimestamp   pgtype.Timestamptz `json:"source_timestamp"`
	ReceivedTimestamp pgtype.Timestamptz `json:"received_timestamp"`
}

type GetEventDateRangeRow

type GetEventDateRangeRow struct {
	OldestEventDate interface{} `json:"oldest_event_date"`
	NewestEventDate interface{} `json:"newest_event_date"`
}

type GetEventSourcesRow

type GetEventSourcesRow struct {
	ID            pgtype.UUID        `json:"id"`
	EventID       pgtype.UUID        `json:"event_id"`
	SourceID      pgtype.UUID        `json:"source_id"`
	SourceUrl     string             `json:"source_url"`
	SourceEventID pgtype.Text        `json:"source_event_id"`
	RetrievedAt   pgtype.Timestamptz `json:"retrieved_at"`
	Payload       []byte             `json:"payload"`
	PayloadHash   string             `json:"payload_hash"`
	Confidence    pgtype.Numeric     `json:"confidence"`
	SourceName    string             `json:"source_name"`
	SourceType    string             `json:"source_type"`
	TrustLevel    int32              `json:"trust_level"`
	LicenseUrl    string             `json:"license_url"`
	LicenseType   string             `json:"license_type"`
}

type GetFieldProvenanceForPathsParams

type GetFieldProvenanceForPathsParams struct {
	EventID pgtype.UUID `json:"event_id"`
	Column2 []string    `json:"column_2"`
}

type GetFieldProvenanceForPathsRow

type GetFieldProvenanceForPathsRow struct {
	ID                 pgtype.UUID        `json:"id"`
	EventID            pgtype.UUID        `json:"event_id"`
	FieldPath          string             `json:"field_path"`
	ValueHash          string             `json:"value_hash"`
	ValuePreview       pgtype.Text        `json:"value_preview"`
	SourceID           pgtype.UUID        `json:"source_id"`
	Confidence         pgtype.Numeric     `json:"confidence"`
	ObservedAt         pgtype.Timestamptz `json:"observed_at"`
	AppliedToCanonical bool               `json:"applied_to_canonical"`
	SupersededAt       pgtype.Timestamptz `json:"superseded_at"`
	SupersededByID     pgtype.UUID        `json:"superseded_by_id"`
	SourceName         string             `json:"source_name"`
	SourceType         string             `json:"source_type"`
	TrustLevel         int32              `json:"trust_level"`
	LicenseUrl         string             `json:"license_url"`
	LicenseType        string             `json:"license_type"`
}

type GetFieldProvenanceRow

type GetFieldProvenanceRow struct {
	ID                 pgtype.UUID        `json:"id"`
	EventID            pgtype.UUID        `json:"event_id"`
	FieldPath          string             `json:"field_path"`
	ValueHash          string             `json:"value_hash"`
	ValuePreview       pgtype.Text        `json:"value_preview"`
	SourceID           pgtype.UUID        `json:"source_id"`
	Confidence         pgtype.Numeric     `json:"confidence"`
	ObservedAt         pgtype.Timestamptz `json:"observed_at"`
	AppliedToCanonical bool               `json:"applied_to_canonical"`
	SupersededAt       pgtype.Timestamptz `json:"superseded_at"`
	SupersededByID     pgtype.UUID        `json:"superseded_by_id"`
	SourceName         string             `json:"source_name"`
	SourceType         string             `json:"source_type"`
	TrustLevel         int32              `json:"trust_level"`
	LicenseUrl         string             `json:"license_url"`
	LicenseType        string             `json:"license_type"`
}

type GetIdempotencyKeyRow

type GetIdempotencyKeyRow struct {
	Key         string      `json:"key"`
	RequestHash string      `json:"request_hash"`
	EventID     pgtype.UUID `json:"event_id"`
	EventUlid   pgtype.Text `json:"event_ulid"`
}

type GetLatestEventChangeRow

type GetLatestEventChangeRow struct {
	SequenceNumber pgtype.Int8        `json:"sequence_number"`
	ChangedAt      pgtype.Timestamptz `json:"changed_at"`
}

type GetOccurrenceByIDParams

type GetOccurrenceByIDParams struct {
	ID      pgtype.UUID `json:"id"`
	EventID pgtype.UUID `json:"event_id"`
}

type GetOccurrenceByIDRow

type GetOccurrenceByIDRow struct {
	ID            pgtype.UUID        `json:"id"`
	EventID       pgtype.UUID        `json:"event_id"`
	StartTime     pgtype.Timestamptz `json:"start_time"`
	EndTime       pgtype.Timestamptz `json:"end_time"`
	Timezone      string             `json:"timezone"`
	DoorTime      pgtype.Timestamptz `json:"door_time"`
	VenueID       pgtype.UUID        `json:"venue_id"`
	VenueUlid     pgtype.Text        `json:"venue_ulid"`
	VirtualUrl    pgtype.Text        `json:"virtual_url"`
	TicketUrl     pgtype.Text        `json:"ticket_url"`
	PriceMin      pgtype.Numeric     `json:"price_min"`
	PriceMax      pgtype.Numeric     `json:"price_max"`
	PriceCurrency pgtype.Text        `json:"price_currency"`
	Availability  pgtype.Text        `json:"availability"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

type GetOrganizationByULIDRow

type GetOrganizationByULIDRow struct {
	Organization Organization `json:"organization"`
}

type GetPendingReviewByEventUlidAndDuplicateUlidParams

type GetPendingReviewByEventUlidAndDuplicateUlidParams struct {
	EventUlid     string `json:"event_ulid"`
	DuplicateUlid string `json:"duplicate_ulid"`
}

type GetPendingReviewByEventUlidAndDuplicateUlidRow

type GetPendingReviewByEventUlidAndDuplicateUlidRow struct {
	ID                   int32              `json:"id"`
	EventID              pgtype.UUID        `json:"event_id"`
	EventUlid            string             `json:"event_ulid"`
	OriginalPayload      []byte             `json:"original_payload"`
	NormalizedPayload    []byte             `json:"normalized_payload"`
	Warnings             []byte             `json:"warnings"`
	SourceID             pgtype.Text        `json:"source_id"`
	SourceExternalID     pgtype.Text        `json:"source_external_id"`
	DedupHash            pgtype.Text        `json:"dedup_hash"`
	EventStartTime       pgtype.Timestamptz `json:"event_start_time"`
	EventEndTime         pgtype.Timestamptz `json:"event_end_time"`
	Status               string             `json:"status"`
	ReviewedBy           pgtype.Text        `json:"reviewed_by"`
	ReviewedAt           pgtype.Timestamptz `json:"reviewed_at"`
	ReviewNotes          pgtype.Text        `json:"review_notes"`
	RejectionReason      pgtype.Text        `json:"rejection_reason"`
	CreatedAt            pgtype.Timestamptz `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz `json:"updated_at"`
	DuplicateOfEventID   pgtype.UUID        `json:"duplicate_of_event_id"`
	DuplicateOfEventUlid pgtype.Text        `json:"duplicate_of_event_ulid"`
}

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetCreatedAt

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetDedupHash

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetDuplicateOfEventID

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetDuplicateOfEventUlid

func (r GetPendingReviewByEventUlidAndDuplicateUlidRow) GetDuplicateOfEventUlid() pgtype.Text

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetEventEndTime

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetEventID

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetEventStartTime

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetEventUlid

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetID

Implement reviewQueueRowFields for GetPendingReviewByEventUlidAndDuplicateUlidRow

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetNormalizedPayload

func (r GetPendingReviewByEventUlidAndDuplicateUlidRow) GetNormalizedPayload() []byte

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetOriginalPayload

func (r GetPendingReviewByEventUlidAndDuplicateUlidRow) GetOriginalPayload() []byte

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetRejectionReason

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetReviewNotes

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetReviewedAt

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetReviewedBy

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetSourceExternalID

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetSourceID

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetStatus

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetUpdatedAt

func (GetPendingReviewByEventUlidAndDuplicateUlidRow) GetWarnings

type GetPendingReviewByEventUlidRow

type GetPendingReviewByEventUlidRow struct {
	ID                   int32              `json:"id"`
	EventID              pgtype.UUID        `json:"event_id"`
	EventUlid            string             `json:"event_ulid"`
	OriginalPayload      []byte             `json:"original_payload"`
	NormalizedPayload    []byte             `json:"normalized_payload"`
	Warnings             []byte             `json:"warnings"`
	SourceID             pgtype.Text        `json:"source_id"`
	SourceExternalID     pgtype.Text        `json:"source_external_id"`
	DedupHash            pgtype.Text        `json:"dedup_hash"`
	EventStartTime       pgtype.Timestamptz `json:"event_start_time"`
	EventEndTime         pgtype.Timestamptz `json:"event_end_time"`
	Status               string             `json:"status"`
	ReviewedBy           pgtype.Text        `json:"reviewed_by"`
	ReviewedAt           pgtype.Timestamptz `json:"reviewed_at"`
	ReviewNotes          pgtype.Text        `json:"review_notes"`
	RejectionReason      pgtype.Text        `json:"rejection_reason"`
	CreatedAt            pgtype.Timestamptz `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz `json:"updated_at"`
	DuplicateOfEventID   pgtype.UUID        `json:"duplicate_of_event_id"`
	DuplicateOfEventUlid pgtype.Text        `json:"duplicate_of_event_ulid"`
}

func (GetPendingReviewByEventUlidRow) GetCreatedAt

func (GetPendingReviewByEventUlidRow) GetDedupHash

func (r GetPendingReviewByEventUlidRow) GetDedupHash() pgtype.Text

func (GetPendingReviewByEventUlidRow) GetDuplicateOfEventID

func (r GetPendingReviewByEventUlidRow) GetDuplicateOfEventID() pgtype.UUID

func (GetPendingReviewByEventUlidRow) GetDuplicateOfEventUlid

func (r GetPendingReviewByEventUlidRow) GetDuplicateOfEventUlid() pgtype.Text

func (GetPendingReviewByEventUlidRow) GetEventEndTime

func (GetPendingReviewByEventUlidRow) GetEventID

func (GetPendingReviewByEventUlidRow) GetEventStartTime

func (r GetPendingReviewByEventUlidRow) GetEventStartTime() pgtype.Timestamptz

func (GetPendingReviewByEventUlidRow) GetEventUlid

func (r GetPendingReviewByEventUlidRow) GetEventUlid() string

func (GetPendingReviewByEventUlidRow) GetID

Implement reviewQueueRowFields for GetPendingReviewByEventUlidRow

func (GetPendingReviewByEventUlidRow) GetNormalizedPayload

func (r GetPendingReviewByEventUlidRow) GetNormalizedPayload() []byte

func (GetPendingReviewByEventUlidRow) GetOriginalPayload

func (r GetPendingReviewByEventUlidRow) GetOriginalPayload() []byte

func (GetPendingReviewByEventUlidRow) GetRejectionReason

func (r GetPendingReviewByEventUlidRow) GetRejectionReason() pgtype.Text

func (GetPendingReviewByEventUlidRow) GetReviewNotes

func (r GetPendingReviewByEventUlidRow) GetReviewNotes() pgtype.Text

func (GetPendingReviewByEventUlidRow) GetReviewedAt

func (GetPendingReviewByEventUlidRow) GetReviewedBy

func (r GetPendingReviewByEventUlidRow) GetReviewedBy() pgtype.Text

func (GetPendingReviewByEventUlidRow) GetSourceExternalID

func (r GetPendingReviewByEventUlidRow) GetSourceExternalID() pgtype.Text

func (GetPendingReviewByEventUlidRow) GetSourceID

func (r GetPendingReviewByEventUlidRow) GetSourceID() pgtype.Text

func (GetPendingReviewByEventUlidRow) GetStatus

func (r GetPendingReviewByEventUlidRow) GetStatus() string

func (GetPendingReviewByEventUlidRow) GetUpdatedAt

func (GetPendingReviewByEventUlidRow) GetWarnings

func (r GetPendingReviewByEventUlidRow) GetWarnings() []byte

type GetPlaceByULIDRow

type GetPlaceByULIDRow struct {
	Place Place `json:"place"`
}

type GetRecentSubmissionByURLNormParams

type GetRecentSubmissionByURLNormParams struct {
	UrlNorm  string          `json:"url_norm"`
	Interval pgtype.Interval `json:"interval"`
}

type GetReconciliationCacheParams

type GetReconciliationCacheParams struct {
	EntityType    string `json:"entity_type"`
	AuthorityCode string `json:"authority_code"`
	LookupKey     string `json:"lookup_key"`
}

type GetReviewQueueEntryRow

type GetReviewQueueEntryRow struct {
	ID                   int32              `json:"id"`
	EventID              pgtype.UUID        `json:"event_id"`
	EventUlid            string             `json:"event_ulid"`
	OriginalPayload      []byte             `json:"original_payload"`
	NormalizedPayload    []byte             `json:"normalized_payload"`
	Warnings             []byte             `json:"warnings"`
	SourceID             pgtype.Text        `json:"source_id"`
	SourceExternalID     pgtype.Text        `json:"source_external_id"`
	DedupHash            pgtype.Text        `json:"dedup_hash"`
	EventStartTime       pgtype.Timestamptz `json:"event_start_time"`
	EventEndTime         pgtype.Timestamptz `json:"event_end_time"`
	Status               string             `json:"status"`
	ReviewedBy           pgtype.Text        `json:"reviewed_by"`
	ReviewedAt           pgtype.Timestamptz `json:"reviewed_at"`
	ReviewNotes          pgtype.Text        `json:"review_notes"`
	RejectionReason      pgtype.Text        `json:"rejection_reason"`
	CreatedAt            pgtype.Timestamptz `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz `json:"updated_at"`
	DuplicateOfEventID   pgtype.UUID        `json:"duplicate_of_event_id"`
	DuplicateOfEventUlid pgtype.Text        `json:"duplicate_of_event_ulid"`
}

func (GetReviewQueueEntryRow) GetCreatedAt

func (r GetReviewQueueEntryRow) GetCreatedAt() pgtype.Timestamptz

func (GetReviewQueueEntryRow) GetDedupHash

func (r GetReviewQueueEntryRow) GetDedupHash() pgtype.Text

func (GetReviewQueueEntryRow) GetDuplicateOfEventID

func (r GetReviewQueueEntryRow) GetDuplicateOfEventID() pgtype.UUID

func (GetReviewQueueEntryRow) GetDuplicateOfEventUlid

func (r GetReviewQueueEntryRow) GetDuplicateOfEventUlid() pgtype.Text

func (GetReviewQueueEntryRow) GetEventEndTime

func (r GetReviewQueueEntryRow) GetEventEndTime() pgtype.Timestamptz

func (GetReviewQueueEntryRow) GetEventID

func (r GetReviewQueueEntryRow) GetEventID() pgtype.UUID

func (GetReviewQueueEntryRow) GetEventStartTime

func (r GetReviewQueueEntryRow) GetEventStartTime() pgtype.Timestamptz

func (GetReviewQueueEntryRow) GetEventUlid

func (r GetReviewQueueEntryRow) GetEventUlid() string

func (GetReviewQueueEntryRow) GetID

func (r GetReviewQueueEntryRow) GetID() int32

Implement reviewQueueRowFields for GetReviewQueueEntryRow

func (GetReviewQueueEntryRow) GetNormalizedPayload

func (r GetReviewQueueEntryRow) GetNormalizedPayload() []byte

func (GetReviewQueueEntryRow) GetOriginalPayload

func (r GetReviewQueueEntryRow) GetOriginalPayload() []byte

func (GetReviewQueueEntryRow) GetRejectionReason

func (r GetReviewQueueEntryRow) GetRejectionReason() pgtype.Text

func (GetReviewQueueEntryRow) GetReviewNotes

func (r GetReviewQueueEntryRow) GetReviewNotes() pgtype.Text

func (GetReviewQueueEntryRow) GetReviewedAt

func (r GetReviewQueueEntryRow) GetReviewedAt() pgtype.Timestamptz

func (GetReviewQueueEntryRow) GetReviewedBy

func (r GetReviewQueueEntryRow) GetReviewedBy() pgtype.Text

func (GetReviewQueueEntryRow) GetSourceExternalID

func (r GetReviewQueueEntryRow) GetSourceExternalID() pgtype.Text

func (GetReviewQueueEntryRow) GetSourceID

func (r GetReviewQueueEntryRow) GetSourceID() pgtype.Text

func (GetReviewQueueEntryRow) GetStatus

func (r GetReviewQueueEntryRow) GetStatus() string

func (GetReviewQueueEntryRow) GetUpdatedAt

func (r GetReviewQueueEntryRow) GetUpdatedAt() pgtype.Timestamptz

func (GetReviewQueueEntryRow) GetWarnings

func (r GetReviewQueueEntryRow) GetWarnings() []byte

type GetScraperSourceByIDRow

type GetScraperSourceByIDRow struct {
	ScraperSource ScraperSource `json:"scraper_source"`
}

type GetScraperSourceByNameRow

type GetScraperSourceByNameRow struct {
	ScraperSource ScraperSource `json:"scraper_source"`
}

type GetSourceByIDRow

type GetSourceByIDRow struct {
	ID          pgtype.UUID        `json:"id"`
	Name        string             `json:"name"`
	SourceType  string             `json:"source_type"`
	BaseUrl     pgtype.Text        `json:"base_url"`
	TrustLevel  int32              `json:"trust_level"`
	LicenseUrl  string             `json:"license_url"`
	LicenseType string             `json:"license_type"`
	IsActive    pgtype.Bool        `json:"is_active"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
}

type GetSourcesByEventIDRow

type GetSourcesByEventIDRow struct {
	ID          pgtype.UUID `json:"id"`
	Name        string      `json:"name"`
	SourceType  string      `json:"source_type"`
	BaseUrl     pgtype.Text `json:"base_url"`
	TrustLevel  int32       `json:"trust_level"`
	LicenseUrl  string      `json:"license_url"`
	LicenseType string      `json:"license_type"`
	IsActive    pgtype.Bool `json:"is_active"`
}

type GetUserByEmailRow

type GetUserByEmailRow struct {
	ID           pgtype.UUID        `json:"id"`
	Username     string             `json:"username"`
	Email        string             `json:"email"`
	PasswordHash string             `json:"password_hash"`
	Role         string             `json:"role"`
	IsActive     bool               `json:"is_active"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	LastLoginAt  pgtype.Timestamptz `json:"last_login_at"`
}

type GetUserByIDRow

type GetUserByIDRow struct {
	ID           pgtype.UUID        `json:"id"`
	Username     string             `json:"username"`
	Email        string             `json:"email"`
	PasswordHash string             `json:"password_hash"`
	Role         string             `json:"role"`
	IsActive     bool               `json:"is_active"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	LastLoginAt  pgtype.Timestamptz `json:"last_login_at"`
}

type GetUserByUsernameRow

type GetUserByUsernameRow struct {
	ID           pgtype.UUID        `json:"id"`
	Username     string             `json:"username"`
	Email        string             `json:"email"`
	PasswordHash string             `json:"password_hash"`
	Role         string             `json:"role"`
	IsActive     bool               `json:"is_active"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	LastLoginAt  pgtype.Timestamptz `json:"last_login_at"`
}

type IdempotencyKey

type IdempotencyKey struct {
	Key         string             `json:"key"`
	RequestHash string             `json:"request_hash"`
	EventID     pgtype.UUID        `json:"event_id"`
	EventUlid   pgtype.Text        `json:"event_ulid"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	ExpiresAt   pgtype.Timestamptz `json:"expires_at"`
}

type InsertEventSourceParams

type InsertEventSourceParams struct {
	EventID       pgtype.UUID        `json:"event_id"`
	SourceID      pgtype.UUID        `json:"source_id"`
	SourceUrl     string             `json:"source_url"`
	SourceEventID pgtype.Text        `json:"source_event_id"`
	RetrievedAt   pgtype.Timestamptz `json:"retrieved_at"`
	Payload       []byte             `json:"payload"`
	PayloadHash   string             `json:"payload_hash"`
	Confidence    pgtype.Numeric     `json:"confidence"`
}

type InsertFieldProvenanceParams

type InsertFieldProvenanceParams struct {
	EventID            pgtype.UUID        `json:"event_id"`
	FieldPath          string             `json:"field_path"`
	ValueHash          string             `json:"value_hash"`
	ValuePreview       pgtype.Text        `json:"value_preview"`
	SourceID           pgtype.UUID        `json:"source_id"`
	Confidence         pgtype.Numeric     `json:"confidence"`
	ObservedAt         pgtype.Timestamptz `json:"observed_at"`
	AppliedToCanonical bool               `json:"applied_to_canonical"`
}

type InsertIdempotencyKeyParams

type InsertIdempotencyKeyParams struct {
	Key         string      `json:"key"`
	RequestHash string      `json:"request_hash"`
	EventID     pgtype.UUID `json:"event_id"`
	EventUlid   pgtype.Text `json:"event_ulid"`
}

type InsertIdempotencyKeyRow

type InsertIdempotencyKeyRow struct {
	Key         string      `json:"key"`
	RequestHash string      `json:"request_hash"`
	EventID     pgtype.UUID `json:"event_id"`
	EventUlid   pgtype.Text `json:"event_ulid"`
}

type InsertNotDuplicateParams

type InsertNotDuplicateParams struct {
	EventIDA  interface{} `json:"event_id_a"`
	EventIDB  interface{} `json:"event_id_b"`
	CreatedBy pgtype.Text `json:"created_by"`
}

type InsertOccurrenceParams

type InsertOccurrenceParams struct {
	EventID       pgtype.UUID        `json:"event_id"`
	StartTime     pgtype.Timestamptz `json:"start_time"`
	EndTime       pgtype.Timestamptz `json:"end_time"`
	Timezone      string             `json:"timezone"`
	DoorTime      pgtype.Timestamptz `json:"door_time"`
	VenueID       pgtype.UUID        `json:"venue_id"`
	VirtualUrl    pgtype.Text        `json:"virtual_url"`
	TicketUrl     pgtype.Text        `json:"ticket_url"`
	PriceMin      pgtype.Numeric     `json:"price_min"`
	PriceMax      pgtype.Numeric     `json:"price_max"`
	PriceCurrency interface{}        `json:"price_currency"`
	Availability  interface{}        `json:"availability"`
}

type InsertOccurrenceRow

type InsertOccurrenceRow struct {
	ID            pgtype.UUID        `json:"id"`
	EventID       pgtype.UUID        `json:"event_id"`
	StartTime     pgtype.Timestamptz `json:"start_time"`
	EndTime       pgtype.Timestamptz `json:"end_time"`
	Timezone      string             `json:"timezone"`
	DoorTime      pgtype.Timestamptz `json:"door_time"`
	VenueID       pgtype.UUID        `json:"venue_id"`
	VirtualUrl    pgtype.Text        `json:"virtual_url"`
	TicketUrl     pgtype.Text        `json:"ticket_url"`
	PriceMin      pgtype.Numeric     `json:"price_min"`
	PriceMax      pgtype.Numeric     `json:"price_max"`
	PriceCurrency pgtype.Text        `json:"price_currency"`
	Availability  pgtype.Text        `json:"availability"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
	VenueUlid     string             `json:"venue_ulid"`
}

type InsertScraperRunParams

type InsertScraperRunParams struct {
	SourceName string `json:"source_name"`
	SourceUrl  string `json:"source_url"`
	Tier       int32  `json:"tier"`
}

type InsertScraperSubmissionParams

type InsertScraperSubmissionParams struct {
	Url         string     `json:"url"`
	UrlNorm     string     `json:"url_norm"`
	SubmitterIp netip.Addr `json:"submitter_ip"`
}

type IsNotDuplicateParams

type IsNotDuplicateParams struct {
	EventIDA string `json:"event_id_a"`
	EventIDB string `json:"event_id_b"`
}

type KnowledgeGraphAuthority

type KnowledgeGraphAuthority struct {
	ID                     int32              `json:"id"`
	AuthorityCode          string             `json:"authority_code"`
	AuthorityName          string             `json:"authority_name"`
	BaseUriPattern         string             `json:"base_uri_pattern"`
	ReconciliationEndpoint pgtype.Text        `json:"reconciliation_endpoint"`
	ApplicableDomains      []string           `json:"applicable_domains"`
	TrustLevel             int32              `json:"trust_level"`
	PriorityOrder          int32              `json:"priority_order"`
	RateLimitPerMinute     int32              `json:"rate_limit_per_minute"`
	RateLimitPerDay        int32              `json:"rate_limit_per_day"`
	IsActive               bool               `json:"is_active"`
	DocumentationUrl       pgtype.Text        `json:"documentation_url"`
	CreatedAt              pgtype.Timestamptz `json:"created_at"`
	UpdatedAt              pgtype.Timestamptz `json:"updated_at"`
}

type LinkOrgScraperSourceParams

type LinkOrgScraperSourceParams struct {
	OrganizationID  pgtype.UUID `json:"organization_id"`
	ScraperSourceID int64       `json:"scraper_source_id"`
}

type LinkPlaceScraperSourceParams

type LinkPlaceScraperSourceParams struct {
	PlaceID         pgtype.UUID `json:"place_id"`
	ScraperSourceID int64       `json:"scraper_source_id"`
}

type ListAPIKeysRow

type ListAPIKeysRow struct {
	ID            pgtype.UUID        `json:"id"`
	Prefix        string             `json:"prefix"`
	Name          string             `json:"name"`
	SourceID      pgtype.UUID        `json:"source_id"`
	Role          string             `json:"role"`
	RateLimitTier string             `json:"rate_limit_tier"`
	IsActive      bool               `json:"is_active"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	LastUsedAt    pgtype.Timestamptz `json:"last_used_at"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
}

type ListDevelopersParams

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

type ListEventChangesParams

type ListEventChangesParams struct {
	AfterSequence  pgtype.Int8        `json:"after_sequence"`
	AfterTimestamp pgtype.Timestamptz `json:"after_timestamp"`
	Action         pgtype.Text        `json:"action"`
	Limit          int32              `json:"limit"`
}

type ListEventChangesRow

type ListEventChangesRow struct {
	ID                   pgtype.UUID        `json:"id"`
	EventID              pgtype.UUID        `json:"event_id"`
	Action               string             `json:"action"`
	ChangedFields        []byte             `json:"changed_fields"`
	Snapshot             []byte             `json:"snapshot"`
	ChangedAt            pgtype.Timestamptz `json:"changed_at"`
	SequenceNumber       pgtype.Int8        `json:"sequence_number"`
	EventUlid            string             `json:"event_ulid"`
	FederationUri        pgtype.Text        `json:"federation_uri"`
	LicenseUrl           string             `json:"license_url"`
	LicenseStatus        string             `json:"license_status"`
	SourceTimestamp      pgtype.Timestamptz `json:"source_timestamp"`
	ReceivedTimestamp    pgtype.Timestamptz `json:"received_timestamp"`
	OccurrenceStartTime  pgtype.Timestamptz `json:"occurrence_start_time"`
	OccurrenceEndTime    pgtype.Timestamptz `json:"occurrence_end_time"`
	VenueName            pgtype.Text        `json:"venue_name"`
	VenueStreetAddress   pgtype.Text        `json:"venue_street_address"`
	VenueAddressLocality pgtype.Text        `json:"venue_address_locality"`
	VenueAddressRegion   pgtype.Text        `json:"venue_address_region"`
	VenueAddressCountry  pgtype.Text        `json:"venue_address_country"`
}

type ListEventTombstonesParams

type ListEventTombstonesParams struct {
	AfterTimestamp pgtype.Timestamptz `json:"after_timestamp"`
	Limit          int32              `json:"limit"`
}

type ListFederationNodesParams

type ListFederationNodesParams struct {
	FederationStatus interface{} `json:"federation_status"`
	SyncEnabled      pgtype.Bool `json:"sync_enabled"`
	IsOnline         pgtype.Bool `json:"is_online"`
	Limit            int32       `json:"limit"`
}

type ListOrganizationsByCreatedAtDescParams

type ListOrganizationsByCreatedAtDescParams struct {
	City            pgtype.Text        `json:"city"`
	Query           pgtype.Text        `json:"query"`
	CursorTimestamp pgtype.Timestamptz `json:"cursor_timestamp"`
	CursorUlid      pgtype.Text        `json:"cursor_ulid"`
	Limit           int32              `json:"limit"`
}

type ListOrganizationsByCreatedAtDescRow

type ListOrganizationsByCreatedAtDescRow struct {
	Organization Organization `json:"organization"`
}

type ListOrganizationsByCreatedAtParams

type ListOrganizationsByCreatedAtParams struct {
	City            pgtype.Text        `json:"city"`
	Query           pgtype.Text        `json:"query"`
	CursorTimestamp pgtype.Timestamptz `json:"cursor_timestamp"`
	CursorUlid      pgtype.Text        `json:"cursor_ulid"`
	Limit           int32              `json:"limit"`
}

type ListOrganizationsByCreatedAtRow

type ListOrganizationsByCreatedAtRow struct {
	Organization Organization `json:"organization"`
}

type ListOrganizationsByNameDescParams

type ListOrganizationsByNameDescParams struct {
	City       pgtype.Text `json:"city"`
	Query      pgtype.Text `json:"query"`
	CursorName pgtype.Text `json:"cursor_name"`
	CursorUlid pgtype.Text `json:"cursor_ulid"`
	Limit      int32       `json:"limit"`
}

type ListOrganizationsByNameDescRow

type ListOrganizationsByNameDescRow struct {
	Organization Organization `json:"organization"`
}

type ListOrganizationsByNameParams

type ListOrganizationsByNameParams struct {
	City       pgtype.Text `json:"city"`
	Query      pgtype.Text `json:"query"`
	CursorName pgtype.Text `json:"cursor_name"`
	CursorUlid pgtype.Text `json:"cursor_ulid"`
	Limit      int32       `json:"limit"`
}

type ListOrganizationsByNameRow

type ListOrganizationsByNameRow struct {
	Organization Organization `json:"organization"`
}

type ListPendingInvitationsForUserRow

type ListPendingInvitationsForUserRow struct {
	ID        pgtype.UUID        `json:"id"`
	TokenHash string             `json:"token_hash"`
	Email     string             `json:"email"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type ListPlacesByCreatedAtDescParams

type ListPlacesByCreatedAtDescParams struct {
	City            pgtype.Text        `json:"city"`
	Query           pgtype.Text        `json:"query"`
	CursorTimestamp pgtype.Timestamptz `json:"cursor_timestamp"`
	CursorUlid      pgtype.Text        `json:"cursor_ulid"`
	Limit           int32              `json:"limit"`
}

type ListPlacesByCreatedAtDescRow

type ListPlacesByCreatedAtDescRow struct {
	Place Place `json:"place"`
}

type ListPlacesByCreatedAtParams

type ListPlacesByCreatedAtParams struct {
	City            pgtype.Text        `json:"city"`
	Query           pgtype.Text        `json:"query"`
	CursorTimestamp pgtype.Timestamptz `json:"cursor_timestamp"`
	CursorUlid      pgtype.Text        `json:"cursor_ulid"`
	Limit           int32              `json:"limit"`
}

type ListPlacesByCreatedAtRow

type ListPlacesByCreatedAtRow struct {
	Place Place `json:"place"`
}

type ListPlacesByNameDescParams

type ListPlacesByNameDescParams struct {
	City       pgtype.Text `json:"city"`
	Query      pgtype.Text `json:"query"`
	CursorName pgtype.Text `json:"cursor_name"`
	CursorUlid pgtype.Text `json:"cursor_ulid"`
	Limit      int32       `json:"limit"`
}

type ListPlacesByNameDescRow

type ListPlacesByNameDescRow struct {
	Place Place `json:"place"`
}

type ListPlacesByNameParams

type ListPlacesByNameParams struct {
	City       pgtype.Text `json:"city"`
	Query      pgtype.Text `json:"query"`
	CursorName pgtype.Text `json:"cursor_name"`
	CursorUlid pgtype.Text `json:"cursor_ulid"`
	Limit      int32       `json:"limit"`
}

type ListPlacesByNameRow

type ListPlacesByNameRow struct {
	Place Place `json:"place"`
}

type ListRecentScraperRunsFilteredParams

type ListRecentScraperRunsFilteredParams struct {
	StatusFilter pgtype.Text `json:"status_filter"`
	SourceFilter pgtype.Text `json:"source_filter"`
	Limit        int32       `json:"limit"`
}

type ListReviewQueueParams

type ListReviewQueueParams struct {
	Status  pgtype.Text `json:"status"`
	AfterID pgtype.Int4 `json:"after_id"`
	Limit   int32       `json:"limit"`
}

type ListReviewQueueRow

type ListReviewQueueRow struct {
	ID                   int32              `json:"id"`
	EventID              pgtype.UUID        `json:"event_id"`
	EventUlid            string             `json:"event_ulid"`
	OriginalPayload      []byte             `json:"original_payload"`
	NormalizedPayload    []byte             `json:"normalized_payload"`
	Warnings             []byte             `json:"warnings"`
	SourceID             pgtype.Text        `json:"source_id"`
	SourceExternalID     pgtype.Text        `json:"source_external_id"`
	DedupHash            pgtype.Text        `json:"dedup_hash"`
	EventStartTime       pgtype.Timestamptz `json:"event_start_time"`
	EventEndTime         pgtype.Timestamptz `json:"event_end_time"`
	Status               string             `json:"status"`
	ReviewedBy           pgtype.Text        `json:"reviewed_by"`
	ReviewedAt           pgtype.Timestamptz `json:"reviewed_at"`
	ReviewNotes          pgtype.Text        `json:"review_notes"`
	RejectionReason      pgtype.Text        `json:"rejection_reason"`
	CreatedAt            pgtype.Timestamptz `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz `json:"updated_at"`
	DuplicateOfEventID   pgtype.UUID        `json:"duplicate_of_event_id"`
	DuplicateOfEventUlid pgtype.Text        `json:"duplicate_of_event_ulid"`
}

func (ListReviewQueueRow) GetCreatedAt

func (r ListReviewQueueRow) GetCreatedAt() pgtype.Timestamptz

func (ListReviewQueueRow) GetDedupHash

func (r ListReviewQueueRow) GetDedupHash() pgtype.Text

func (ListReviewQueueRow) GetDuplicateOfEventID

func (r ListReviewQueueRow) GetDuplicateOfEventID() pgtype.UUID

func (ListReviewQueueRow) GetDuplicateOfEventUlid

func (r ListReviewQueueRow) GetDuplicateOfEventUlid() pgtype.Text

func (ListReviewQueueRow) GetEventEndTime

func (r ListReviewQueueRow) GetEventEndTime() pgtype.Timestamptz

func (ListReviewQueueRow) GetEventID

func (r ListReviewQueueRow) GetEventID() pgtype.UUID

func (ListReviewQueueRow) GetEventStartTime

func (r ListReviewQueueRow) GetEventStartTime() pgtype.Timestamptz

func (ListReviewQueueRow) GetEventUlid

func (r ListReviewQueueRow) GetEventUlid() string

func (ListReviewQueueRow) GetID

func (r ListReviewQueueRow) GetID() int32

Implement reviewQueueRowFields for ListReviewQueueRow

func (ListReviewQueueRow) GetNormalizedPayload

func (r ListReviewQueueRow) GetNormalizedPayload() []byte

func (ListReviewQueueRow) GetOriginalPayload

func (r ListReviewQueueRow) GetOriginalPayload() []byte

func (ListReviewQueueRow) GetRejectionReason

func (r ListReviewQueueRow) GetRejectionReason() pgtype.Text

func (ListReviewQueueRow) GetReviewNotes

func (r ListReviewQueueRow) GetReviewNotes() pgtype.Text

func (ListReviewQueueRow) GetReviewedAt

func (r ListReviewQueueRow) GetReviewedAt() pgtype.Timestamptz

func (ListReviewQueueRow) GetReviewedBy

func (r ListReviewQueueRow) GetReviewedBy() pgtype.Text

func (ListReviewQueueRow) GetSourceExternalID

func (r ListReviewQueueRow) GetSourceExternalID() pgtype.Text

func (ListReviewQueueRow) GetSourceID

func (r ListReviewQueueRow) GetSourceID() pgtype.Text

func (ListReviewQueueRow) GetStatus

func (r ListReviewQueueRow) GetStatus() string

func (ListReviewQueueRow) GetUpdatedAt

func (r ListReviewQueueRow) GetUpdatedAt() pgtype.Timestamptz

func (ListReviewQueueRow) GetWarnings

func (r ListReviewQueueRow) GetWarnings() []byte

type ListScraperRunsBySourceParams

type ListScraperRunsBySourceParams struct {
	SourceName string `json:"source_name"`
	Limit      int32  `json:"limit"`
}

type ListScraperSourcesByOrgRow

type ListScraperSourcesByOrgRow struct {
	ScraperSource ScraperSource `json:"scraper_source"`
}

type ListScraperSourcesByPlaceRow

type ListScraperSourcesByPlaceRow struct {
	ScraperSource ScraperSource `json:"scraper_source"`
}

type ListScraperSourcesRow

type ListScraperSourcesRow struct {
	ScraperSource ScraperSource `json:"scraper_source"`
}

type ListScraperSourcesWithLatestRunRow

type ListScraperSourcesWithLatestRunRow struct {
	ScraperSource       ScraperSource      `json:"scraper_source"`
	LastRunStartedAt    pgtype.Timestamptz `json:"last_run_started_at"`
	LastRunCompletedAt  pgtype.Timestamptz `json:"last_run_completed_at"`
	LastRunStatus       string             `json:"last_run_status"`
	LastRunEventsFound  int32              `json:"last_run_events_found"`
	LastRunEventsNew    int32              `json:"last_run_events_new"`
	LastRunEventsDup    int32              `json:"last_run_events_dup"`
	LastRunEventsFailed int32              `json:"last_run_events_failed"`
	LastRunErrorMessage pgtype.Text        `json:"last_run_error_message"`
}

type ListScraperSubmissionsParams

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

type ListUnreconciledOrganizationsRow

type ListUnreconciledOrganizationsRow struct {
	Ulid            string      `json:"ulid"`
	Name            string      `json:"name"`
	LegalName       pgtype.Text `json:"legal_name"`
	Url             pgtype.Text `json:"url"`
	AddressLocality pgtype.Text `json:"address_locality"`
	AddressRegion   pgtype.Text `json:"address_region"`
	PostalCode      pgtype.Text `json:"postal_code"`
	AddressCountry  pgtype.Text `json:"address_country"`
}

type ListUnreconciledPlacesRow

type ListUnreconciledPlacesRow struct {
	Ulid            string      `json:"ulid"`
	Name            string      `json:"name"`
	StreetAddress   pgtype.Text `json:"street_address"`
	AddressLocality pgtype.Text `json:"address_locality"`
	AddressRegion   pgtype.Text `json:"address_region"`
	PostalCode      pgtype.Text `json:"postal_code"`
	AddressCountry  pgtype.Text `json:"address_country"`
	Url             pgtype.Text `json:"url"`
}

type ListUsersRow

type ListUsersRow struct {
	ID          pgtype.UUID        `json:"id"`
	Username    string             `json:"username"`
	Email       string             `json:"email"`
	Role        string             `json:"role"`
	IsActive    bool               `json:"is_active"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	LastLoginAt pgtype.Timestamptz `json:"last_login_at"`
}

type ListUsersWithFiltersParams

type ListUsersWithFiltersParams struct {
	IsActive pgtype.Bool `json:"is_active"`
	Role     pgtype.Text `json:"role"`
	Offset   int32       `json:"offset"`
	Limit    int32       `json:"limit"`
}

type ListUsersWithFiltersRow

type ListUsersWithFiltersRow struct {
	ID           pgtype.UUID        `json:"id"`
	Username     string             `json:"username"`
	Email        string             `json:"email"`
	Role         string             `json:"role"`
	IsActive     bool               `json:"is_active"`
	PasswordHash string             `json:"password_hash"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	LastLoginAt  pgtype.Timestamptz `json:"last_login_at"`
}

type MergeEventIntoDuplicateParams

type MergeEventIntoDuplicateParams struct {
	Ulid   string `json:"ulid"`
	Ulid_2 string `json:"ulid_2"`
}

type OrgScraperSource

type OrgScraperSource struct {
	OrganizationID  pgtype.UUID `json:"organization_id"`
	ScraperSourceID int64       `json:"scraper_source_id"`
}

type Organization

type Organization struct {
	ID               pgtype.UUID        `json:"id"`
	Ulid             string             `json:"ulid"`
	Name             string             `json:"name"`
	LegalName        pgtype.Text        `json:"legal_name"`
	AlternateName    pgtype.Text        `json:"alternate_name"`
	Description      pgtype.Text        `json:"description"`
	Email            pgtype.Text        `json:"email"`
	Telephone        pgtype.Text        `json:"telephone"`
	Url              pgtype.Text        `json:"url"`
	StreetAddress    pgtype.Text        `json:"street_address"`
	AddressLocality  pgtype.Text        `json:"address_locality"`
	AddressRegion    pgtype.Text        `json:"address_region"`
	PostalCode       pgtype.Text        `json:"postal_code"`
	AddressCountry   pgtype.Text        `json:"address_country"`
	OrganizationType pgtype.Text        `json:"organization_type"`
	FoundingDate     pgtype.Date        `json:"founding_date"`
	OriginNodeID     pgtype.UUID        `json:"origin_node_id"`
	Confidence       pgtype.Numeric     `json:"confidence"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz `json:"updated_at"`
	DeletedAt        pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason   pgtype.Text        `json:"deletion_reason"`
	FederationUri    pgtype.Text        `json:"federation_uri"`
	NormalizedName   pgtype.Text        `json:"normalized_name"`
	MergedIntoID     pgtype.UUID        `json:"merged_into_id"`
}

type OrganizationRepository

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

func (*OrganizationRepository) CreateTombstone

CreateTombstone creates a tombstone record for a deleted organization

func (*OrganizationRepository) GetByULID

func (*OrganizationRepository) GetTombstoneByULID

func (r *OrganizationRepository) GetTombstoneByULID(ctx context.Context, ulid string) (*organizations.Tombstone, error)

GetTombstoneByULID retrieves the tombstone for a deleted organization by ULID

func (*OrganizationRepository) List

func (*OrganizationRepository) SoftDelete

func (r *OrganizationRepository) SoftDelete(ctx context.Context, ulid string, reason string) error

SoftDelete marks an organization as deleted

func (*OrganizationRepository) Update

Update updates an organization's fields. Nil pointer fields in params are not changed (COALESCE pattern).

type OrganizationTombstone

type OrganizationTombstone struct {
	ID              pgtype.UUID        `json:"id"`
	OrganizationID  pgtype.UUID        `json:"organization_id"`
	OrganizationUri string             `json:"organization_uri"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason  pgtype.Text        `json:"deletion_reason"`
	SupersededByUri pgtype.Text        `json:"superseded_by_uri"`
	Payload         []byte             `json:"payload"`
}

type Place

type Place struct {
	ID                      pgtype.UUID        `json:"id"`
	Ulid                    string             `json:"ulid"`
	Name                    string             `json:"name"`
	Description             pgtype.Text        `json:"description"`
	StreetAddress           pgtype.Text        `json:"street_address"`
	AddressLocality         pgtype.Text        `json:"address_locality"`
	AddressRegion           pgtype.Text        `json:"address_region"`
	PostalCode              pgtype.Text        `json:"postal_code"`
	AddressCountry          pgtype.Text        `json:"address_country"`
	FullAddress             pgtype.Text        `json:"full_address"`
	Latitude                pgtype.Numeric     `json:"latitude"`
	Longitude               pgtype.Numeric     `json:"longitude"`
	GeoPoint                interface{}        `json:"geo_point"`
	Telephone               pgtype.Text        `json:"telephone"`
	Email                   pgtype.Text        `json:"email"`
	Url                     pgtype.Text        `json:"url"`
	MaximumAttendeeCapacity pgtype.Int4        `json:"maximum_attendee_capacity"`
	VenueType               pgtype.Text        `json:"venue_type"`
	AccessibilityFeatures   []string           `json:"accessibility_features"`
	OriginNodeID            pgtype.UUID        `json:"origin_node_id"`
	Confidence              pgtype.Numeric     `json:"confidence"`
	CreatedAt               pgtype.Timestamptz `json:"created_at"`
	UpdatedAt               pgtype.Timestamptz `json:"updated_at"`
	DeletedAt               pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason          pgtype.Text        `json:"deletion_reason"`
	FederationUri           pgtype.Text        `json:"federation_uri"`
	NormalizedName          pgtype.Text        `json:"normalized_name"`
	MergedIntoID            pgtype.UUID        `json:"merged_into_id"`
}

type PlaceRepository

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

func (*PlaceRepository) CreateTombstone

func (r *PlaceRepository) CreateTombstone(ctx context.Context, params places.TombstoneCreateParams) error

CreateTombstone creates a tombstone record for a deleted place

func (*PlaceRepository) GetByULID

func (r *PlaceRepository) GetByULID(ctx context.Context, ulid string) (*places.Place, error)

func (*PlaceRepository) GetTombstoneByULID

func (r *PlaceRepository) GetTombstoneByULID(ctx context.Context, ulid string) (*places.Tombstone, error)

GetTombstoneByULID retrieves the tombstone for a deleted place by ULID

func (*PlaceRepository) List

func (r *PlaceRepository) List(ctx context.Context, filters places.Filters, paginationArgs places.Pagination) (places.ListResult, error)

func (*PlaceRepository) SoftDelete

func (r *PlaceRepository) SoftDelete(ctx context.Context, ulid string, reason string) error

SoftDelete marks a place as deleted

func (*PlaceRepository) Update

func (r *PlaceRepository) Update(ctx context.Context, ulid string, params places.UpdatePlaceParams) (*places.Place, error)

Update updates a place's fields. Nil pointer fields in params are not changed (COALESCE pattern).

type PlaceScraperSource

type PlaceScraperSource struct {
	PlaceID         pgtype.UUID `json:"place_id"`
	ScraperSourceID int64       `json:"scraper_source_id"`
}

type PlaceTombstone

type PlaceTombstone struct {
	ID              pgtype.UUID        `json:"id"`
	PlaceID         pgtype.UUID        `json:"place_id"`
	PlaceUri        string             `json:"place_uri"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
	DeletionReason  pgtype.Text        `json:"deletion_reason"`
	SupersededByUri pgtype.Text        `json:"superseded_by_uri"`
	Payload         []byte             `json:"payload"`
}

type ProvenanceRepository

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

func (*ProvenanceRepository) Create

func (*ProvenanceRepository) GetByBaseURL

func (r *ProvenanceRepository) GetByBaseURL(ctx context.Context, baseURL string) (*provenance.Source, error)

func (*ProvenanceRepository) GetCanonicalFieldValue

func (r *ProvenanceRepository) GetCanonicalFieldValue(ctx context.Context, eventID string, fieldPath string) (*provenance.FieldProvenanceInfo, error)

func (*ProvenanceRepository) GetEventSources

func (r *ProvenanceRepository) GetEventSources(ctx context.Context, eventID string) ([]provenance.EventSourceAttribution, error)

func (*ProvenanceRepository) GetFieldProvenance

func (r *ProvenanceRepository) GetFieldProvenance(ctx context.Context, eventID string) ([]provenance.FieldProvenanceInfo, error)

func (*ProvenanceRepository) GetFieldProvenanceForPaths

func (r *ProvenanceRepository) GetFieldProvenanceForPaths(ctx context.Context, eventID string, fieldPaths []string) ([]provenance.FieldProvenanceInfo, error)

type Querier

type Querier interface {
	AcceptDeveloperInvitation(ctx context.Context, id pgtype.UUID) error
	ActivateUser(ctx context.Context, id pgtype.UUID) error
	// Mark review as approved
	ApproveReview(ctx context.Context, arg ApproveReviewParams) (EventReviewQueue, error)
	CheckAPIKeyOwnership(ctx context.Context, arg CheckAPIKeyOwnershipParams) (bool, error)
	// Archive old approved/superseded/merged/dismissed reviews (90 day retention)
	CleanupArchivedReviews(ctx context.Context) error
	// Delete expired cache entries
	CleanupExpiredCache(ctx context.Context) (pgconn.CommandTag, error)
	// Delete rejected reviews for past events (7 day grace period)
	CleanupExpiredRejections(ctx context.Context) error
	// Delete pending reviews for events that have already started (too late to review)
	CleanupUnreviewedEvents(ctx context.Context) error
	CountAllEvents(ctx context.Context) (int64, error)
	CountAllOrganizations(ctx context.Context) (int64, error)
	CountAllPlaces(ctx context.Context) (int64, error)
	// SQLc queries for sources registry.
	CountAllSources(ctx context.Context) (int64, error)
	CountAllUsers(ctx context.Context) (int64, error)
	CountDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) (int64, error)
	CountDevelopers(ctx context.Context) (int64, error)
	CountEventsByLifecycleState(ctx context.Context, lifecycleState string) (int64, error)
	CountEventsCreatedSince(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)
	// Count occurrences for a given event UUID. Used to enforce last-occurrence guard.
	CountOccurrencesByEventID(ctx context.Context, eventID pgtype.UUID) (int64, error)
	CountPastEvents(ctx context.Context) (int64, error)
	// Count rows currently awaiting async URL validation.
	CountPendingValidation(ctx context.Context) (int64, error)
	// Count submissions from a given IP within the provided interval (for rate limiting).
	CountRecentSubmissionsByIP(ctx context.Context, arg CountRecentSubmissionsByIPParams) (int64, error)
	// Count total reviews by status (for badge display)
	CountReviewQueueByStatus(ctx context.Context, status pgtype.Text) (int64, error)
	// Count scraper runs currently marked as running within a recent window.
	// The time window avoids stale rows permanently blocking new run-all attempts.
	CountRunningScraperRuns(ctx context.Context) (int64, error)
	// Count submissions with optional status filter (for pagination total).
	CountScraperSubmissions(ctx context.Context, status pgtype.Text) (int64, error)
	// Count entities of a type that have no external identifiers
	CountUnreconciledEntities(ctx context.Context) (int64, error)
	CountUpcomingEvents(ctx context.Context) (int64, error)
	CountUsers(ctx context.Context, arg CountUsersParams) (int64, error)
	CreateAPIKey(ctx context.Context, arg CreateAPIKeyParams) (CreateAPIKeyRow, error)
	CreateBatchIngestionResult(ctx context.Context, arg CreateBatchIngestionResultParams) error
	// SQLc queries for developer management and invitations.
	// Developer CRUD operations
	CreateDeveloper(ctx context.Context, arg CreateDeveloperParams) (Developer, error)
	CreateDeveloperAPIKey(ctx context.Context, arg CreateDeveloperAPIKeyParams) (CreateDeveloperAPIKeyRow, error)
	// Developer invitation operations
	CreateDeveloperInvitation(ctx context.Context, arg CreateDeveloperInvitationParams) (DeveloperInvitation, error)
	CreateEventTombstone(ctx context.Context, arg CreateEventTombstoneParams) error
	CreateFederatedEventOccurrence(ctx context.Context, arg CreateFederatedEventOccurrenceParams) error
	// SQLc queries for federation sync.
	CreateFederationNode(ctx context.Context, arg CreateFederationNodeParams) (FederationNode, error)
	CreateOrganizationTombstone(ctx context.Context, arg CreateOrganizationTombstoneParams) error
	CreatePlaceTombstone(ctx context.Context, arg CreatePlaceTombstoneParams) error
	// Create new review queue entry
	CreateReviewQueueEntry(ctx context.Context, arg CreateReviewQueueEntryParams) (EventReviewQueue, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error)
	// User Invitation Queries
	CreateUserInvitation(ctx context.Context, arg CreateUserInvitationParams) (CreateUserInvitationRow, error)
	DeactivateAPIKey(ctx context.Context, id pgtype.UUID) error
	DeactivateDeveloper(ctx context.Context, id pgtype.UUID) error
	// User Management Queries
	DeactivateUser(ctx context.Context, id pgtype.UUID) error
	// Delete a specific entity identifier
	DeleteEntityIdentifier(ctx context.Context, id int32) error
	DeleteFederationNode(ctx context.Context, id pgtype.UUID) error
	// Delete a single occurrence by its UUID, scoped to the given event. Returns the deleted ID
	// so callers can detect when no row matched (event mismatch or already deleted).
	DeleteOccurrenceByID(ctx context.Context, arg DeleteOccurrenceByIDParams) (pgtype.UUID, error)
	// Remove all occurrence rows for a soft-deleted event.  Called after absorbing an
	// occurrence into a target series so the source event's orphaned rows are cleaned up.
	// Soft-delete (UPDATE) does not trigger ON DELETE CASCADE, so explicit cleanup is needed.
	DeleteOccurrencesByEventULID(ctx context.Context, eventUlid string) error
	// Delete processed/rejected submissions older than the given interval.
	// Used by the daily cleanup job to prevent unbounded table growth (srv-3sac0).
	DeleteOldScraperSubmissions(ctx context.Context, olderThan pgtype.Interval) (int64, error)
	// Delete a scraper source by name.
	DeleteScraperSource(ctx context.Context, name string) error
	DeleteUser(ctx context.Context, id pgtype.UUID) error
	// Atomically strips all companion warning entries referencing the given event_ulid
	// from a specific review row. Handles three warning types:
	//   near_duplicate_of_new_event  — stripped when duplicate_of_event_id matches
	//   potential_duplicate          — specific match entries filtered; warning nullified when matches empty
	//   cross_week_series_companion  — stripped when details->>'companion_ulid' matches
	// Also clears duplicate_of_event_id if it points to the given event.
	// Returns true (warnings_empty) when the resulting warnings array is empty after stripping.
	DismissAllCompanionWarnings(ctx context.Context, arg DismissAllCompanionWarningsParams) (bool, error)
	// Atomically remove any potential_duplicate match entry whose ulid equals event_ulid
	// from the companion's pending review queue entry, identified by the companion's event ULID.
	// Rebuilds the warnings JSONB in one UPDATE — no read-modify-write race.
	DismissCompanionWarningMatch(ctx context.Context, arg DismissCompanionWarningMatchParams) error
	// Atomically remove any potential_duplicate match entry whose ulid equals event_ulid
	// from a specific review queue entry identified by its primary key id.
	// Narrower than DismissCompanionWarningMatch: targets exactly one row, preventing
	// accidental modification of unrelated pending reviews on the same companion event.
	DismissWarningMatchByReviewID(ctx context.Context, arg DismissWarningMatchByReviewIDParams) error
	// Expires all pending (non-accepted, non-expired) invitations for a user by
	// setting accepted_at. This satisfies the unique partial index
	// idx_user_invitations_active (WHERE accepted_at IS NULL), allowing a new
	// invitation to be created. These rows are distinguishable from genuinely
	// accepted invitations because they will not have a corresponding password set.
	ExpirePendingInvitationsForUser(ctx context.Context, userID pgtype.UUID) error
	// Find all pending review entries whose cross_week_series_companion warnings
	// reference any of the given retire ULIDs. Returns the review ID and event ULID
	// so callers can update the warning details to point to a surviving canonical.
	FindCrossWeekCompanionTargets(ctx context.Context, retireUlids []string) ([]FindCrossWeekCompanionTargetsRow, error)
	// SQLc queries for event_review_queue domain.
	// See docs/architecture/event-review-workflow.md for complete design.
	// Find existing review by deduplication keys (checks source_external_id or dedup_hash)
	FindReviewByDedup(ctx context.Context, arg FindReviewByDedupParams) (FindReviewByDedupRow, error)
	GetAPIKeyByID(ctx context.Context, id pgtype.UUID) (ApiKey, error)
	GetAPIKeyByPrefix(ctx context.Context, prefix string) (GetAPIKeyByPrefixRow, error)
	GetAPIKeyUsage(ctx context.Context, arg GetAPIKeyUsageParams) ([]ApiKeyUsage, error)
	GetAPIKeyUsageTotal(ctx context.Context, arg GetAPIKeyUsageTotalParams) (GetAPIKeyUsageTotalRow, error)
	// SQLc queries for knowledge graph reconciliation.
	// Get active knowledge graph authorities ordered by priority
	GetActiveAuthorities(ctx context.Context) ([]KnowledgeGraphAuthority, error)
	// Gets complete provenance history for a field, including superseded records
	GetAllFieldProvenanceHistory(ctx context.Context, arg GetAllFieldProvenanceHistoryParams) ([]GetAllFieldProvenanceHistoryRow, error)
	// Get active authorities applicable to a given event domain
	GetAuthoritiesForDomain(ctx context.Context, domain string) ([]KnowledgeGraphAuthority, error)
	GetAuthorityByCode(ctx context.Context, authorityCode string) (KnowledgeGraphAuthority, error)
	// SQLc queries for batch ingestion operations.
	GetBatchIngestionResult(ctx context.Context, batchID string) (BatchIngestionResult, error)
	// Gets the canonical (winning) field value based on conflict resolution rules
	// Priority: trust_level DESC, confidence DESC, observed_at DESC
	GetCanonicalFieldValue(ctx context.Context, arg GetCanonicalFieldValueParams) (GetCanonicalFieldValueRow, error)
	GetDailyUsageReportData(ctx context.Context, arg GetDailyUsageReportDataParams) ([]GetDailyUsageReportDataRow, error)
	GetDeveloperByEmail(ctx context.Context, email string) (Developer, error)
	GetDeveloperByGitHubID(ctx context.Context, githubID pgtype.Int8) (Developer, error)
	GetDeveloperByID(ctx context.Context, id pgtype.UUID) (Developer, error)
	GetDeveloperInvitationByTokenHash(ctx context.Context, tokenHash string) (DeveloperInvitation, error)
	GetDeveloperUsageTotal(ctx context.Context, arg GetDeveloperUsageTotalParams) (GetDeveloperUsageTotalRow, error)
	// Get all external identifiers for an entity
	GetEntityIdentifiers(ctx context.Context, arg GetEntityIdentifiersParams) ([]EntityIdentifier, error)
	// Get identifiers for an entity from a specific authority
	GetEntityIdentifiersByAuthority(ctx context.Context, arg GetEntityIdentifiersByAuthorityParams) ([]EntityIdentifier, error)
	// Federation Sync Queries
	GetEventByFederationURI(ctx context.Context, federationUri pgtype.Text) (Event, error)
	// SQLc queries for events domain.
	GetEventByULID(ctx context.Context, ulid string) ([]GetEventByULIDRow, error)
	GetEventChangeByID(ctx context.Context, id pgtype.UUID) (GetEventChangeByIDRow, error)
	GetEventDateRange(ctx context.Context) (GetEventDateRangeRow, error)
	// SQLc queries for provenance tracking.
	// Retrieves all sources for a given event with source metadata and timestamps (FR-029)
	GetEventSources(ctx context.Context, eventID pgtype.UUID) ([]GetEventSourcesRow, error)
	GetEventTombstoneByEventID(ctx context.Context, eventID pgtype.UUID) (EventTombstone, error)
	GetEventTombstoneByEventULID(ctx context.Context, ulid string) (EventTombstone, error)
	GetEventTombstoneByURI(ctx context.Context, eventUri string) (EventTombstone, error)
	GetFederationNodeByDomain(ctx context.Context, nodeDomain string) (FederationNode, error)
	GetFederationNodeByID(ctx context.Context, id pgtype.UUID) (FederationNode, error)
	// Retrieves field-level provenance for an event, optionally filtered by field paths
	// Includes source metadata and timestamps per FR-024 and FR-029
	GetFieldProvenance(ctx context.Context, eventID pgtype.UUID) ([]GetFieldProvenanceRow, error)
	// Retrieves field-level provenance for specific field paths on an event
	GetFieldProvenanceForPaths(ctx context.Context, arg GetFieldProvenanceForPathsParams) ([]GetFieldProvenanceForPathsRow, error)
	GetIdempotencyKey(ctx context.Context, key string) (GetIdempotencyKeyRow, error)
	// Get the most recent successful (completed) scraper run for a given source_name.
	GetLastSuccessfulRunBySource(ctx context.Context, sourceName string) (ScraperRun, error)
	GetLatestEventChange(ctx context.Context) (GetLatestEventChangeRow, error)
	// Get the most recent scraper run for a given source_name.
	GetLatestScraperRunBySource(ctx context.Context, sourceName string) (ScraperRun, error)
	// Fetch a single occurrence row by its UUID, scoped to the given event.
	GetOccurrenceByID(ctx context.Context, arg GetOccurrenceByIDParams) (GetOccurrenceByIDRow, error)
	GetOrganizationByULID(ctx context.Context, ulid string) (GetOrganizationByULIDRow, error)
	GetOrganizationTombstoneByULID(ctx context.Context, ulid string) (OrganizationTombstone, error)
	// Get the pending review queue entry for an event by its ULID, if any.
	GetPendingReviewByEventUlid(ctx context.Context, eventUlid string) (GetPendingReviewByEventUlidRow, error)
	// Get the pending review queue entry for an event by its ULID, narrowed to the
	// specific companion whose duplicate_of_event_id points to the counterpart event.
	// Used by the add-occurrence workflow to avoid picking an unrelated pending review
	// when the same event has multiple pending review rows.
	GetPendingReviewByEventUlidAndDuplicateUlid(ctx context.Context, arg GetPendingReviewByEventUlidAndDuplicateUlidParams) (GetPendingReviewByEventUlidAndDuplicateUlidRow, error)
	GetPlaceByULID(ctx context.Context, ulid string) (GetPlaceByULIDRow, error)
	GetPlaceTombstoneByULID(ctx context.Context, ulid string) (PlaceTombstone, error)
	// Check if a url_norm was submitted within the given interval (for dedup).
	// Returns the most recent matching row if found.
	GetRecentSubmissionByURLNorm(ctx context.Context, arg GetRecentSubmissionByURLNormParams) (ScraperSubmission, error)
	// Check cache for a previous reconciliation result
	GetReconciliationCache(ctx context.Context, arg GetReconciliationCacheParams) (ReconciliationCache, error)
	// Get single review by ID
	GetReviewQueueEntry(ctx context.Context, id int32) (GetReviewQueueEntryRow, error)
	GetScraperConfig(ctx context.Context) (ScraperConfig, error)
	// Get a single scraper source by primary key.
	GetScraperSourceByID(ctx context.Context, id int64) (GetScraperSourceByIDRow, error)
	// Get a single scraper source by unique name.
	GetScraperSourceByName(ctx context.Context, name string) (GetScraperSourceByNameRow, error)
	// Retrieves source metadata by ID
	GetSourceByID(ctx context.Context, id pgtype.UUID) (GetSourceByIDRow, error)
	// Gets all sources that contributed to an event (deduplicated)
	GetSourcesByEventID(ctx context.Context, eventID pgtype.UUID) ([]GetSourcesByEventIDRow, error)
	// SQLc queries for authentication.
	GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error)
	GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDRow, error)
	GetUserByUsername(ctx context.Context, username string) (GetUserByUsernameRow, error)
	GetUserInvitationByTokenHash(ctx context.Context, tokenHash string) (UserInvitation, error)
	// Records a source's contribution to an event with source and received timestamps (FR-029)
	InsertEventSource(ctx context.Context, arg InsertEventSourceParams) (EventSource, error)
	// Records field-level provenance with source timestamp
	InsertFieldProvenance(ctx context.Context, arg InsertFieldProvenanceParams) (FieldProvenance, error)
	InsertIdempotencyKey(ctx context.Context, arg InsertIdempotencyKeyParams) (InsertIdempotencyKeyRow, error)
	// SQLc queries for event_not_duplicates table.
	// Tracks pairs of events that an admin has confirmed are NOT duplicates,
	// preventing them from being re-flagged during near-duplicate detection.
	// Record that two events are confirmed as NOT duplicates.
	// Uses canonical ordering (smaller ULID first) to prevent storing both (A,B) and (B,A).
	// ON CONFLICT DO NOTHING handles the case where the pair already exists.
	InsertNotDuplicate(ctx context.Context, arg InsertNotDuplicateParams) error
	// Insert a single occurrence and return the created row (including generated UUID).
	InsertOccurrence(ctx context.Context, arg InsertOccurrenceParams) (InsertOccurrenceRow, error)
	// SQLc queries for scraper runs tracking.
	// Insert a new scraper run record and return its id.
	InsertScraperRun(ctx context.Context, arg InsertScraperRunParams) (int64, error)
	// SQLc queries for scraper_submissions.
	// Insert a new URL submission and return the full row.
	InsertScraperSubmission(ctx context.Context, arg InsertScraperSubmissionParams) (ScraperSubmission, error)
	// Check if a pair of events has been marked as not-duplicates.
	// Uses canonical ordering to match regardless of argument order.
	IsNotDuplicate(ctx context.Context, arg IsNotDuplicateParams) (bool, error)
	// Associate an organization with a scraper source.
	LinkOrgScraperSource(ctx context.Context, arg LinkOrgScraperSourceParams) error
	// Associate a place with a scraper source.
	LinkPlaceScraperSource(ctx context.Context, arg LinkPlaceScraperSourceParams) error
	ListAPIKeys(ctx context.Context) ([]ListAPIKeysRow, error)
	ListActiveDeveloperInvitations(ctx context.Context) ([]DeveloperInvitation, error)
	// Developer API key operations
	ListDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) ([]ApiKey, error)
	ListDevelopers(ctx context.Context, arg ListDevelopersParams) ([]Developer, error)
	// SQLc queries for change feeds.
	ListEventChanges(ctx context.Context, arg ListEventChangesParams) ([]ListEventChangesRow, error)
	ListEventTombstones(ctx context.Context, arg ListEventTombstonesParams) ([]EventTombstone, error)
	ListFederationNodes(ctx context.Context, arg ListFederationNodesParams) ([]FederationNode, error)
	// List all events that have been confirmed as NOT duplicates of a given event.
	// Returns both sides of the pair (the given event could be event_id_a or event_id_b).
	ListNotDuplicatesForEvent(ctx context.Context, eventID string) ([]EventNotDuplicate, error)
	// SQLc queries for organizations domain.
	ListOrganizationsByCreatedAt(ctx context.Context, arg ListOrganizationsByCreatedAtParams) ([]ListOrganizationsByCreatedAtRow, error)
	ListOrganizationsByCreatedAtDesc(ctx context.Context, arg ListOrganizationsByCreatedAtDescParams) ([]ListOrganizationsByCreatedAtDescRow, error)
	ListOrganizationsByName(ctx context.Context, arg ListOrganizationsByNameParams) ([]ListOrganizationsByNameRow, error)
	ListOrganizationsByNameDesc(ctx context.Context, arg ListOrganizationsByNameDescParams) ([]ListOrganizationsByNameDescRow, error)
	ListPendingInvitationsForUser(ctx context.Context, userID pgtype.UUID) ([]ListPendingInvitationsForUserRow, error)
	// Fetch up to N rows awaiting async URL validation, oldest first.
	ListPendingValidation(ctx context.Context, limit int32) ([]ScraperSubmission, error)
	// SQLc queries for places domain.
	ListPlacesByCreatedAt(ctx context.Context, arg ListPlacesByCreatedAtParams) ([]ListPlacesByCreatedAtRow, error)
	ListPlacesByCreatedAtDesc(ctx context.Context, arg ListPlacesByCreatedAtDescParams) ([]ListPlacesByCreatedAtDescRow, error)
	ListPlacesByName(ctx context.Context, arg ListPlacesByNameParams) ([]ListPlacesByNameRow, error)
	ListPlacesByNameDesc(ctx context.Context, arg ListPlacesByNameDescParams) ([]ListPlacesByNameDescRow, error)
	// List the N most recent scraper runs ordered by started_at DESC.
	ListRecentScraperRuns(ctx context.Context, limit int32) ([]ScraperRun, error)
	// List recent scraper runs with optional status and source_name filters.
	ListRecentScraperRunsFiltered(ctx context.Context, arg ListRecentScraperRunsFilteredParams) ([]ScraperRun, error)
	// List reviews with pagination and status filter
	ListReviewQueue(ctx context.Context, arg ListReviewQueueParams) ([]ListReviewQueueRow, error)
	// List recent scraper runs for a specific source, ordered newest first.
	ListScraperRunsBySource(ctx context.Context, arg ListScraperRunsBySourceParams) ([]ScraperRun, error)
	// List all scraper sources, optionally filtered by enabled flag.
	ListScraperSources(ctx context.Context, enabled pgtype.Bool) ([]ListScraperSourcesRow, error)
	// List all scraper sources linked to a given organization.
	ListScraperSourcesByOrg(ctx context.Context, organizationID pgtype.UUID) ([]ListScraperSourcesByOrgRow, error)
	// List all scraper sources linked to a given place.
	ListScraperSourcesByPlace(ctx context.Context, placeID pgtype.UUID) ([]ListScraperSourcesByPlaceRow, error)
	// List all scraper sources with their most recent run stats embedded.
	// last_run_started_at/completed_at/error_message are nullable (NULL when a source
	// has never been run). status and event counts use COALESCE to return non-nullable
	// defaults so SQLc generates simple string/int32 types for those columns.
	ListScraperSourcesWithLatestRun(ctx context.Context, enabled pgtype.Bool) ([]ListScraperSourcesWithLatestRunRow, error)
	// Paginated list of submissions, optionally filtered by status (for admin).
	ListScraperSubmissions(ctx context.Context, arg ListScraperSubmissionsParams) ([]ScraperSubmission, error)
	// Get organizations that have no external identifiers, ordered by creation date
	ListUnreconciledOrganizations(ctx context.Context, maxResults int32) ([]ListUnreconciledOrganizationsRow, error)
	// Get places that have no external identifiers, ordered by creation date
	ListUnreconciledPlaces(ctx context.Context, maxResults int32) ([]ListUnreconciledPlacesRow, error)
	ListUsers(ctx context.Context) ([]ListUsersRow, error)
	ListUsersWithFilters(ctx context.Context, arg ListUsersWithFiltersParams) ([]ListUsersWithFiltersRow, error)
	MarkInvitationAccepted(ctx context.Context, id pgtype.UUID) error
	// Mark events as deleted before cleaning up their pending reviews
	MarkUnreviewedEventsAsDeleted(ctx context.Context) error
	MergeEventIntoDuplicate(ctx context.Context, arg MergeEventIntoDuplicateParams) error
	// Mark review as rejected
	RejectReview(ctx context.Context, arg RejectReviewParams) (EventReviewQueue, error)
	// Follow the merged_into_id chain from a given ULID to find the final canonical event.
	// Uses a recursive CTE with a max depth of 10 to prevent infinite loops.
	// Returns the ULID of the final canonical event (the one that is not itself merged).
	ResolveCanonicalEventULID(ctx context.Context, ulid string) (string, error)
	RevokeAllDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) (int64, error)
	SetScraperConfig(ctx context.Context, arg SetScraperConfigParams) error
	// Enable or disable a scraper source by name. Returns the updated row.
	SetScraperSourceEnabled(ctx context.Context, arg SetScraperSourceEnabledParams) (SetScraperSourceEnabledRow, error)
	SoftDeleteEvent(ctx context.Context, arg SoftDeleteEventParams) error
	SoftDeleteOrganization(ctx context.Context, arg SoftDeleteOrganizationParams) error
	SoftDeletePlace(ctx context.Context, arg SoftDeletePlaceParams) error
	// Atomically strips all duplicate warning entries referencing any of the given retire_ulids
	// from a specific review row. Handles three warning types:
	//   near_duplicate_of_new_event  — stripped when duplicate_of_event_id points to a retired event
	//   potential_duplicate          — specific match entries filtered; warning nullified when matches empty
	//   cross_week_series_companion  — stripped when details->>'companion_ulid' is in the retire set
	// Also clears duplicate_of_event_id if it points to a retired event.
	// Returns true (warnings_empty) when the resulting warnings array is empty after stripping.
	// Note: companion replacement is handled in Go after SQL returns.
	StripRetiredDupWarnings(ctx context.Context, arg StripRetiredDupWarningsParams) (bool, error)
	// Marks a field provenance record as superseded by a new record
	SupersedeFieldProvenance(ctx context.Context, arg SupersedeFieldProvenanceParams) error
	// Remove an organization↔scraper source association.
	UnlinkOrgScraperSource(ctx context.Context, arg UnlinkOrgScraperSourceParams) error
	// Remove a place↔scraper source association.
	UnlinkPlaceScraperSource(ctx context.Context, arg UnlinkPlaceScraperSourceParams) error
	UpdateAPIKeyLastUsed(ctx context.Context, id pgtype.UUID) error
	UpdateDeveloper(ctx context.Context, arg UpdateDeveloperParams) (Developer, error)
	UpdateDeveloperLastLogin(ctx context.Context, id pgtype.UUID) error
	UpdateEvent(ctx context.Context, arg UpdateEventParams) (UpdateEventRow, error)
	UpdateFederationNode(ctx context.Context, arg UpdateFederationNodeParams) (FederationNode, error)
	UpdateFederationNodeHealth(ctx context.Context, arg UpdateFederationNodeHealthParams) error
	UpdateFederationNodeSyncStatus(ctx context.Context, arg UpdateFederationNodeSyncStatusParams) error
	UpdateLastLogin(ctx context.Context, id pgtype.UUID) error
	// Flatten existing merge chains: update all events that point to an old target
	// to point to the new canonical target instead. This prevents transitive chains.
	// $1 = old target event ULID (intermediate node being re-pointed)
	// $2 = new canonical target event ULID (final destination)
	UpdateMergedIntoChain(ctx context.Context, arg UpdateMergedIntoChainParams) error
	// Partial-update a single occurrence row, scoped to the given event.
	// Only non-NULL arguments are applied (COALESCE pattern).
	// venue_id, virtual_url, ticket_url use explicit NULLability via CASE WHEN *_set pattern.
	UpdateOccurrenceByID(ctx context.Context, arg UpdateOccurrenceByIDParams) (UpdateOccurrenceByIDRow, error)
	// Update the start_time and end_time of all occurrences for an event identified by ULID.
	// Used by the FixReview workflow to correct occurrence dates during admin review.
	UpdateOccurrenceDatesByEventULID(ctx context.Context, arg UpdateOccurrenceDatesByEventULIDParams) error
	UpdateOrganization(ctx context.Context, arg UpdateOrganizationParams) (UpdateOrganizationRow, error)
	UpdatePlace(ctx context.Context, arg UpdatePlaceParams) (UpdatePlaceRow, error)
	// Update existing review entry (for resubmissions with same issues).
	// Pass clear_duplicate_of=TRUE to set duplicate_of_event_id to NULL;
	// otherwise pass a new UUID via duplicate_of_event_id or leave both NULL to keep the existing value.
	UpdateReviewQueueEntry(ctx context.Context, arg UpdateReviewQueueEntryParams) (EventReviewQueue, error)
	// Update only the warnings JSON of a review queue entry (used for companion warning dismissal).
	UpdateReviewWarnings(ctx context.Context, arg UpdateReviewWarningsParams) error
	// Mark a scraper run as completed with event counts and optional per-event failure metadata.
	UpdateScraperRunCompleted(ctx context.Context, arg UpdateScraperRunCompletedParams) error
	// Mark a scraper run as failed with an error message.
	UpdateScraperRunFailed(ctx context.Context, arg UpdateScraperRunFailedParams) error
	// Update last_scraped_at timestamp after a successful scrape run.
	UpdateScraperSourceLastScraped(ctx context.Context, name string) error
	// Update status and optional notes for a given row (admin PATCH).
	// Returns the full updated row.
	UpdateSubmissionAdminReview(ctx context.Context, arg UpdateSubmissionAdminReviewParams) (ScraperSubmission, error)
	// Update status, optional rejection_reason, and optional validated_at for a given row.
	// Used by the background validation worker.
	UpdateSubmissionStatus(ctx context.Context, arg UpdateSubmissionStatusParams) error
	UpdateUser(ctx context.Context, arg UpdateUserParams) error
	UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error
	// SQLc queries for API key usage tracking.
	UpsertAPIKeyUsage(ctx context.Context, arg UpsertAPIKeyUsageParams) error
	UpsertAPIKeyUsageIP(ctx context.Context, arg UpsertAPIKeyUsageIPParams) error
	// Insert or update an entity identifier (sameAs link)
	UpsertEntityIdentifier(ctx context.Context, arg UpsertEntityIdentifierParams) (EntityIdentifier, error)
	UpsertFederatedEvent(ctx context.Context, arg UpsertFederatedEventParams) (Event, error)
	// Insert or update a cache entry
	UpsertReconciliationCache(ctx context.Context, arg UpsertReconciliationCacheParams) (ReconciliationCache, error)
	// SQLc queries for scraper_sources and linkage tables.
	// Insert or update a scraper source by name (used by 'server scrape sync').
	UpsertScraperSource(ctx context.Context, arg UpsertScraperSourceParams) (UpsertScraperSourceRow, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AcceptDeveloperInvitation

func (q *Queries) AcceptDeveloperInvitation(ctx context.Context, id pgtype.UUID) error

func (*Queries) ActivateUser

func (q *Queries) ActivateUser(ctx context.Context, id pgtype.UUID) error

func (*Queries) ApproveReview

func (q *Queries) ApproveReview(ctx context.Context, arg ApproveReviewParams) (EventReviewQueue, error)

Mark review as approved

func (*Queries) CheckAPIKeyOwnership

func (q *Queries) CheckAPIKeyOwnership(ctx context.Context, arg CheckAPIKeyOwnershipParams) (bool, error)

func (*Queries) CleanupArchivedReviews

func (q *Queries) CleanupArchivedReviews(ctx context.Context) error

Archive old approved/superseded/merged/dismissed reviews (90 day retention)

func (*Queries) CleanupExpiredCache

func (q *Queries) CleanupExpiredCache(ctx context.Context) (pgconn.CommandTag, error)

Delete expired cache entries

func (*Queries) CleanupExpiredRejections

func (q *Queries) CleanupExpiredRejections(ctx context.Context) error

Delete rejected reviews for past events (7 day grace period)

func (*Queries) CleanupUnreviewedEvents

func (q *Queries) CleanupUnreviewedEvents(ctx context.Context) error

Delete pending reviews for events that have already started (too late to review)

func (*Queries) CountAllEvents

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

func (*Queries) CountAllOrganizations

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

func (*Queries) CountAllPlaces

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

func (*Queries) CountAllSources

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

SQLc queries for sources registry.

func (*Queries) CountAllUsers

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

func (*Queries) CountDeveloperAPIKeys

func (q *Queries) CountDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) (int64, error)

func (*Queries) CountDevelopers

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

func (*Queries) CountEventsByLifecycleState

func (q *Queries) CountEventsByLifecycleState(ctx context.Context, lifecycleState string) (int64, error)

func (*Queries) CountEventsCreatedSince

func (q *Queries) CountEventsCreatedSince(ctx context.Context, createdAt pgtype.Timestamptz) (int64, error)

func (*Queries) CountOccurrencesByEventID

func (q *Queries) CountOccurrencesByEventID(ctx context.Context, eventID pgtype.UUID) (int64, error)

Count occurrences for a given event UUID. Used to enforce last-occurrence guard.

func (*Queries) CountPastEvents

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

func (*Queries) CountPendingValidation

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

Count rows currently awaiting async URL validation.

func (*Queries) CountRecentSubmissionsByIP

func (q *Queries) CountRecentSubmissionsByIP(ctx context.Context, arg CountRecentSubmissionsByIPParams) (int64, error)

Count submissions from a given IP within the provided interval (for rate limiting).

func (*Queries) CountReviewQueueByStatus

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

Count total reviews by status (for badge display)

func (*Queries) CountRunningScraperRuns

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

Count scraper runs currently marked as running within a recent window. The time window avoids stale rows permanently blocking new run-all attempts.

func (*Queries) CountScraperSubmissions

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

Count submissions with optional status filter (for pagination total).

func (*Queries) CountUnreconciledEntities

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

Count entities of a type that have no external identifiers

func (*Queries) CountUpcomingEvents

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

func (*Queries) CountUsers

func (q *Queries) CountUsers(ctx context.Context, arg CountUsersParams) (int64, error)

func (*Queries) CreateAPIKey

func (q *Queries) CreateAPIKey(ctx context.Context, arg CreateAPIKeyParams) (CreateAPIKeyRow, error)

func (*Queries) CreateBatchIngestionResult

func (q *Queries) CreateBatchIngestionResult(ctx context.Context, arg CreateBatchIngestionResultParams) error

func (*Queries) CreateDeveloper

func (q *Queries) CreateDeveloper(ctx context.Context, arg CreateDeveloperParams) (Developer, error)

SQLc queries for developer management and invitations. Developer CRUD operations

func (*Queries) CreateDeveloperAPIKey

func (q *Queries) CreateDeveloperAPIKey(ctx context.Context, arg CreateDeveloperAPIKeyParams) (CreateDeveloperAPIKeyRow, error)

func (*Queries) CreateDeveloperInvitation

func (q *Queries) CreateDeveloperInvitation(ctx context.Context, arg CreateDeveloperInvitationParams) (DeveloperInvitation, error)

Developer invitation operations

func (*Queries) CreateEventTombstone

func (q *Queries) CreateEventTombstone(ctx context.Context, arg CreateEventTombstoneParams) error

func (*Queries) CreateFederatedEventOccurrence

func (q *Queries) CreateFederatedEventOccurrence(ctx context.Context, arg CreateFederatedEventOccurrenceParams) error

func (*Queries) CreateFederationNode

func (q *Queries) CreateFederationNode(ctx context.Context, arg CreateFederationNodeParams) (FederationNode, error)

SQLc queries for federation sync.

func (*Queries) CreateOrganizationTombstone

func (q *Queries) CreateOrganizationTombstone(ctx context.Context, arg CreateOrganizationTombstoneParams) error

func (*Queries) CreatePlaceTombstone

func (q *Queries) CreatePlaceTombstone(ctx context.Context, arg CreatePlaceTombstoneParams) error

func (*Queries) CreateReviewQueueEntry

func (q *Queries) CreateReviewQueueEntry(ctx context.Context, arg CreateReviewQueueEntryParams) (EventReviewQueue, error)

Create new review queue entry

func (*Queries) CreateUser

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

func (*Queries) CreateUserInvitation

func (q *Queries) CreateUserInvitation(ctx context.Context, arg CreateUserInvitationParams) (CreateUserInvitationRow, error)

User Invitation Queries

func (*Queries) DeactivateAPIKey

func (q *Queries) DeactivateAPIKey(ctx context.Context, id pgtype.UUID) error

func (*Queries) DeactivateDeveloper

func (q *Queries) DeactivateDeveloper(ctx context.Context, id pgtype.UUID) error

func (*Queries) DeactivateUser

func (q *Queries) DeactivateUser(ctx context.Context, id pgtype.UUID) error

User Management Queries

func (*Queries) DeleteEntityIdentifier

func (q *Queries) DeleteEntityIdentifier(ctx context.Context, id int32) error

Delete a specific entity identifier

func (*Queries) DeleteFederationNode

func (q *Queries) DeleteFederationNode(ctx context.Context, id pgtype.UUID) error

func (*Queries) DeleteOccurrenceByID

func (q *Queries) DeleteOccurrenceByID(ctx context.Context, arg DeleteOccurrenceByIDParams) (pgtype.UUID, error)

Delete a single occurrence by its UUID, scoped to the given event. Returns the deleted ID so callers can detect when no row matched (event mismatch or already deleted).

func (*Queries) DeleteOccurrencesByEventULID

func (q *Queries) DeleteOccurrencesByEventULID(ctx context.Context, eventUlid string) error

Remove all occurrence rows for a soft-deleted event. Called after absorbing an occurrence into a target series so the source event's orphaned rows are cleaned up. Soft-delete (UPDATE) does not trigger ON DELETE CASCADE, so explicit cleanup is needed.

func (*Queries) DeleteOldScraperSubmissions

func (q *Queries) DeleteOldScraperSubmissions(ctx context.Context, olderThan pgtype.Interval) (int64, error)

Delete processed/rejected submissions older than the given interval. Used by the daily cleanup job to prevent unbounded table growth (srv-3sac0).

func (*Queries) DeleteScraperSource

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

Delete a scraper source by name.

func (*Queries) DeleteUser

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

func (*Queries) DismissAllCompanionWarnings

func (q *Queries) DismissAllCompanionWarnings(ctx context.Context, arg DismissAllCompanionWarningsParams) (bool, error)

Atomically strips all companion warning entries referencing the given event_ulid from a specific review row. Handles three warning types:

near_duplicate_of_new_event  — stripped when duplicate_of_event_id matches
potential_duplicate          — specific match entries filtered; warning nullified when matches empty
cross_week_series_companion  — stripped when details->>'companion_ulid' matches

Also clears duplicate_of_event_id if it points to the given event. Returns true (warnings_empty) when the resulting warnings array is empty after stripping.

func (*Queries) DismissCompanionWarningMatch

func (q *Queries) DismissCompanionWarningMatch(ctx context.Context, arg DismissCompanionWarningMatchParams) error

Atomically remove any potential_duplicate match entry whose ulid equals event_ulid from the companion's pending review queue entry, identified by the companion's event ULID. Rebuilds the warnings JSONB in one UPDATE — no read-modify-write race.

func (*Queries) DismissWarningMatchByReviewID

func (q *Queries) DismissWarningMatchByReviewID(ctx context.Context, arg DismissWarningMatchByReviewIDParams) error

Atomically remove any potential_duplicate match entry whose ulid equals event_ulid from a specific review queue entry identified by its primary key id. Narrower than DismissCompanionWarningMatch: targets exactly one row, preventing accidental modification of unrelated pending reviews on the same companion event.

func (*Queries) ExpirePendingInvitationsForUser

func (q *Queries) ExpirePendingInvitationsForUser(ctx context.Context, userID pgtype.UUID) error

Expires all pending (non-accepted, non-expired) invitations for a user by setting accepted_at. This satisfies the unique partial index idx_user_invitations_active (WHERE accepted_at IS NULL), allowing a new invitation to be created. These rows are distinguishable from genuinely accepted invitations because they will not have a corresponding password set.

func (*Queries) FindCrossWeekCompanionTargets

func (q *Queries) FindCrossWeekCompanionTargets(ctx context.Context, retireUlids []string) ([]FindCrossWeekCompanionTargetsRow, error)

Find all pending review entries whose cross_week_series_companion warnings reference any of the given retire ULIDs. Returns the review ID and event ULID so callers can update the warning details to point to a surviving canonical.

func (*Queries) FindReviewByDedup

func (q *Queries) FindReviewByDedup(ctx context.Context, arg FindReviewByDedupParams) (FindReviewByDedupRow, error)

SQLc queries for event_review_queue domain. See docs/architecture/event-review-workflow.md for complete design. Find existing review by deduplication keys (checks source_external_id or dedup_hash)

func (*Queries) GetAPIKeyByID

func (q *Queries) GetAPIKeyByID(ctx context.Context, id pgtype.UUID) (ApiKey, error)

func (*Queries) GetAPIKeyByPrefix

func (q *Queries) GetAPIKeyByPrefix(ctx context.Context, prefix string) (GetAPIKeyByPrefixRow, error)

func (*Queries) GetAPIKeyUsage

func (q *Queries) GetAPIKeyUsage(ctx context.Context, arg GetAPIKeyUsageParams) ([]ApiKeyUsage, error)

func (*Queries) GetAPIKeyUsageTotal

func (q *Queries) GetAPIKeyUsageTotal(ctx context.Context, arg GetAPIKeyUsageTotalParams) (GetAPIKeyUsageTotalRow, error)

func (*Queries) GetActiveAuthorities

func (q *Queries) GetActiveAuthorities(ctx context.Context) ([]KnowledgeGraphAuthority, error)

SQLc queries for knowledge graph reconciliation. Get active knowledge graph authorities ordered by priority

func (*Queries) GetAllFieldProvenanceHistory

func (q *Queries) GetAllFieldProvenanceHistory(ctx context.Context, arg GetAllFieldProvenanceHistoryParams) ([]GetAllFieldProvenanceHistoryRow, error)

Gets complete provenance history for a field, including superseded records

func (*Queries) GetAuthoritiesForDomain

func (q *Queries) GetAuthoritiesForDomain(ctx context.Context, domain string) ([]KnowledgeGraphAuthority, error)

Get active authorities applicable to a given event domain

func (*Queries) GetAuthorityByCode

func (q *Queries) GetAuthorityByCode(ctx context.Context, authorityCode string) (KnowledgeGraphAuthority, error)

func (*Queries) GetBatchIngestionResult

func (q *Queries) GetBatchIngestionResult(ctx context.Context, batchID string) (BatchIngestionResult, error)

SQLc queries for batch ingestion operations.

func (*Queries) GetCanonicalFieldValue

func (q *Queries) GetCanonicalFieldValue(ctx context.Context, arg GetCanonicalFieldValueParams) (GetCanonicalFieldValueRow, error)

Gets the canonical (winning) field value based on conflict resolution rules Priority: trust_level DESC, confidence DESC, observed_at DESC

func (*Queries) GetDailyUsageReportData

func (q *Queries) GetDailyUsageReportData(ctx context.Context, arg GetDailyUsageReportDataParams) ([]GetDailyUsageReportDataRow, error)

func (*Queries) GetDeveloperByEmail

func (q *Queries) GetDeveloperByEmail(ctx context.Context, email string) (Developer, error)

func (*Queries) GetDeveloperByGitHubID

func (q *Queries) GetDeveloperByGitHubID(ctx context.Context, githubID pgtype.Int8) (Developer, error)

func (*Queries) GetDeveloperByID

func (q *Queries) GetDeveloperByID(ctx context.Context, id pgtype.UUID) (Developer, error)

func (*Queries) GetDeveloperInvitationByTokenHash

func (q *Queries) GetDeveloperInvitationByTokenHash(ctx context.Context, tokenHash string) (DeveloperInvitation, error)

func (*Queries) GetDeveloperUsageTotal

func (q *Queries) GetDeveloperUsageTotal(ctx context.Context, arg GetDeveloperUsageTotalParams) (GetDeveloperUsageTotalRow, error)

func (*Queries) GetEntityIdentifiers

func (q *Queries) GetEntityIdentifiers(ctx context.Context, arg GetEntityIdentifiersParams) ([]EntityIdentifier, error)

Get all external identifiers for an entity

func (*Queries) GetEntityIdentifiersByAuthority

func (q *Queries) GetEntityIdentifiersByAuthority(ctx context.Context, arg GetEntityIdentifiersByAuthorityParams) ([]EntityIdentifier, error)

Get identifiers for an entity from a specific authority

func (*Queries) GetEventByFederationURI

func (q *Queries) GetEventByFederationURI(ctx context.Context, federationUri pgtype.Text) (Event, error)

Federation Sync Queries

func (*Queries) GetEventByULID

func (q *Queries) GetEventByULID(ctx context.Context, ulid string) ([]GetEventByULIDRow, error)

SQLc queries for events domain.

func (*Queries) GetEventChangeByID

func (q *Queries) GetEventChangeByID(ctx context.Context, id pgtype.UUID) (GetEventChangeByIDRow, error)

func (*Queries) GetEventDateRange

func (q *Queries) GetEventDateRange(ctx context.Context) (GetEventDateRangeRow, error)

func (*Queries) GetEventSources

func (q *Queries) GetEventSources(ctx context.Context, eventID pgtype.UUID) ([]GetEventSourcesRow, error)

SQLc queries for provenance tracking. Retrieves all sources for a given event with source metadata and timestamps (FR-029)

func (*Queries) GetEventTombstoneByEventID

func (q *Queries) GetEventTombstoneByEventID(ctx context.Context, eventID pgtype.UUID) (EventTombstone, error)

func (*Queries) GetEventTombstoneByEventULID

func (q *Queries) GetEventTombstoneByEventULID(ctx context.Context, ulid string) (EventTombstone, error)

func (*Queries) GetEventTombstoneByURI

func (q *Queries) GetEventTombstoneByURI(ctx context.Context, eventUri string) (EventTombstone, error)

func (*Queries) GetFederationNodeByDomain

func (q *Queries) GetFederationNodeByDomain(ctx context.Context, nodeDomain string) (FederationNode, error)

func (*Queries) GetFederationNodeByID

func (q *Queries) GetFederationNodeByID(ctx context.Context, id pgtype.UUID) (FederationNode, error)

func (*Queries) GetFieldProvenance

func (q *Queries) GetFieldProvenance(ctx context.Context, eventID pgtype.UUID) ([]GetFieldProvenanceRow, error)

Retrieves field-level provenance for an event, optionally filtered by field paths Includes source metadata and timestamps per FR-024 and FR-029

func (*Queries) GetFieldProvenanceForPaths

func (q *Queries) GetFieldProvenanceForPaths(ctx context.Context, arg GetFieldProvenanceForPathsParams) ([]GetFieldProvenanceForPathsRow, error)

Retrieves field-level provenance for specific field paths on an event

func (*Queries) GetIdempotencyKey

func (q *Queries) GetIdempotencyKey(ctx context.Context, key string) (GetIdempotencyKeyRow, error)

func (*Queries) GetLastSuccessfulRunBySource

func (q *Queries) GetLastSuccessfulRunBySource(ctx context.Context, sourceName string) (ScraperRun, error)

Get the most recent successful (completed) scraper run for a given source_name.

func (*Queries) GetLatestEventChange

func (q *Queries) GetLatestEventChange(ctx context.Context) (GetLatestEventChangeRow, error)

func (*Queries) GetLatestScraperRunBySource

func (q *Queries) GetLatestScraperRunBySource(ctx context.Context, sourceName string) (ScraperRun, error)

Get the most recent scraper run for a given source_name.

func (*Queries) GetOccurrenceByID

func (q *Queries) GetOccurrenceByID(ctx context.Context, arg GetOccurrenceByIDParams) (GetOccurrenceByIDRow, error)

Fetch a single occurrence row by its UUID, scoped to the given event.

func (*Queries) GetOrganizationByULID

func (q *Queries) GetOrganizationByULID(ctx context.Context, ulid string) (GetOrganizationByULIDRow, error)

func (*Queries) GetOrganizationTombstoneByULID

func (q *Queries) GetOrganizationTombstoneByULID(ctx context.Context, ulid string) (OrganizationTombstone, error)

func (*Queries) GetPendingReviewByEventUlid

func (q *Queries) GetPendingReviewByEventUlid(ctx context.Context, eventUlid string) (GetPendingReviewByEventUlidRow, error)

Get the pending review queue entry for an event by its ULID, if any.

func (*Queries) GetPendingReviewByEventUlidAndDuplicateUlid

Get the pending review queue entry for an event by its ULID, narrowed to the specific companion whose duplicate_of_event_id points to the counterpart event. Used by the add-occurrence workflow to avoid picking an unrelated pending review when the same event has multiple pending review rows.

func (*Queries) GetPlaceByULID

func (q *Queries) GetPlaceByULID(ctx context.Context, ulid string) (GetPlaceByULIDRow, error)

func (*Queries) GetPlaceTombstoneByULID

func (q *Queries) GetPlaceTombstoneByULID(ctx context.Context, ulid string) (PlaceTombstone, error)

func (*Queries) GetRecentSubmissionByURLNorm

func (q *Queries) GetRecentSubmissionByURLNorm(ctx context.Context, arg GetRecentSubmissionByURLNormParams) (ScraperSubmission, error)

Check if a url_norm was submitted within the given interval (for dedup). Returns the most recent matching row if found.

func (*Queries) GetReconciliationCache

func (q *Queries) GetReconciliationCache(ctx context.Context, arg GetReconciliationCacheParams) (ReconciliationCache, error)

Check cache for a previous reconciliation result

func (*Queries) GetReviewQueueEntry

func (q *Queries) GetReviewQueueEntry(ctx context.Context, id int32) (GetReviewQueueEntryRow, error)

Get single review by ID

func (*Queries) GetScraperConfig

func (q *Queries) GetScraperConfig(ctx context.Context) (ScraperConfig, error)

func (*Queries) GetScraperSourceByID

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

Get a single scraper source by primary key.

func (*Queries) GetScraperSourceByName

func (q *Queries) GetScraperSourceByName(ctx context.Context, name string) (GetScraperSourceByNameRow, error)

Get a single scraper source by unique name.

func (*Queries) GetSourceByID

func (q *Queries) GetSourceByID(ctx context.Context, id pgtype.UUID) (GetSourceByIDRow, error)

Retrieves source metadata by ID

func (*Queries) GetSourcesByEventID

func (q *Queries) GetSourcesByEventID(ctx context.Context, eventID pgtype.UUID) ([]GetSourcesByEventIDRow, error)

Gets all sources that contributed to an event (deduplicated)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error)

SQLc queries for authentication.

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDRow, error)

func (*Queries) GetUserByUsername

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

func (*Queries) GetUserInvitationByTokenHash

func (q *Queries) GetUserInvitationByTokenHash(ctx context.Context, tokenHash string) (UserInvitation, error)

func (*Queries) InsertEventSource

func (q *Queries) InsertEventSource(ctx context.Context, arg InsertEventSourceParams) (EventSource, error)

Records a source's contribution to an event with source and received timestamps (FR-029)

func (*Queries) InsertFieldProvenance

func (q *Queries) InsertFieldProvenance(ctx context.Context, arg InsertFieldProvenanceParams) (FieldProvenance, error)

Records field-level provenance with source timestamp

func (*Queries) InsertIdempotencyKey

func (q *Queries) InsertIdempotencyKey(ctx context.Context, arg InsertIdempotencyKeyParams) (InsertIdempotencyKeyRow, error)

func (*Queries) InsertNotDuplicate

func (q *Queries) InsertNotDuplicate(ctx context.Context, arg InsertNotDuplicateParams) error

SQLc queries for event_not_duplicates table. Tracks pairs of events that an admin has confirmed are NOT duplicates, preventing them from being re-flagged during near-duplicate detection. Record that two events are confirmed as NOT duplicates. Uses canonical ordering (smaller ULID first) to prevent storing both (A,B) and (B,A). ON CONFLICT DO NOTHING handles the case where the pair already exists.

func (*Queries) InsertOccurrence

func (q *Queries) InsertOccurrence(ctx context.Context, arg InsertOccurrenceParams) (InsertOccurrenceRow, error)

Insert a single occurrence and return the created row (including generated UUID).

func (*Queries) InsertScraperRun

func (q *Queries) InsertScraperRun(ctx context.Context, arg InsertScraperRunParams) (int64, error)

SQLc queries for scraper runs tracking. Insert a new scraper run record and return its id.

func (*Queries) InsertScraperSubmission

func (q *Queries) InsertScraperSubmission(ctx context.Context, arg InsertScraperSubmissionParams) (ScraperSubmission, error)

SQLc queries for scraper_submissions. Insert a new URL submission and return the full row.

func (*Queries) IsNotDuplicate

func (q *Queries) IsNotDuplicate(ctx context.Context, arg IsNotDuplicateParams) (bool, error)

Check if a pair of events has been marked as not-duplicates. Uses canonical ordering to match regardless of argument order.

func (*Queries) LinkOrgScraperSource

func (q *Queries) LinkOrgScraperSource(ctx context.Context, arg LinkOrgScraperSourceParams) error

Associate an organization with a scraper source.

func (*Queries) LinkPlaceScraperSource

func (q *Queries) LinkPlaceScraperSource(ctx context.Context, arg LinkPlaceScraperSourceParams) error

Associate a place with a scraper source.

func (*Queries) ListAPIKeys

func (q *Queries) ListAPIKeys(ctx context.Context) ([]ListAPIKeysRow, error)

func (*Queries) ListActiveDeveloperInvitations

func (q *Queries) ListActiveDeveloperInvitations(ctx context.Context) ([]DeveloperInvitation, error)

func (*Queries) ListDeveloperAPIKeys

func (q *Queries) ListDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) ([]ApiKey, error)

Developer API key operations

func (*Queries) ListDevelopers

func (q *Queries) ListDevelopers(ctx context.Context, arg ListDevelopersParams) ([]Developer, error)

func (*Queries) ListEventChanges

func (q *Queries) ListEventChanges(ctx context.Context, arg ListEventChangesParams) ([]ListEventChangesRow, error)

SQLc queries for change feeds.

func (*Queries) ListEventTombstones

func (q *Queries) ListEventTombstones(ctx context.Context, arg ListEventTombstonesParams) ([]EventTombstone, error)

func (*Queries) ListFederationNodes

func (q *Queries) ListFederationNodes(ctx context.Context, arg ListFederationNodesParams) ([]FederationNode, error)

func (*Queries) ListNotDuplicatesForEvent

func (q *Queries) ListNotDuplicatesForEvent(ctx context.Context, eventID string) ([]EventNotDuplicate, error)

List all events that have been confirmed as NOT duplicates of a given event. Returns both sides of the pair (the given event could be event_id_a or event_id_b).

func (*Queries) ListOrganizationsByCreatedAt

func (q *Queries) ListOrganizationsByCreatedAt(ctx context.Context, arg ListOrganizationsByCreatedAtParams) ([]ListOrganizationsByCreatedAtRow, error)

SQLc queries for organizations domain.

func (*Queries) ListOrganizationsByName

func (q *Queries) ListOrganizationsByName(ctx context.Context, arg ListOrganizationsByNameParams) ([]ListOrganizationsByNameRow, error)

func (*Queries) ListPendingInvitationsForUser

func (q *Queries) ListPendingInvitationsForUser(ctx context.Context, userID pgtype.UUID) ([]ListPendingInvitationsForUserRow, error)

func (*Queries) ListPendingValidation

func (q *Queries) ListPendingValidation(ctx context.Context, limit int32) ([]ScraperSubmission, error)

Fetch up to N rows awaiting async URL validation, oldest first.

func (*Queries) ListPlacesByCreatedAt

func (q *Queries) ListPlacesByCreatedAt(ctx context.Context, arg ListPlacesByCreatedAtParams) ([]ListPlacesByCreatedAtRow, error)

SQLc queries for places domain.

func (*Queries) ListPlacesByCreatedAtDesc

func (q *Queries) ListPlacesByCreatedAtDesc(ctx context.Context, arg ListPlacesByCreatedAtDescParams) ([]ListPlacesByCreatedAtDescRow, error)

func (*Queries) ListPlacesByName

func (q *Queries) ListPlacesByName(ctx context.Context, arg ListPlacesByNameParams) ([]ListPlacesByNameRow, error)

func (*Queries) ListPlacesByNameDesc

func (q *Queries) ListPlacesByNameDesc(ctx context.Context, arg ListPlacesByNameDescParams) ([]ListPlacesByNameDescRow, error)

func (*Queries) ListRecentScraperRuns

func (q *Queries) ListRecentScraperRuns(ctx context.Context, limit int32) ([]ScraperRun, error)

List the N most recent scraper runs ordered by started_at DESC.

func (*Queries) ListRecentScraperRunsFiltered

func (q *Queries) ListRecentScraperRunsFiltered(ctx context.Context, arg ListRecentScraperRunsFilteredParams) ([]ScraperRun, error)

List recent scraper runs with optional status and source_name filters.

func (*Queries) ListReviewQueue

func (q *Queries) ListReviewQueue(ctx context.Context, arg ListReviewQueueParams) ([]ListReviewQueueRow, error)

List reviews with pagination and status filter

func (*Queries) ListScraperRunsBySource

func (q *Queries) ListScraperRunsBySource(ctx context.Context, arg ListScraperRunsBySourceParams) ([]ScraperRun, error)

List recent scraper runs for a specific source, ordered newest first.

func (*Queries) ListScraperSources

func (q *Queries) ListScraperSources(ctx context.Context, enabled pgtype.Bool) ([]ListScraperSourcesRow, error)

List all scraper sources, optionally filtered by enabled flag.

func (*Queries) ListScraperSourcesByOrg

func (q *Queries) ListScraperSourcesByOrg(ctx context.Context, organizationID pgtype.UUID) ([]ListScraperSourcesByOrgRow, error)

List all scraper sources linked to a given organization.

func (*Queries) ListScraperSourcesByPlace

func (q *Queries) ListScraperSourcesByPlace(ctx context.Context, placeID pgtype.UUID) ([]ListScraperSourcesByPlaceRow, error)

List all scraper sources linked to a given place.

func (*Queries) ListScraperSourcesWithLatestRun

func (q *Queries) ListScraperSourcesWithLatestRun(ctx context.Context, enabled pgtype.Bool) ([]ListScraperSourcesWithLatestRunRow, error)

List all scraper sources with their most recent run stats embedded. last_run_started_at/completed_at/error_message are nullable (NULL when a source has never been run). status and event counts use COALESCE to return non-nullable defaults so SQLc generates simple string/int32 types for those columns.

func (*Queries) ListScraperSubmissions

func (q *Queries) ListScraperSubmissions(ctx context.Context, arg ListScraperSubmissionsParams) ([]ScraperSubmission, error)

Paginated list of submissions, optionally filtered by status (for admin).

func (*Queries) ListUnreconciledOrganizations

func (q *Queries) ListUnreconciledOrganizations(ctx context.Context, maxResults int32) ([]ListUnreconciledOrganizationsRow, error)

Get organizations that have no external identifiers, ordered by creation date

func (*Queries) ListUnreconciledPlaces

func (q *Queries) ListUnreconciledPlaces(ctx context.Context, maxResults int32) ([]ListUnreconciledPlacesRow, error)

Get places that have no external identifiers, ordered by creation date

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context) ([]ListUsersRow, error)

func (*Queries) ListUsersWithFilters

func (q *Queries) ListUsersWithFilters(ctx context.Context, arg ListUsersWithFiltersParams) ([]ListUsersWithFiltersRow, error)

func (*Queries) MarkInvitationAccepted

func (q *Queries) MarkInvitationAccepted(ctx context.Context, id pgtype.UUID) error

func (*Queries) MarkUnreviewedEventsAsDeleted

func (q *Queries) MarkUnreviewedEventsAsDeleted(ctx context.Context) error

Mark events as deleted before cleaning up their pending reviews

func (*Queries) MergeEventIntoDuplicate

func (q *Queries) MergeEventIntoDuplicate(ctx context.Context, arg MergeEventIntoDuplicateParams) error

func (*Queries) RejectReview

func (q *Queries) RejectReview(ctx context.Context, arg RejectReviewParams) (EventReviewQueue, error)

Mark review as rejected

func (*Queries) ResolveCanonicalEventULID

func (q *Queries) ResolveCanonicalEventULID(ctx context.Context, ulid string) (string, error)

Follow the merged_into_id chain from a given ULID to find the final canonical event. Uses a recursive CTE with a max depth of 10 to prevent infinite loops. Returns the ULID of the final canonical event (the one that is not itself merged).

func (*Queries) RevokeAllDeveloperAPIKeys

func (q *Queries) RevokeAllDeveloperAPIKeys(ctx context.Context, developerID pgtype.UUID) (int64, error)

func (*Queries) SetScraperConfig

func (q *Queries) SetScraperConfig(ctx context.Context, arg SetScraperConfigParams) error

func (*Queries) SetScraperSourceEnabled

func (q *Queries) SetScraperSourceEnabled(ctx context.Context, arg SetScraperSourceEnabledParams) (SetScraperSourceEnabledRow, error)

Enable or disable a scraper source by name. Returns the updated row.

func (*Queries) SoftDeleteEvent

func (q *Queries) SoftDeleteEvent(ctx context.Context, arg SoftDeleteEventParams) error

func (*Queries) SoftDeleteOrganization

func (q *Queries) SoftDeleteOrganization(ctx context.Context, arg SoftDeleteOrganizationParams) error

func (*Queries) SoftDeletePlace

func (q *Queries) SoftDeletePlace(ctx context.Context, arg SoftDeletePlaceParams) error

func (*Queries) StripRetiredDupWarnings

func (q *Queries) StripRetiredDupWarnings(ctx context.Context, arg StripRetiredDupWarningsParams) (bool, error)

Atomically strips all duplicate warning entries referencing any of the given retire_ulids from a specific review row. Handles three warning types:

near_duplicate_of_new_event  — stripped when duplicate_of_event_id points to a retired event
potential_duplicate          — specific match entries filtered; warning nullified when matches empty
cross_week_series_companion  — stripped when details->>'companion_ulid' is in the retire set

Also clears duplicate_of_event_id if it points to a retired event. Returns true (warnings_empty) when the resulting warnings array is empty after stripping. Note: companion replacement is handled in Go after SQL returns.

func (*Queries) SupersedeFieldProvenance

func (q *Queries) SupersedeFieldProvenance(ctx context.Context, arg SupersedeFieldProvenanceParams) error

Marks a field provenance record as superseded by a new record

func (*Queries) UnlinkOrgScraperSource

func (q *Queries) UnlinkOrgScraperSource(ctx context.Context, arg UnlinkOrgScraperSourceParams) error

Remove an organization↔scraper source association.

func (*Queries) UnlinkPlaceScraperSource

func (q *Queries) UnlinkPlaceScraperSource(ctx context.Context, arg UnlinkPlaceScraperSourceParams) error

Remove a place↔scraper source association.

func (*Queries) UpdateAPIKeyLastUsed

func (q *Queries) UpdateAPIKeyLastUsed(ctx context.Context, id pgtype.UUID) error

func (*Queries) UpdateDeveloper

func (q *Queries) UpdateDeveloper(ctx context.Context, arg UpdateDeveloperParams) (Developer, error)

func (*Queries) UpdateDeveloperLastLogin

func (q *Queries) UpdateDeveloperLastLogin(ctx context.Context, id pgtype.UUID) error

func (*Queries) UpdateEvent

func (q *Queries) UpdateEvent(ctx context.Context, arg UpdateEventParams) (UpdateEventRow, error)

func (*Queries) UpdateFederationNode

func (q *Queries) UpdateFederationNode(ctx context.Context, arg UpdateFederationNodeParams) (FederationNode, error)

func (*Queries) UpdateFederationNodeHealth

func (q *Queries) UpdateFederationNodeHealth(ctx context.Context, arg UpdateFederationNodeHealthParams) error

func (*Queries) UpdateFederationNodeSyncStatus

func (q *Queries) UpdateFederationNodeSyncStatus(ctx context.Context, arg UpdateFederationNodeSyncStatusParams) error

func (*Queries) UpdateLastLogin

func (q *Queries) UpdateLastLogin(ctx context.Context, id pgtype.UUID) error

func (*Queries) UpdateMergedIntoChain

func (q *Queries) UpdateMergedIntoChain(ctx context.Context, arg UpdateMergedIntoChainParams) error

Flatten existing merge chains: update all events that point to an old target to point to the new canonical target instead. This prevents transitive chains. $1 = old target event ULID (intermediate node being re-pointed) $2 = new canonical target event ULID (final destination)

func (*Queries) UpdateOccurrenceByID

func (q *Queries) UpdateOccurrenceByID(ctx context.Context, arg UpdateOccurrenceByIDParams) (UpdateOccurrenceByIDRow, error)

Partial-update a single occurrence row, scoped to the given event. Only non-NULL arguments are applied (COALESCE pattern). venue_id, virtual_url, ticket_url use explicit NULLability via CASE WHEN *_set pattern.

func (*Queries) UpdateOccurrenceDatesByEventULID

func (q *Queries) UpdateOccurrenceDatesByEventULID(ctx context.Context, arg UpdateOccurrenceDatesByEventULIDParams) error

Update the start_time and end_time of all occurrences for an event identified by ULID. Used by the FixReview workflow to correct occurrence dates during admin review.

func (*Queries) UpdateOrganization

func (q *Queries) UpdateOrganization(ctx context.Context, arg UpdateOrganizationParams) (UpdateOrganizationRow, error)

func (*Queries) UpdatePlace

func (q *Queries) UpdatePlace(ctx context.Context, arg UpdatePlaceParams) (UpdatePlaceRow, error)

func (*Queries) UpdateReviewQueueEntry

func (q *Queries) UpdateReviewQueueEntry(ctx context.Context, arg UpdateReviewQueueEntryParams) (EventReviewQueue, error)

Update existing review entry (for resubmissions with same issues). Pass clear_duplicate_of=TRUE to set duplicate_of_event_id to NULL; otherwise pass a new UUID via duplicate_of_event_id or leave both NULL to keep the existing value.

func (*Queries) UpdateReviewWarnings

func (q *Queries) UpdateReviewWarnings(ctx context.Context, arg UpdateReviewWarningsParams) error

Update only the warnings JSON of a review queue entry (used for companion warning dismissal).

func (*Queries) UpdateScraperRunCompleted

func (q *Queries) UpdateScraperRunCompleted(ctx context.Context, arg UpdateScraperRunCompletedParams) error

Mark a scraper run as completed with event counts and optional per-event failure metadata.

func (*Queries) UpdateScraperRunFailed

func (q *Queries) UpdateScraperRunFailed(ctx context.Context, arg UpdateScraperRunFailedParams) error

Mark a scraper run as failed with an error message.

func (*Queries) UpdateScraperSourceLastScraped

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

Update last_scraped_at timestamp after a successful scrape run.

func (*Queries) UpdateSubmissionAdminReview

func (q *Queries) UpdateSubmissionAdminReview(ctx context.Context, arg UpdateSubmissionAdminReviewParams) (ScraperSubmission, error)

Update status and optional notes for a given row (admin PATCH). Returns the full updated row.

func (*Queries) UpdateSubmissionStatus

func (q *Queries) UpdateSubmissionStatus(ctx context.Context, arg UpdateSubmissionStatusParams) error

Update status, optional rejection_reason, and optional validated_at for a given row. Used by the background validation worker.

func (*Queries) UpdateUser

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

func (*Queries) UpdateUserPassword

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func (*Queries) UpsertAPIKeyUsage

func (q *Queries) UpsertAPIKeyUsage(ctx context.Context, arg UpsertAPIKeyUsageParams) error

SQLc queries for API key usage tracking.

func (*Queries) UpsertAPIKeyUsageIP

func (q *Queries) UpsertAPIKeyUsageIP(ctx context.Context, arg UpsertAPIKeyUsageIPParams) error

func (*Queries) UpsertEntityIdentifier

func (q *Queries) UpsertEntityIdentifier(ctx context.Context, arg UpsertEntityIdentifierParams) (EntityIdentifier, error)

Insert or update an entity identifier (sameAs link)

func (*Queries) UpsertFederatedEvent

func (q *Queries) UpsertFederatedEvent(ctx context.Context, arg UpsertFederatedEventParams) (Event, error)

func (*Queries) UpsertReconciliationCache

func (q *Queries) UpsertReconciliationCache(ctx context.Context, arg UpsertReconciliationCacheParams) (ReconciliationCache, error)

Insert or update a cache entry

func (*Queries) UpsertScraperSource

func (q *Queries) UpsertScraperSource(ctx context.Context, arg UpsertScraperSourceParams) (UpsertScraperSourceRow, error)

SQLc queries for scraper_sources and linkage tables. Insert or update a scraper source by name (used by 'server scrape sync').

func (*Queries) WithTx

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

type ReconciliationCache

type ReconciliationCache struct {
	ID            int32              `json:"id"`
	EntityType    string             `json:"entity_type"`
	AuthorityCode string             `json:"authority_code"`
	LookupKey     string             `json:"lookup_key"`
	ResultJson    []byte             `json:"result_json"`
	HitCount      int32              `json:"hit_count"`
	IsNegative    bool               `json:"is_negative"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

type RejectReviewParams

type RejectReviewParams struct {
	ReviewedBy pgtype.Text `json:"reviewed_by"`
	Reason     pgtype.Text `json:"reason"`
	ID         int32       `json:"id"`
}

type Repository

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

Repository implements storage.Repository interface with PostgreSQL backend

func NewRepository

func NewRepository(pool *pgxpool.Pool, logger zerolog.Logger) (*Repository, error)

NewRepository creates a new PostgreSQL-backed repository

func (*Repository) Auth

func (r *Repository) Auth() storage.AuthRepository

Auth returns the auth repository

func (*Repository) Developers

func (r *Repository) Developers() storage.DeveloperRepository

Developers returns the developers repository

func (*Repository) Events

func (r *Repository) Events() storage.EventRepository

Events returns the events repository

func (*Repository) Federation

func (r *Repository) Federation() storage.FederationRepository

Federation returns the federation repository

func (*Repository) Organizations

func (r *Repository) Organizations() storage.OrganizationRepository

Organizations returns the organizations repository

func (*Repository) Places

func (r *Repository) Places() storage.PlaceRepository

Places returns the places repository

func (*Repository) Provenance

func (r *Repository) Provenance() storage.ProvenanceRepository

Provenance returns the provenance repository

func (*Repository) Sources

func (r *Repository) Sources() storage.SourceRepository

Sources returns the sources repository (placeholder)

func (*Repository) WithTx

WithTx executes a function within a database transaction

type ReverseGeocodingCache

type ReverseGeocodingCache struct {
	ID              int64              `json:"id"`
	Latitude        float64            `json:"latitude"`
	Longitude       float64            `json:"longitude"`
	GeoPoint        interface{}        `json:"geo_point"`
	DisplayName     string             `json:"display_name"`
	AddressRoad     pgtype.Text        `json:"address_road"`
	AddressSuburb   pgtype.Text        `json:"address_suburb"`
	AddressCity     pgtype.Text        `json:"address_city"`
	AddressState    pgtype.Text        `json:"address_state"`
	AddressPostcode pgtype.Text        `json:"address_postcode"`
	AddressCountry  pgtype.Text        `json:"address_country"`
	OsmID           pgtype.Int8        `json:"osm_id"`
	RawResponse     []byte             `json:"raw_response"`
	HitCount        int32              `json:"hit_count"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	ExpiresAt       pgtype.Timestamptz `json:"expires_at"`
}

type ScraperConfig

type ScraperConfig struct {
	ID                    int32              `json:"id"`
	AutoScrape            bool               `json:"auto_scrape"`
	MaxConcurrentSources  int32              `json:"max_concurrent_sources"`
	RequestTimeoutSeconds int32              `json:"request_timeout_seconds"`
	RetryMaxAttempts      int32              `json:"retry_max_attempts"`
	MaxBatchSize          int32              `json:"max_batch_size"`
	RateLimitMs           int32              `json:"rate_limit_ms"`
	UpdatedAt             pgtype.Timestamptz `json:"updated_at"`
}

type ScraperRun

type ScraperRun struct {
	ID           int64              `json:"id"`
	SourceName   string             `json:"source_name"`
	SourceUrl    string             `json:"source_url"`
	Tier         int32              `json:"tier"`
	StartedAt    pgtype.Timestamptz `json:"started_at"`
	CompletedAt  pgtype.Timestamptz `json:"completed_at"`
	Status       string             `json:"status"`
	EventsFound  int32              `json:"events_found"`
	EventsNew    int32              `json:"events_new"`
	EventsDup    int32              `json:"events_dup"`
	EventsFailed int32              `json:"events_failed"`
	ErrorMessage pgtype.Text        `json:"error_message"`
	Metadata     []byte             `json:"metadata"`
}

type ScraperSource

type ScraperSource struct {
	ID                            int64              `json:"id"`
	Name                          string             `json:"name"`
	Url                           string             `json:"url"`
	Tier                          int32              `json:"tier"`
	Schedule                      string             `json:"schedule"`
	TrustLevel                    int32              `json:"trust_level"`
	License                       string             `json:"license"`
	Enabled                       bool               `json:"enabled"`
	MaxPages                      int32              `json:"max_pages"`
	Selectors                     []byte             `json:"selectors"`
	Notes                         pgtype.Text        `json:"notes"`
	LastScrapedAt                 pgtype.Timestamptz `json:"last_scraped_at"`
	CreatedAt                     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt                     pgtype.Timestamptz `json:"updated_at"`
	HeadlessWaitSelector          pgtype.Text        `json:"headless_wait_selector"`
	HeadlessWaitTimeoutMs         int32              `json:"headless_wait_timeout_ms"`
	HeadlessPaginationBtn         pgtype.Text        `json:"headless_pagination_btn"`
	HeadlessHeaders               []byte             `json:"headless_headers"`
	HeadlessRateLimitMs           int32              `json:"headless_rate_limit_ms"`
	GraphqlConfig                 []byte             `json:"graphql_config"`
	RestConfig                    []byte             `json:"rest_config"`
	SitemapConfig                 []byte             `json:"sitemap_config"`
	Urls                          []string           `json:"urls"`
	EventUrlPattern               string             `json:"event_url_pattern"`
	SkipMultiSessionCheck         bool               `json:"skip_multi_session_check"`
	MultiSessionDurationThreshold string             `json:"multi_session_duration_threshold"`
	FollowEventUrls               bool               `json:"follow_event_urls"`
	Timezone                      string             `json:"timezone"`
	HeadlessWaitNetworkIdle       bool               `json:"headless_wait_network_idle"`
	HeadlessUndetected            bool               `json:"headless_undetected"`
	HeadlessIframe                []byte             `json:"headless_iframe"`
	HeadlessIntercept             []byte             `json:"headless_intercept"`
	DefaultLocation               []byte             `json:"default_location"`
	ExtractionMethod              string             `json:"extraction_method"`
	InsecureSkipVerify            bool               `json:"insecure_skip_verify"`
	RequestTimeoutSeconds         int32              `json:"request_timeout_seconds"`
	MaxBodyBytes                  int64              `json:"max_body_bytes"`
	EventDomain                   pgtype.Text        `json:"event_domain"`
	TlsFingerprint                string             `json:"tls_fingerprint"`
}

type ScraperSourceRepository

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

ScraperSourceRepository implements scraper.Repository using PostgreSQL.

func NewScraperSourceRepository

func NewScraperSourceRepository(pool *pgxpool.Pool) *ScraperSourceRepository

NewScraperSourceRepository creates a new ScraperSourceRepository.

func (*ScraperSourceRepository) Delete

func (r *ScraperSourceRepository) Delete(ctx context.Context, name string) error

Delete removes a scraper source by name.

func (*ScraperSourceRepository) GetByName

func (r *ScraperSourceRepository) GetByName(ctx context.Context, name string) (*scraper.Source, error)

GetByName returns a scraper source by unique name.

func (*ScraperSourceRepository) LinkToOrg

func (r *ScraperSourceRepository) LinkToOrg(ctx context.Context, orgID string, sourceID int64) error

LinkToOrg associates a scraper source with an organization.

func (*ScraperSourceRepository) LinkToPlace

func (r *ScraperSourceRepository) LinkToPlace(ctx context.Context, placeID string, sourceID int64) error

LinkToPlace associates a scraper source with a place.

func (*ScraperSourceRepository) List

func (r *ScraperSourceRepository) List(ctx context.Context, enabled *bool) ([]scraper.Source, error)

List returns all scraper sources, optionally filtered by enabled status.

func (*ScraperSourceRepository) ListByOrg

func (r *ScraperSourceRepository) ListByOrg(ctx context.Context, orgID string) ([]scraper.Source, error)

ListByOrg returns all scraper sources linked to the given organization UUID.

func (*ScraperSourceRepository) ListByPlace

func (r *ScraperSourceRepository) ListByPlace(ctx context.Context, placeID string) ([]scraper.Source, error)

ListByPlace returns all scraper sources linked to the given place UUID.

func (*ScraperSourceRepository) UnlinkFromOrg

func (r *ScraperSourceRepository) UnlinkFromOrg(ctx context.Context, orgID string, sourceID int64) error

UnlinkFromOrg removes a source↔org association.

func (*ScraperSourceRepository) UnlinkFromPlace

func (r *ScraperSourceRepository) UnlinkFromPlace(ctx context.Context, placeID string, sourceID int64) error

UnlinkFromPlace removes a source↔place association.

func (*ScraperSourceRepository) UpdateLastScraped

func (r *ScraperSourceRepository) UpdateLastScraped(ctx context.Context, name string) error

UpdateLastScraped sets last_scraped_at = NOW() for the named source.

func (*ScraperSourceRepository) Upsert

Upsert inserts or updates a scraper source by name.

type ScraperSubmission

type ScraperSubmission struct {
	ID              int64              `json:"id"`
	Url             string             `json:"url"`
	UrlNorm         string             `json:"url_norm"`
	SubmittedAt     pgtype.Timestamptz `json:"submitted_at"`
	SubmitterIp     netip.Addr         `json:"submitter_ip"`
	Status          string             `json:"status"`
	RejectionReason pgtype.Text        `json:"rejection_reason"`
	Notes           pgtype.Text        `json:"notes"`
	ValidatedAt     pgtype.Timestamptz `json:"validated_at"`
}

type ScraperSubmissionRepository

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

ScraperSubmissionRepository implements scraper.SubmissionRepository using PostgreSQL.

func NewScraperSubmissionRepository

func NewScraperSubmissionRepository(pool *pgxpool.Pool) *ScraperSubmissionRepository

NewScraperSubmissionRepository creates a new ScraperSubmissionRepository.

func (*ScraperSubmissionRepository) Count

func (r *ScraperSubmissionRepository) Count(ctx context.Context, status *string) (int64, error)

Count returns the total count of submissions with optional status filter.

func (*ScraperSubmissionRepository) CountPendingValidation

func (r *ScraperSubmissionRepository) CountPendingValidation(ctx context.Context) (int64, error)

CountPendingValidation returns the count of pending_validation rows.

func (*ScraperSubmissionRepository) CountRecentByIP

func (r *ScraperSubmissionRepository) CountRecentByIP(ctx context.Context, ip string) (int64, error)

CountRecentByIP returns the number of URLs submitted from the given IP in the last 24 hours.

func (*ScraperSubmissionRepository) GetRecentByURLNorm

func (r *ScraperSubmissionRepository) GetRecentByURLNorm(ctx context.Context, urlNorm string) (*scraper.Submission, error)

GetRecentByURLNorm returns a submission for the given url_norm within the 30-day dedup window. Returns nil (no error) when no recent submission is found.

func (*ScraperSubmissionRepository) Insert

Insert stores a new submission and returns the stored row.

func (*ScraperSubmissionRepository) List

func (r *ScraperSubmissionRepository) List(ctx context.Context, status *string, limit, offset int) ([]*scraper.Submission, error)

List returns a paginated list of submissions with optional status filter.

func (*ScraperSubmissionRepository) ListPendingValidation

func (r *ScraperSubmissionRepository) ListPendingValidation(ctx context.Context, limit int) ([]*scraper.Submission, error)

ListPendingValidation returns up to limit rows with status pending_validation, oldest first.

func (*ScraperSubmissionRepository) UpdateAdminReview

func (r *ScraperSubmissionRepository) UpdateAdminReview(ctx context.Context, id int64, status string, notes *string) (*scraper.Submission, error)

UpdateAdminReview updates status and notes for a submission, returning the updated row. Returns scraper.ErrNotFound if no submission with the given id exists.

func (*ScraperSubmissionRepository) UpdateStatus

func (r *ScraperSubmissionRepository) UpdateStatus(ctx context.Context, id int64, status string, rejectionReason *string, validatedAt *time.Time) error

UpdateStatus updates status, rejection_reason, and validated_at for a submission.

type SetScraperConfigParams

type SetScraperConfigParams struct {
	AutoScrape            bool  `json:"auto_scrape"`
	MaxConcurrentSources  int32 `json:"max_concurrent_sources"`
	RequestTimeoutSeconds int32 `json:"request_timeout_seconds"`
	RetryMaxAttempts      int32 `json:"retry_max_attempts"`
	MaxBatchSize          int32 `json:"max_batch_size"`
	RateLimitMs           int32 `json:"rate_limit_ms"`
}

type SetScraperSourceEnabledParams

type SetScraperSourceEnabledParams struct {
	Enabled bool   `json:"enabled"`
	Name    string `json:"name"`
}

type SetScraperSourceEnabledRow

type SetScraperSourceEnabledRow struct {
	ScraperSource ScraperSource `json:"scraper_source"`
}

type SoftDeleteEventParams

type SoftDeleteEventParams struct {
	Ulid           string      `json:"ulid"`
	DeletionReason pgtype.Text `json:"deletion_reason"`
}

type SoftDeleteOrganizationParams

type SoftDeleteOrganizationParams struct {
	Ulid           string      `json:"ulid"`
	DeletionReason pgtype.Text `json:"deletion_reason"`
}

type SoftDeletePlaceParams

type SoftDeletePlaceParams struct {
	Ulid           string      `json:"ulid"`
	DeletionReason pgtype.Text `json:"deletion_reason"`
}

type Source

type Source struct {
	ID                     pgtype.UUID        `json:"id"`
	Name                   string             `json:"name"`
	SourceType             string             `json:"source_type"`
	BaseUrl                pgtype.Text        `json:"base_url"`
	ApiEndpoint            pgtype.Text        `json:"api_endpoint"`
	TrustLevel             int32              `json:"trust_level"`
	LicenseUrl             string             `json:"license_url"`
	LicenseType            string             `json:"license_type"`
	RequiresAuthentication pgtype.Bool        `json:"requires_authentication"`
	ApiKeyEncrypted        []byte             `json:"api_key_encrypted"`
	RateLimitRequests      pgtype.Int4        `json:"rate_limit_requests"`
	RateLimitWindowSeconds pgtype.Int4        `json:"rate_limit_window_seconds"`
	ContactEmail           pgtype.Text        `json:"contact_email"`
	ContactUrl             pgtype.Text        `json:"contact_url"`
	IsActive               pgtype.Bool        `json:"is_active"`
	LastSuccessfulFetch    pgtype.Timestamptz `json:"last_successful_fetch"`
	LastError              pgtype.Timestamptz `json:"last_error"`
	LastErrorMessage       pgtype.Text        `json:"last_error_message"`
	Config                 []byte             `json:"config"`
	Notes                  pgtype.Text        `json:"notes"`
	CreatedAt              pgtype.Timestamptz `json:"created_at"`
	UpdatedAt              pgtype.Timestamptz `json:"updated_at"`
}

type StripRetiredDupWarningsParams

type StripRetiredDupWarningsParams struct {
	RetireUlids []string `json:"retire_ulids"`
	ReviewID    int32    `json:"review_id"`
}

type SupersedeFieldProvenanceParams

type SupersedeFieldProvenanceParams struct {
	ID             pgtype.UUID `json:"id"`
	SupersededByID pgtype.UUID `json:"superseded_by_id"`
}

type SyncRepository

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

SyncRepository implements federation.SyncRepository using SQLc queries.

func NewSyncRepository

func NewSyncRepository(pool *pgxpool.Pool, queries *Queries) *SyncRepository

NewSyncRepository creates a new sync repository.

func (*SyncRepository) CreateOccurrence

func (r *SyncRepository) CreateOccurrence(ctx context.Context, params federation.OccurrenceCreateParams) error

CreateOccurrence creates an event occurrence for a federated event.

func (*SyncRepository) GetEventByFederationURI

func (r *SyncRepository) GetEventByFederationURI(ctx context.Context, federationUri string) (federation.Event, error)

GetEventByFederationURI fetches an event by its federation URI.

func (*SyncRepository) GetFederationNodeByDomain

func (r *SyncRepository) GetFederationNodeByDomain(ctx context.Context, nodeDomain string) (federation.FederationNode, error)

GetFederationNodeByDomain fetches a federation node by domain.

func (*SyncRepository) GetIdempotencyKey

func (r *SyncRepository) GetIdempotencyKey(ctx context.Context, key string) (*federation.IdempotencyKey, error)

GetIdempotencyKey retrieves an idempotency key entry.

func (*SyncRepository) InsertIdempotencyKey

func (r *SyncRepository) InsertIdempotencyKey(ctx context.Context, params federation.IdempotencyKeyParams) error

InsertIdempotencyKey inserts a new idempotency key entry.

func (*SyncRepository) UpsertFederatedEvent

UpsertFederatedEvent upserts a federated event.

func (*SyncRepository) UpsertOrganization

UpsertOrganization upserts an organization with federation URI support.

func (*SyncRepository) UpsertPlace

UpsertPlace upserts a place with federation URI support.

func (*SyncRepository) WithTransaction

func (r *SyncRepository) WithTransaction(ctx context.Context, fn func(txRepo federation.SyncRepository) error) error

WithTransaction executes the given function within a database transaction. If fn returns an error, the transaction is rolled back. Otherwise it's committed.

type UnlinkOrgScraperSourceParams

type UnlinkOrgScraperSourceParams struct {
	OrganizationID  pgtype.UUID `json:"organization_id"`
	ScraperSourceID int64       `json:"scraper_source_id"`
}

type UnlinkPlaceScraperSourceParams

type UnlinkPlaceScraperSourceParams struct {
	PlaceID         pgtype.UUID `json:"place_id"`
	ScraperSourceID int64       `json:"scraper_source_id"`
}

type UpdateDeveloperParams

type UpdateDeveloperParams struct {
	Name           pgtype.Text `json:"name"`
	GithubID       pgtype.Int8 `json:"github_id"`
	GithubUsername pgtype.Text `json:"github_username"`
	MaxKeys        pgtype.Int4 `json:"max_keys"`
	IsActive       pgtype.Bool `json:"is_active"`
	ID             pgtype.UUID `json:"id"`
}

func NewUpdateDeveloperParams

func NewUpdateDeveloperParams(id pgtype.UUID) UpdateDeveloperParams

NewUpdateDeveloperParams creates an UpdateDeveloperParams with only the ID set Call SetX methods to set optional fields

func (*UpdateDeveloperParams) SetGitHubID

func (p *UpdateDeveloperParams) SetGitHubID(id int64)

SetGitHubID sets the github_id field for update

func (*UpdateDeveloperParams) SetGitHubUsername

func (p *UpdateDeveloperParams) SetGitHubUsername(username string)

SetGitHubUsername sets the github_username field for update

func (*UpdateDeveloperParams) SetIsActive

func (p *UpdateDeveloperParams) SetIsActive(isActive bool)

SetIsActive sets the is_active field for update

func (*UpdateDeveloperParams) SetMaxKeys

func (p *UpdateDeveloperParams) SetMaxKeys(maxKeys int32)

SetMaxKeys sets the max_keys field for update

func (*UpdateDeveloperParams) SetName

func (p *UpdateDeveloperParams) SetName(name string)

SetName sets the name field for update

type UpdateEventParams

type UpdateEventParams struct {
	Ulid           string      `json:"ulid"`
	Name           pgtype.Text `json:"name"`
	Description    pgtype.Text `json:"description"`
	LifecycleState pgtype.Text `json:"lifecycle_state"`
	ImageUrl       pgtype.Text `json:"image_url"`
	PublicUrl      pgtype.Text `json:"public_url"`
	EventDomain    pgtype.Text `json:"event_domain"`
	Keywords       []string    `json:"keywords"`
}

type UpdateEventRow

type UpdateEventRow struct {
	ID             pgtype.UUID        `json:"id"`
	Ulid           string             `json:"ulid"`
	Name           string             `json:"name"`
	Description    pgtype.Text        `json:"description"`
	LifecycleState string             `json:"lifecycle_state"`
	EventDomain    pgtype.Text        `json:"event_domain"`
	ImageUrl       pgtype.Text        `json:"image_url"`
	PublicUrl      pgtype.Text        `json:"public_url"`
	Keywords       []string           `json:"keywords"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	UpdatedAt      pgtype.Timestamptz `json:"updated_at"`
}

type UpdateFederationNodeHealthParams

type UpdateFederationNodeHealthParams struct {
	ID       pgtype.UUID `json:"id"`
	IsOnline pgtype.Bool `json:"is_online"`
}

type UpdateFederationNodeParams

type UpdateFederationNodeParams struct {
	NodeName         pgtype.Text `json:"node_name"`
	BaseUrl          pgtype.Text `json:"base_url"`
	ApiVersion       pgtype.Text `json:"api_version"`
	GeographicScope  pgtype.Text `json:"geographic_scope"`
	TrustLevel       pgtype.Int4 `json:"trust_level"`
	FederationStatus pgtype.Text `json:"federation_status"`
	SyncEnabled      pgtype.Bool `json:"sync_enabled"`
	SyncDirection    pgtype.Text `json:"sync_direction"`
	ContactEmail     pgtype.Text `json:"contact_email"`
	ContactName      pgtype.Text `json:"contact_name"`
	Notes            pgtype.Text `json:"notes"`
	ID               pgtype.UUID `json:"id"`
}

type UpdateFederationNodeSyncStatusParams

type UpdateFederationNodeSyncStatusParams struct {
	ID                   pgtype.UUID        `json:"id"`
	LastSyncAt           pgtype.Timestamptz `json:"last_sync_at"`
	LastSuccessfulSyncAt pgtype.Timestamptz `json:"last_successful_sync_at"`
	SyncCursor           pgtype.Text        `json:"sync_cursor"`
	LastErrorMessage     pgtype.Text        `json:"last_error_message"`
}

type UpdateMergedIntoChainParams

type UpdateMergedIntoChainParams struct {
	Ulid   string `json:"ulid"`
	Ulid_2 string `json:"ulid_2"`
}

type UpdateOccurrenceByIDParams

type UpdateOccurrenceByIDParams struct {
	StartTime     pgtype.Timestamptz `json:"start_time"`
	EndTimeSet    pgtype.Bool        `json:"end_time_set"`
	EndTime       pgtype.Timestamptz `json:"end_time"`
	Timezone      pgtype.Text        `json:"timezone"`
	DoorTimeSet   pgtype.Bool        `json:"door_time_set"`
	DoorTime      pgtype.Timestamptz `json:"door_time"`
	VenueIDSet    pgtype.Bool        `json:"venue_id_set"`
	VenueID       pgtype.UUID        `json:"venue_id"`
	VirtualUrlSet pgtype.Bool        `json:"virtual_url_set"`
	VirtualUrl    pgtype.Text        `json:"virtual_url"`
	TicketUrlSet  pgtype.Bool        `json:"ticket_url_set"`
	TicketUrl     pgtype.Text        `json:"ticket_url"`
	PriceMinSet   pgtype.Bool        `json:"price_min_set"`
	PriceMin      pgtype.Numeric     `json:"price_min"`
	PriceMaxSet   pgtype.Bool        `json:"price_max_set"`
	PriceMax      pgtype.Numeric     `json:"price_max"`
	PriceCurrency pgtype.Text        `json:"price_currency"`
	Availability  pgtype.Text        `json:"availability"`
	ID            pgtype.UUID        `json:"id"`
	EventID       pgtype.UUID        `json:"event_id"`
}

type UpdateOccurrenceByIDRow

type UpdateOccurrenceByIDRow struct {
	ID            pgtype.UUID        `json:"id"`
	EventID       pgtype.UUID        `json:"event_id"`
	StartTime     pgtype.Timestamptz `json:"start_time"`
	EndTime       pgtype.Timestamptz `json:"end_time"`
	Timezone      string             `json:"timezone"`
	DoorTime      pgtype.Timestamptz `json:"door_time"`
	VenueID       pgtype.UUID        `json:"venue_id"`
	VirtualUrl    pgtype.Text        `json:"virtual_url"`
	TicketUrl     pgtype.Text        `json:"ticket_url"`
	PriceMin      pgtype.Numeric     `json:"price_min"`
	PriceMax      pgtype.Numeric     `json:"price_max"`
	PriceCurrency pgtype.Text        `json:"price_currency"`
	Availability  pgtype.Text        `json:"availability"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
	VenueUlid     string             `json:"venue_ulid"`
}

type UpdateOccurrenceDatesByEventULIDParams

type UpdateOccurrenceDatesByEventULIDParams struct {
	StartTime pgtype.Timestamptz `json:"start_time"`
	EndTime   pgtype.Timestamptz `json:"end_time"`
	EventUlid string             `json:"event_ulid"`
}

type UpdateOrganizationParams

type UpdateOrganizationParams struct {
	Ulid            string      `json:"ulid"`
	Name            pgtype.Text `json:"name"`
	Description     pgtype.Text `json:"description"`
	StreetAddress   pgtype.Text `json:"street_address"`
	AddressLocality pgtype.Text `json:"address_locality"`
	AddressRegion   pgtype.Text `json:"address_region"`
	PostalCode      pgtype.Text `json:"postal_code"`
	AddressCountry  pgtype.Text `json:"address_country"`
	Telephone       pgtype.Text `json:"telephone"`
	Email           pgtype.Text `json:"email"`
	Url             pgtype.Text `json:"url"`
}

type UpdateOrganizationRow

type UpdateOrganizationRow struct {
	Organization Organization `json:"organization"`
}

type UpdatePlaceParams

type UpdatePlaceParams struct {
	Ulid            string      `json:"ulid"`
	Name            pgtype.Text `json:"name"`
	Description     pgtype.Text `json:"description"`
	StreetAddress   pgtype.Text `json:"street_address"`
	AddressLocality pgtype.Text `json:"address_locality"`
	AddressRegion   pgtype.Text `json:"address_region"`
	PostalCode      pgtype.Text `json:"postal_code"`
	AddressCountry  pgtype.Text `json:"address_country"`
	Telephone       pgtype.Text `json:"telephone"`
	Email           pgtype.Text `json:"email"`
	Url             pgtype.Text `json:"url"`
}

type UpdatePlaceRow

type UpdatePlaceRow struct {
	Place Place `json:"place"`
}

type UpdateReviewQueueEntryParams

type UpdateReviewQueueEntryParams struct {
	OriginalPayload    []byte      `json:"original_payload"`
	NormalizedPayload  []byte      `json:"normalized_payload"`
	Warnings           []byte      `json:"warnings"`
	ClearDuplicateOf   pgtype.Bool `json:"clear_duplicate_of"`
	DuplicateOfEventID pgtype.UUID `json:"duplicate_of_event_id"`
	ID                 int32       `json:"id"`
}

type UpdateReviewWarningsParams

type UpdateReviewWarningsParams struct {
	Warnings []byte `json:"warnings"`
	ID       int32  `json:"id"`
}

type UpdateScraperRunCompletedParams

type UpdateScraperRunCompletedParams struct {
	EventsFound  int32  `json:"events_found"`
	EventsNew    int32  `json:"events_new"`
	EventsDup    int32  `json:"events_dup"`
	EventsFailed int32  `json:"events_failed"`
	Metadata     []byte `json:"metadata"`
	ID           int64  `json:"id"`
}

type UpdateScraperRunFailedParams

type UpdateScraperRunFailedParams struct {
	ErrorMessage pgtype.Text `json:"error_message"`
	ID           int64       `json:"id"`
}

type UpdateSubmissionAdminReviewParams

type UpdateSubmissionAdminReviewParams struct {
	Status string      `json:"status"`
	Notes  pgtype.Text `json:"notes"`
	ID     int64       `json:"id"`
}

type UpdateSubmissionStatusParams

type UpdateSubmissionStatusParams struct {
	Status          string             `json:"status"`
	RejectionReason pgtype.Text        `json:"rejection_reason"`
	ValidatedAt     pgtype.Timestamptz `json:"validated_at"`
	ID              int64              `json:"id"`
}

type UpdateUserParams

type UpdateUserParams struct {
	ID       pgtype.UUID `json:"id"`
	Username string      `json:"username"`
	Email    string      `json:"email"`
	Role     string      `json:"role"`
	IsActive bool        `json:"is_active"`
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	ID           pgtype.UUID `json:"id"`
	PasswordHash string      `json:"password_hash"`
}

type UpsertAPIKeyUsageIPParams

type UpsertAPIKeyUsageIPParams struct {
	ApiKeyID     pgtype.UUID `json:"api_key_id"`
	Date         pgtype.Date `json:"date"`
	Ip           netip.Addr  `json:"ip"`
	RequestCount int64       `json:"request_count"`
	ErrorCount   int64       `json:"error_count"`
}

type UpsertAPIKeyUsageParams

type UpsertAPIKeyUsageParams struct {
	ApiKeyID     pgtype.UUID `json:"api_key_id"`
	Date         pgtype.Date `json:"date"`
	RequestCount int64       `json:"request_count"`
	ErrorCount   int64       `json:"error_count"`
}

type UpsertEntityIdentifierParams

type UpsertEntityIdentifierParams struct {
	EntityType           string         `json:"entity_type"`
	EntityID             string         `json:"entity_id"`
	AuthorityCode        string         `json:"authority_code"`
	IdentifierUri        string         `json:"identifier_uri"`
	Confidence           pgtype.Numeric `json:"confidence"`
	ReconciliationMethod string         `json:"reconciliation_method"`
	IsCanonical          bool           `json:"is_canonical"`
	Metadata             []byte         `json:"metadata"`
}

type UpsertFederatedEventParams

type UpsertFederatedEventParams struct {
	Ulid                  string             `json:"ulid"`
	Name                  string             `json:"name"`
	Description           pgtype.Text        `json:"description"`
	LifecycleState        string             `json:"lifecycle_state"`
	EventStatus           pgtype.Text        `json:"event_status"`
	AttendanceMode        pgtype.Text        `json:"attendance_mode"`
	OrganizerID           pgtype.UUID        `json:"organizer_id"`
	PrimaryVenueID        pgtype.UUID        `json:"primary_venue_id"`
	SeriesID              pgtype.UUID        `json:"series_id"`
	ImageUrl              pgtype.Text        `json:"image_url"`
	PublicUrl             pgtype.Text        `json:"public_url"`
	VirtualUrl            pgtype.Text        `json:"virtual_url"`
	Keywords              []string           `json:"keywords"`
	InLanguage            []string           `json:"in_language"`
	DefaultLanguage       pgtype.Text        `json:"default_language"`
	IsAccessibleForFree   pgtype.Bool        `json:"is_accessible_for_free"`
	AccessibilityFeatures []string           `json:"accessibility_features"`
	EventDomain           pgtype.Text        `json:"event_domain"`
	OriginNodeID          pgtype.UUID        `json:"origin_node_id"`
	FederationUri         pgtype.Text        `json:"federation_uri"`
	LicenseUrl            string             `json:"license_url"`
	LicenseStatus         string             `json:"license_status"`
	Confidence            pgtype.Numeric     `json:"confidence"`
	QualityScore          pgtype.Int4        `json:"quality_score"`
	Version               int32              `json:"version"`
	CreatedAt             pgtype.Timestamptz `json:"created_at"`
	UpdatedAt             pgtype.Timestamptz `json:"updated_at"`
	PublishedAt           pgtype.Timestamptz `json:"published_at"`
}

type UpsertReconciliationCacheParams

type UpsertReconciliationCacheParams struct {
	EntityType    string             `json:"entity_type"`
	AuthorityCode string             `json:"authority_code"`
	LookupKey     string             `json:"lookup_key"`
	ResultJson    []byte             `json:"result_json"`
	IsNegative    bool               `json:"is_negative"`
	ExpiresAt     pgtype.Timestamptz `json:"expires_at"`
}

type UpsertScraperSourceParams

type UpsertScraperSourceParams struct {
	Name                          string             `json:"name"`
	Url                           string             `json:"url"`
	Urls                          []string           `json:"urls"`
	Tier                          int32              `json:"tier"`
	Schedule                      string             `json:"schedule"`
	TrustLevel                    int32              `json:"trust_level"`
	License                       string             `json:"license"`
	EventDomain                   pgtype.Text        `json:"event_domain"`
	TlsFingerprint                string             `json:"tls_fingerprint"`
	Enabled                       bool               `json:"enabled"`
	MaxPages                      int32              `json:"max_pages"`
	Selectors                     []byte             `json:"selectors"`
	Notes                         pgtype.Text        `json:"notes"`
	EventUrlPattern               string             `json:"event_url_pattern"`
	SkipMultiSessionCheck         bool               `json:"skip_multi_session_check"`
	MultiSessionDurationThreshold string             `json:"multi_session_duration_threshold"`
	FollowEventUrls               bool               `json:"follow_event_urls"`
	Timezone                      string             `json:"timezone"`
	LastScrapedAt                 pgtype.Timestamptz `json:"last_scraped_at"`
	HeadlessWaitSelector          pgtype.Text        `json:"headless_wait_selector"`
	HeadlessWaitTimeoutMs         int32              `json:"headless_wait_timeout_ms"`
	HeadlessPaginationBtn         pgtype.Text        `json:"headless_pagination_btn"`
	HeadlessHeaders               []byte             `json:"headless_headers"`
	HeadlessRateLimitMs           int32              `json:"headless_rate_limit_ms"`
	HeadlessWaitNetworkIdle       bool               `json:"headless_wait_network_idle"`
	HeadlessUndetected            bool               `json:"headless_undetected"`
	HeadlessIframe                []byte             `json:"headless_iframe"`
	HeadlessIntercept             []byte             `json:"headless_intercept"`
	GraphqlConfig                 []byte             `json:"graphql_config"`
	RestConfig                    []byte             `json:"rest_config"`
	SitemapConfig                 []byte             `json:"sitemap_config"`
	DefaultLocation               []byte             `json:"default_location"`
	ExtractionMethod              string             `json:"extraction_method"`
	InsecureSkipVerify            bool               `json:"insecure_skip_verify"`
	RequestTimeoutSeconds         int32              `json:"request_timeout_seconds"`
	MaxBodyBytes                  int64              `json:"max_body_bytes"`
}

type UpsertScraperSourceRow

type UpsertScraperSourceRow struct {
	ScraperSource ScraperSource `json:"scraper_source"`
}

type UsageRepository

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

UsageRepository handles API key usage tracking operations

func NewUsageRepository

func NewUsageRepository(pool *pgxpool.Pool) *UsageRepository

NewUsageRepository creates a new UsageRepository

func (*UsageRepository) GetAPIKeyUsage

func (r *UsageRepository) GetAPIKeyUsage(ctx context.Context, apiKeyID pgtype.UUID, startDate, endDate time.Time) ([]ApiKeyUsage, error)

GetAPIKeyUsage retrieves usage records for an API key within a date range

func (*UsageRepository) GetAPIKeyUsageTotal

func (r *UsageRepository) GetAPIKeyUsageTotal(ctx context.Context, apiKeyID pgtype.UUID, startDate, endDate time.Time) (totalRequests, totalErrors int64, err error)

GetAPIKeyUsageTotal retrieves aggregated usage totals for an API key within a date range

func (*UsageRepository) GetDeveloperUsageTotal

func (r *UsageRepository) GetDeveloperUsageTotal(ctx context.Context, developerID pgtype.UUID, startDate, endDate time.Time) (totalRequests, totalErrors int64, err error)

GetDeveloperUsageTotal retrieves aggregated usage totals across all API keys for a developer within a date range

func (*UsageRepository) UpsertAPIKeyUsage

func (r *UsageRepository) UpsertAPIKeyUsage(ctx context.Context, apiKeyID pgtype.UUID, date time.Time, requestCount, errorCount int64) error

UpsertAPIKeyUsage upserts usage stats for an API key on a given date This increments counters if a row already exists for the date

func (*UsageRepository) UpsertAPIKeyUsageIP

func (r *UsageRepository) UpsertAPIKeyUsageIP(ctx context.Context, apiKeyID pgtype.UUID, date time.Time, ip netip.Addr, requestCount, errorCount int64) error

UpsertAPIKeyUsageIP upserts per-IP usage stats for an API key on a given date

func (*UsageRepository) WithTx

func (r *UsageRepository) WithTx(tx pgx.Tx) *UsageRepository

WithTx returns a new repository instance that will use the provided transaction

type User

type User struct {
	ID           pgtype.UUID        `json:"id"`
	Username     string             `json:"username"`
	Email        string             `json:"email"`
	PasswordHash string             `json:"password_hash"`
	Role         string             `json:"role"`
	IsActive     bool               `json:"is_active"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	LastLoginAt  pgtype.Timestamptz `json:"last_login_at"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
}

type UserInvitation

type UserInvitation struct {
	ID         pgtype.UUID        `json:"id"`
	UserID     pgtype.UUID        `json:"user_id"`
	TokenHash  string             `json:"token_hash"`
	Email      string             `json:"email"`
	ExpiresAt  pgtype.Timestamptz `json:"expires_at"`
	AcceptedAt pgtype.Timestamptz `json:"accepted_at"`
	CreatedBy  pgtype.UUID        `json:"created_by"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
}

Jump to

Keyboard shortcuts

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