Documentation
¶
Index ¶
- Variables
- type CampfireToken
- type Club
- type ClubImportJob
- type ClubImportJobState
- type ClubImportJobStatus
- type ClubImportJobWithClub
- type ClubMemberCheckInCount
- type ClubRef
- type ClubStatsEventRow
- type ClubStatsMonthRow
- type ClubStatsTotals
- type ClubWithCreator
- type ClubWithEvents
- type CodeRequest
- type Config
- type Database
- func (d *Database) AddDiscordUserPinnedClub(ctx context.Context, userID, clubID string) error
- func (d *Database) AddDiscordUserRaffleBlockedMember(ctx context.Context, userID, memberID string) error
- func (d *Database) AppendRaffleEvents(ctx context.Context, raffleID int, eventIDs []string) error
- func (d *Database) BackfillEmptyEventCategories(ctx context.Context) (int, error)
- func (d *Database) Close() error
- func (d *Database) ConfirmRaffleWinner(ctx context.Context, raffleID int, memberID string) error
- func (d *Database) CountEventsWithoutCategory(ctx context.Context) (int, error)
- func (d *Database) CreateSession(ctx context.Context, session Session) error
- func (d *Database) DeleteEvent(ctx context.Context, eventID string) error
- func (d *Database) DeleteExpiredCampfireTokens(ctx context.Context) (int, error)
- func (d *Database) DeleteExpiredSessions(ctx context.Context) error
- func (d *Database) DeleteNotConfirmedRaffleWinners(ctx context.Context, raffleID int) error
- func (d *Database) DeleteReward(ctx context.Context, codeID int) error
- func (d *Database) DeleteRewardCode(ctx context.Context, id int) error
- func (d *Database) DeleteUnconfirmedRaffleWinners(ctx context.Context, raffleID int) error
- func (d *Database) GetAcceptedClubEventsByMember(ctx context.Context, clubID string, memberID string) ([]Event, error)
- func (d *Database) GetAcceptedEventsByMember(ctx context.Context, memberID string) ([]EventWithClub, error)
- func (d *Database) GetAcceptedMembersByEvent(ctx context.Context, eventID string) ([]Member, error)
- func (d *Database) GetAllEvents(ctx context.Context) ([]Event, error)
- func (d *Database) GetBiggestCheckInEvent(ctx context.Context, clubID string, from time.Time, to time.Time, caOnly bool) (*EventWithCheckIns, error)
- func (d *Database) GetCampfireTokens(ctx context.Context) ([]CampfireToken, error)
- func (d *Database) GetCampfireTokensExpiringSoon(ctx context.Context, within time.Duration) ([]CampfireToken, error)
- func (d *Database) GetCheckedInClubEventsByMember(ctx context.Context, clubID string, memberID string) ([]Event, error)
- func (d *Database) GetCheckedInEventsByMember(ctx context.Context, memberID string) ([]EventWithClub, error)
- func (d *Database) GetCheckedInMembersByEvent(ctx context.Context, eventID string) ([]Member, error)
- func (d *Database) GetClub(ctx context.Context, clubID string) (*ClubWithCreator, error)
- func (d *Database) GetClubEventCategories(ctx context.Context, clubID string) ([]string, error)
- func (d *Database) GetClubEventCreators(ctx context.Context, clubID string) ([]Member, error)
- func (d *Database) GetClubImportJobs(ctx context.Context) ([]ClubImportJobWithClub, error)
- func (d *Database) GetClubMemberCheckInCounts(ctx context.Context, clubID string) ([]ClubMemberCheckInCount, error)
- func (d *Database) GetClubOptions(ctx context.Context) ([]ClubRef, error)
- func (d *Database) GetClubStatsEvents(ctx context.Context, clubID string) ([]ClubStatsEventRow, error)
- func (d *Database) GetClubStatsMonthly(ctx context.Context, clubID string) ([]ClubStatsMonthRow, error)
- func (d *Database) GetClubStatsTotals(ctx context.Context, clubID string) (*ClubStatsTotals, error)
- func (d *Database) GetClubTotalCheckInsAccepted(ctx context.Context, clubID string, from time.Time, to time.Time, caOnly bool, ...) (int, int, error)
- func (d *Database) GetClubTotalCheckInsAcceptedExcludingLiveEventPatterns(ctx context.Context, clubID string, from time.Time, to time.Time, caOnly bool, ...) (int, int, error)
- func (d *Database) GetClubs(ctx context.Context, order string) ([]ClubWithEvents, error)
- func (d *Database) GetDiscordUserPinnedClubs(ctx context.Context, userID string) ([]string, error)
- func (d *Database) GetDiscordUserRaffleBlockedMemberIDs(ctx context.Context, userID string) ([]string, error)
- func (d *Database) GetDiscordUserRaffleBlockedMembers(ctx context.Context, userID string) ([]Member, error)
- func (d *Database) GetEvent(ctx context.Context, eventID string) (*EventWithCreator, error)
- func (d *Database) GetEventCheckInAcceptedCounts(ctx context.Context, clubID string, from time.Time, to time.Time, caOnly bool, ...) ([]EventNumbers, error)
- func (d *Database) GetEventMembers(ctx context.Context, eventID string) ([]EventMember, error)
- func (d *Database) GetEvents(ctx context.Context, clubID string, from time.Time, to time.Time, caOnly bool, ...) ([]EventWithCheckIns, error)
- func (d *Database) GetLiveEventRSVPs(ctx context.Context, clubIDs []string, liveEventIDs []string) ([]LiveEventMemberRSVP, error)
- func (d *Database) GetMember(ctx context.Context, memberID string) (*Member, error)
- func (d *Database) GetNextCampfireToken(ctx context.Context) (*CampfireToken, error)
- func (d *Database) GetNextClubImport(ctx context.Context) (*Club, error)
- func (d *Database) GetNextPendingClubImportJob(ctx context.Context) (*ClubImportJob, error)
- func (d *Database) GetNextUpdateEvent(ctx context.Context) (*Event, error)
- func (d *Database) GetOldEvents(ctx context.Context) ([]OldEvent, error)
- func (d *Database) GetRaffleByID(ctx context.Context, id int) (*Raffle, error)
- func (d *Database) GetRaffleEvents(ctx context.Context, raffleID int) ([]Event, error)
- func (d *Database) GetRaffleWinners(ctx context.Context, raffleID int) ([]RaffleWinnerWithMember, error)
- func (d *Database) GetRafflesByUserID(ctx context.Context, userID string) ([]Raffle, error)
- func (d *Database) GetReward(ctx context.Context, id int, userID string) (*Reward, error)
- func (d *Database) GetRewardClubs(ctx context.Context) ([]Club, error)
- func (d *Database) GetRewardCode(ctx context.Context, id int) (*RewardCodeWithUser, error)
- func (d *Database) GetRewardCodeByRedeemCode(ctx context.Context, redeemCode string) (*RewardCodeWithUser, error)
- func (d *Database) GetRewardCodeByRedeemCodeAndIncreaseVisitedCount(ctx context.Context, redeemCode string) (*RewardCodeWithUser, error)
- func (d *Database) GetRewardCodes(ctx context.Context, id int, filter string) ([]RewardCodeWithUser, error)
- func (d *Database) GetRewards(ctx context.Context, userID string) ([]Reward, error)
- func (d *Database) GetSession(ctx context.Context, sessionID string) (*SessionWithUser, error)
- func (d *Database) GetTopEventsByClub(ctx context.Context, clubID string, from time.Time, to time.Time, caOnly bool, ...) ([]EventWithCheckIns, error)
- func (d *Database) GetTopMembersByClub(ctx context.Context, clubID string, from time.Time, to time.Time, caOnly bool, ...) ([]TopMember, error)
- func (d *Database) GetUpcomingClubEvents(ctx context.Context, clubID string) ([]EventWithCheckIns, error)
- func (d *Database) IncreaseRewardCodeVisitedCount(ctx context.Context, id int) error
- func (d *Database) InsertCampfireToken(ctx context.Context, token CampfireToken) error
- func (d *Database) InsertClubImportJob(ctx context.Context, job ClubImportJob) (int, error)
- func (d *Database) InsertClubs(ctx context.Context, clubs []Club) error
- func (d *Database) InsertEventRSVPs(ctx context.Context, rsvps []EventRSVP) error
- func (d *Database) InsertEvents(ctx context.Context, events []Event) error
- func (d *Database) InsertMembers(ctx context.Context, members []Member) error
- func (d *Database) InsertRaffle(ctx context.Context, raffle Raffle) (int, error)
- func (d *Database) InsertRaffleWinners(ctx context.Context, raffleID int, memberIDs []string) error
- func (d *Database) InsertReward(ctx context.Context, reward Reward) (int, error)
- func (d *Database) InsertRewardCodes(ctx context.Context, id int, codes []string, userID string) error
- func (d *Database) MarkRaffleWinnersAsPast(ctx context.Context, raffleID int) error
- func (d *Database) RemoveDiscordUserPinnedClub(ctx context.Context, userID, clubID string) error
- func (d *Database) RemoveDiscordUserRaffleBlockedMember(ctx context.Context, userID, memberID string) error
- func (d *Database) RemoveRaffleEvents(ctx context.Context, raffleID int, eventIDs []string) error
- func (d *Database) SearchMembers(ctx context.Context, query string, limit int) ([]Member, error)
- func (d *Database) UpdateClub(ctx context.Context, clubID string, autoImport bool, ...) error
- func (d *Database) UpdateClubImportJob(ctx context.Context, job ClubImportJob) error
- func (d *Database) UpdateClubLastAutoEventImported(ctx context.Context, clubID string) error
- func (d *Database) UpdateEventCategory(ctx context.Context, eventID string, category string) error
- func (d *Database) UpdateEventLastAutoImported(ctx context.Context, eventID string) error
- func (d *Database) UpdateReward(ctx context.Context, reward Reward) error
- func (d *Database) UpdateRewardCodeRedeemed(ctx context.Context, id int, at *time.Time, userID *string) error
- func (d *Database) UpsertDiscordUser(ctx context.Context, user DiscordUser) error
- type DiscordUser
- type Event
- type EventMember
- type EventNumbers
- type EventRSVP
- type EventState
- type EventWithCheckIns
- type EventWithClub
- type EventWithCreator
- type LiveEventMemberRSVP
- type Member
- type OldEvent
- type Raffle
- type RaffleWinner
- type RaffleWinnerWithMember
- type Reward
- type RewardCode
- type RewardCodeWithUser
- type RewardSession
- type RewardUser
- type Session
- type SessionWithUser
- type TopMember
Constants ¶
This section is empty.
Variables ¶
var ErrSessionExpired = errors.New("session expired")
Functions ¶
This section is empty.
Types ¶
type CampfireToken ¶
type Club ¶
type Club struct {
ID string `db:"club_id"`
Name string `db:"club_name"`
AvatarURL string `db:"club_avatar_url"`
CreatorID string `db:"club_creator_id"`
CreatedByCommunityAmbassador bool `db:"club_created_by_community_ambassador"`
ImportedAt time.Time `db:"club_imported_at"`
RawJSON json.RawMessage `db:"club_raw_json"`
AutoEventImport bool `db:"club_auto_event_import"`
ClubVerificationChannelID *string `db:"club_verification_channel_id"`
LastAutoEventImportedAt time.Time `db:"club_last_auto_event_imported_at"`
}
type ClubImportJob ¶
type ClubImportJob struct {
ID int `db:"club_import_job_id"`
ClubID string `db:"club_import_job_club_id"`
CreatedAt time.Time `db:"club_import_job_created_at"`
CompletedAt time.Time `db:"club_import_job_completed_at"`
LastTriedAt time.Time `db:"club_import_job_last_tried_at"`
Status ClubImportJobStatus `db:"club_import_job_status"`
State xpgtype.JSON[ClubImportJobState] `db:"club_import_job_state"`
Error string `db:"club_import_job_error"`
}
type ClubImportJobState ¶
type ClubImportJobState struct {
Events []EventState `json:"events"`
EventCursor *string `json:"event_cursor"`
Members []Member `json:"members"`
MemberCursor *string `json:"member_cursor"`
}
type ClubImportJobStatus ¶
type ClubImportJobStatus string
const ( ClubImportJobStatusPending ClubImportJobStatus = "pending" ClubImportJobStatusCompleted ClubImportJobStatus = "completed" ClubImportJobStatusFailed ClubImportJobStatus = "failed" )
type ClubImportJobWithClub ¶
type ClubImportJobWithClub struct {
ClubImportJob
Club
}
type ClubMemberCheckInCount ¶
type ClubStatsEventRow ¶
type ClubStatsMonthRow ¶
type ClubStatsTotals ¶
type ClubStatsTotals struct {
Events int `db:"events"`
UniqueParticipants int `db:"unique_participants"`
TotalRSVPs int `db:"total_rsvps"`
TotalCheckIns int `db:"total_check_ins"`
TotalAccepted int `db:"total_accepted"`
TotalDeclined int `db:"total_declined"`
FirstEventDate time.Time `db:"first_event_date"`
LastEventDate time.Time `db:"last_event_date"`
}
type ClubWithCreator ¶
type ClubWithEvents ¶
type CodeRequest ¶
type Config ¶
type Config struct {
Host string `toml:"host"`
Port int `toml:"port"`
Username string `toml:"username"`
Password string `toml:"password"`
Database string `toml:"database"`
SSLMode string `toml:"ssl_mode"`
}
func (Config) DataSourceName ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) AddDiscordUserPinnedClub ¶
func (*Database) AddDiscordUserRaffleBlockedMember ¶
func (*Database) AppendRaffleEvents ¶
func (*Database) BackfillEmptyEventCategories ¶
BackfillEmptyEventCategories sets event_category from the Campfire live event name for every event that still has an empty category. Returns the number of rows updated.
func (*Database) ConfirmRaffleWinner ¶
func (*Database) CountEventsWithoutCategory ¶
func (*Database) CreateSession ¶
func (*Database) DeleteEvent ¶
func (*Database) DeleteExpiredCampfireTokens ¶
func (*Database) DeleteExpiredSessions ¶
func (*Database) DeleteNotConfirmedRaffleWinners ¶
func (*Database) DeleteReward ¶
func (*Database) DeleteRewardCode ¶
func (*Database) DeleteUnconfirmedRaffleWinners ¶
func (*Database) GetAcceptedClubEventsByMember ¶
func (*Database) GetAcceptedEventsByMember ¶
func (*Database) GetAcceptedMembersByEvent ¶
func (*Database) GetAllEvents ¶
func (*Database) GetBiggestCheckInEvent ¶
func (*Database) GetCampfireTokens ¶
func (d *Database) GetCampfireTokens(ctx context.Context) ([]CampfireToken, error)
func (*Database) GetCampfireTokensExpiringSoon ¶
func (*Database) GetCheckedInClubEventsByMember ¶
func (*Database) GetCheckedInEventsByMember ¶
func (*Database) GetCheckedInMembersByEvent ¶
func (*Database) GetClubEventCategories ¶
func (*Database) GetClubEventCreators ¶
func (*Database) GetClubImportJobs ¶
func (d *Database) GetClubImportJobs(ctx context.Context) ([]ClubImportJobWithClub, error)
func (*Database) GetClubMemberCheckInCounts ¶
func (*Database) GetClubOptions ¶
GetClubOptions returns just the id and name of every club, ordered by name. It avoids the events join/count and the jsonb columns loaded by GetClubs, which matters when there are hundreds of clubs.
func (*Database) GetClubStatsEvents ¶
func (*Database) GetClubStatsMonthly ¶
func (*Database) GetClubStatsTotals ¶
func (*Database) GetClubTotalCheckInsAccepted ¶
func (*Database) GetClubTotalCheckInsAcceptedExcludingLiveEventPatterns ¶
func (*Database) GetDiscordUserPinnedClubs ¶
func (*Database) GetDiscordUserRaffleBlockedMemberIDs ¶
func (*Database) GetDiscordUserRaffleBlockedMembers ¶
func (*Database) GetEventCheckInAcceptedCounts ¶
func (*Database) GetEventMembers ¶
func (*Database) GetLiveEventRSVPs ¶
func (d *Database) GetLiveEventRSVPs(ctx context.Context, clubIDs []string, liveEventIDs []string) ([]LiveEventMemberRSVP, error)
GetLiveEventRSVPs returns one row per (club, live event, member) for the given clubs and set of Campfire live event IDs. StatusRank is the member's best status within that live event at that club (2 = checked in, 1 = accepted only). Members who attended multiple meetups within the same live event at a club are deduplicated.
func (*Database) GetNextCampfireToken ¶
func (d *Database) GetNextCampfireToken(ctx context.Context) (*CampfireToken, error)
func (*Database) GetNextClubImport ¶
func (*Database) GetNextPendingClubImportJob ¶
func (d *Database) GetNextPendingClubImportJob(ctx context.Context) (*ClubImportJob, error)
func (*Database) GetNextUpdateEvent ¶
func (*Database) GetOldEvents ¶
func (*Database) GetRaffleByID ¶
func (*Database) GetRaffleEvents ¶
func (*Database) GetRaffleWinners ¶
func (*Database) GetRafflesByUserID ¶
func (*Database) GetRewardClubs ¶
func (*Database) GetRewardCode ¶
func (*Database) GetRewardCodeByRedeemCode ¶
func (*Database) GetRewardCodeByRedeemCodeAndIncreaseVisitedCount ¶
func (*Database) GetRewardCodes ¶
func (*Database) GetRewards ¶
func (*Database) GetSession ¶
func (*Database) GetTopEventsByClub ¶
func (*Database) GetTopMembersByClub ¶
func (*Database) GetUpcomingClubEvents ¶
func (*Database) IncreaseRewardCodeVisitedCount ¶
func (*Database) InsertCampfireToken ¶
func (d *Database) InsertCampfireToken(ctx context.Context, token CampfireToken) error
func (*Database) InsertClubImportJob ¶
func (*Database) InsertClubs ¶
func (*Database) InsertEventRSVPs ¶
func (*Database) InsertEvents ¶
func (*Database) InsertMembers ¶
InsertMembers inserts or updates multiple members in the database. Fields which are an empty string will not be updated.
func (*Database) InsertRaffle ¶
func (*Database) InsertRaffleWinners ¶
func (*Database) InsertReward ¶
func (*Database) InsertRewardCodes ¶
func (*Database) MarkRaffleWinnersAsPast ¶
func (*Database) RemoveDiscordUserPinnedClub ¶
func (*Database) RemoveDiscordUserRaffleBlockedMember ¶
func (*Database) RemoveRaffleEvents ¶
func (*Database) SearchMembers ¶
func (*Database) UpdateClub ¶
func (*Database) UpdateClubImportJob ¶
func (d *Database) UpdateClubImportJob(ctx context.Context, job ClubImportJob) error
func (*Database) UpdateClubLastAutoEventImported ¶
func (*Database) UpdateEventCategory ¶
func (*Database) UpdateEventLastAutoImported ¶
func (*Database) UpdateReward ¶
func (*Database) UpdateRewardCodeRedeemed ¶
func (*Database) UpsertDiscordUser ¶
func (d *Database) UpsertDiscordUser(ctx context.Context, user DiscordUser) error
type DiscordUser ¶
type Event ¶
type Event struct {
ID string `db:"event_id"`
Name string `db:"event_name"`
Details string `db:"event_details"`
Address string `db:"event_address"`
Location string `db:"event_location"`
CreatorID string `db:"event_creator_id"`
CoverPhotoURL string `db:"event_cover_photo_url"`
Time time.Time `db:"event_time"`
EndTime time.Time `db:"event_end_time"`
Finished bool `db:"event_finished"`
DiscordInterested int `db:"event_discord_interested"`
CreatedByCommunityAmbassador bool `db:"event_created_by_community_ambassador"`
CampfireLiveEventID string `db:"event_campfire_live_event_id"`
CampfireLiveEventName string `db:"event_campfire_live_event_name"`
Category string `db:"event_category"`
ClubID string `db:"event_club_id"`
ImportedAt time.Time `db:"event_imported_at"`
RawJSON json.RawMessage `db:"event_raw_json"`
LastAutoImportedAt time.Time `db:"event_last_auto_imported_at"`
}
type EventMember ¶
type EventNumbers ¶
type EventState ¶
type EventWithCheckIns ¶
type EventWithClub ¶
type EventWithCreator ¶
type LiveEventMemberRSVP ¶
type LiveEventMemberRSVP struct {
Member
ClubID string `db:"club_id"`
LiveEventID string `db:"live_event_id"`
StatusRank int `db:"status_rank"`
}
LiveEventMemberRSVP is one member's aggregated RSVP status within a single Campfire live event (across all of that live event's meetups for a club). StatusRank is 2 for CHECKED_IN, 1 for ACCEPTED only, 0 otherwise.
type OldEvent ¶
type OldEvent struct {
ID string `db:"id"`
Name string `db:"name"`
Details string `db:"details"`
CoverPhotoURL string `db:"cover_photo_url"`
EventTime time.Time `db:"event_time"`
EventEndTime time.Time `db:"event_end_time"`
CampfireLiveEventID string `db:"campfire_live_event_id"`
CampfireLiveEventName string `db:"campfire_live_event_name"`
ClubID string `db:"club_id"`
ClubName string `db:"club_name"`
ClubAvatarURL string `db:"club_avatar_url"`
RawJSON json.RawMessage `db:"raw_json"`
}
type Raffle ¶
type Raffle struct {
ID int `db:"raffle_id"`
UserID string `db:"raffle_user_id"`
Events pq.StringArray `db:"raffle_events"`
WinnerCount int `db:"raffle_winner_count"`
OnlyCheckedIn bool `db:"raffle_only_checked_in"`
SingleEntry bool `db:"raffle_single_entry"`
CreatedAt time.Time `db:"raffle_created_at"`
}
type RaffleWinner ¶
type RaffleWinnerWithMember ¶
type RaffleWinnerWithMember struct {
RaffleWinner
Member
Accepted int `db:"accepted"`
CheckIns int `db:"check_ins"`
}
type RewardCode ¶
type RewardCode struct {
ID int `db:"reward_code_id"`
Code string `db:"reward_code_code"`
RewardID int `db:"reward_code_reward_id"`
ImportedAt time.Time `db:"reward_code_imported_at"`
ImportedBy string `db:"reward_code_imported_by"`
RedeemCode string `db:"reward_code_redeem_code"`
RedeemedAt *time.Time `db:"reward_code_redeemed_at"`
RedeemedBy *string `db:"reward_code_redeemed_by"`
VisitedCount int `db:"reward_code_visited_count"`
}
type RewardCodeWithUser ¶
type RewardCodeWithUser struct {
RewardCode
ImportedByUser DiscordUser `db:"imported_by_user"`
RedeemedByUser struct {
ID *string `db:"discord_user_id"`
Username *string `db:"discord_user_username"`
DisplayName *string `db:"discord_user_display_name"`
AvatarURL *string `db:"discord_user_avatar_url"`
} `db:"redeemed_by_user"`
}
type RewardSession ¶
type RewardUser ¶
type SessionWithUser ¶
type SessionWithUser struct {
Session
DiscordUser
}