Documentation ¶
Index ¶
- Constants
- type Balance
- type BalancesQ
- type DailyQuestion
- type DailyQuestionsQ
- type Event
- type EventStatus
- type EventTypesQ
- type EventsQ
- type Jsonb
- type QRCode
- type QRCodesQ
- type Referral
- type ReferralsQ
- type ReferredReferrer
- type ReopenableEvent
- type Withdrawal
- type WithdrawalsQ
- type WithoutPassportEventBalance
Constants ¶
View Source
const ( ColAmount = "amount" ColReferredBy = "referred_by" ColLevel = "level" ColInternalAID = "internal_aid" ColExternalAID = "external_aid" VerifyInternalType = "internal" VerifyExternalType = "external" )
View Source
const ( ColDailyQuestionTitle = "title" ColTimeForAnswer = "time_for_answer" ColAnswerOption = "answer_options" ColCorrectAnswerID = "correct_answer" ColReward = "reward" ColStartAt = "starts_at" ColCorrectAnswers = "num_correct_answers" ColIncorrectAnswers = "num_incorrect_answers" ColAllParticipants = "num_all_participants" )
View Source
const ( ColNullifier = "nullifier" ColUsageCount = "usage_count" ColInfinity = "infinity" )
View Source
const ( StatusInfinity = "infinity" StatusActive = "active" StatusAwaiting = "awaiting" StatusRewarded = "rewarded" StatusConsumed = "consumed" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balance ¶
type Balance struct { Nullifier string `db:"nullifier"` Amount int64 `db:"amount"` CreatedAt int32 `db:"created_at"` UpdatedAt int32 `db:"updated_at"` ReferredBy *string `db:"referred_by"` Level int `db:"level"` InternalAID *string `db:"internal_aid"` ExternalAID *string `db:"external_aid"` Rank *int `db:"rank"` }
func (*Balance) IsDisabled ¶ added in v1.3.0
func (*Balance) IsVerified ¶
type BalancesQ ¶
type BalancesQ interface { New() BalancesQ Insert(Balance) error Update(map[string]any) error Page(*pgdb.OffsetPageParams) BalancesQ Select() ([]Balance, error) Get() (*Balance, error) // GetWithRank returns balance with rank, filtered by nullifier. No other filters can be applied. GetWithRank(nullifier string) (*Balance, error) SelectWithRank() ([]Balance, error) // WithoutPassportEvent returns balances which already // have scanned passport, but there no claimed events // for this. Filters are not applied. WithoutPassportEvent() ([]WithoutPassportEventBalance, error) WithoutReferralEvent() ([]ReferredReferrer, error) Count() (int64, error) FilterByNullifier(...string) BalancesQ FilterDisabled() BalancesQ FilterByInternalAID(aid string) BalancesQ FilterByExternalAID(aid string) BalancesQ FilterByCreatedBefore(date int) BalancesQ FilterVerified() BalancesQ }
type DailyQuestion ¶ added in v1.5.0
type DailyQuestion struct { ID int64 `db:"id"` Title string `db:"title"` TimeForAnswer int64 `db:"time_for_answer"` Reward int64 `db:"reward"` AnswerOptions Jsonb `db:"answer_options"` StartsAt time.Time `db:"starts_at"` CreatedAt time.Time `db:"created_at"` CorrectAnswer int64 `db:"correct_answer"` NumCorrectAnswers int64 `db:"num_correct_answers"` NumIncorrectAnswers int64 `db:"num_incorrect_answers"` NumAllParticipants int64 `db:"num_all_participants"` }
func (*DailyQuestion) ExtractOptions ¶ added in v1.5.0
func (q *DailyQuestion) ExtractOptions() ([]resources.DailyQuestionOptions, error)
type DailyQuestionsQ ¶ added in v1.5.0
type DailyQuestionsQ interface { New() DailyQuestionsQ Insert(DailyQuestion) error Update(map[string]any) error Delete() (int64, error) Count() (int64, error) Select() ([]DailyQuestion, error) Get() (*DailyQuestion, error) Page(*pgdb.OffsetPageParams) DailyQuestionsQ FilterTodayQuestions(offset int) DailyQuestionsQ FilterByCreatedAtAfter(date time.Time) DailyQuestionsQ FilterByStartsAtAfter(date time.Time) DailyQuestionsQ FilterByID(ID int64) DailyQuestionsQ FilterDayQuestions(day time.Time) DailyQuestionsQ IncrementCorrectAnswer() error IncrementIncorrectAnswer() error IncrementAllParticipants() error }
type Event ¶
type Event struct { ID string `db:"id"` Nullifier string `db:"nullifier"` Type string `db:"type"` Status EventStatus `db:"status"` CreatedAt int32 `db:"created_at"` UpdatedAt int32 `db:"updated_at"` Meta Jsonb `db:"meta"` PointsAmount *int64 `db:"points_amount"` ExternalID sql.NullString `db:"external_id"` // hidden from client }
type EventStatus ¶
type EventStatus string
const ( EventOpen EventStatus = "open" EventFulfilled EventStatus = "fulfilled" EventClaimed EventStatus = "claimed" )
func (EventStatus) String ¶
func (s EventStatus) String() string
type EventTypesQ ¶
type EventsQ ¶
type EventsQ interface { New() EventsQ Insert(...Event) error Update(status EventStatus, meta json.RawMessage, points *int64) ([]Event, error) Delete() (rowsAffected int64, err error) Transaction(func() error) error Page(*pgdb.OffsetPageParams) EventsQ Select() ([]Event, error) Get() (*Event, error) // GetLast order events by created_at field in descending order GetLast() (*Event, error) // Count returns the total number of events that match filters. Page is not // applied to this method. Count() (int, error) // SelectReopenable returns events matching criteria: there are no open or // fulfilled events of this type for a specific user. SelectReopenable() ([]ReopenableEvent, error) // SelectAbsentTypes returns events matching criteria: there are no events of // this type for a specific user. Filters are not applied to this selection. SelectAbsentTypes(allTypes ...string) ([]ReopenableEvent, error) FilterByID(...string) EventsQ FilterByQuestionID(int) EventsQ FilterByNullifier(...string) EventsQ FilterByStatus(...EventStatus) EventsQ FilterByType(...string) EventsQ FilterByNotType(types ...string) EventsQ FilterByUpdatedAtBefore(int64) EventsQ FilterByQRCode(string) EventsQ FilterTodayEvents(offset int) EventsQ FilterByExternalID(string) EventsQ FilterInactiveNotClaimed(types ...string) EventsQ }
type ReferralsQ ¶
type ReferralsQ interface { New() ReferralsQ Insert(...Referral) error Delete() error Select() ([]Referral, error) Get(id string) (*Referral, error) Count() (uint64, error) Consume(id string) error WithStatus() ReferralsQ Update(usageLeft int, infinity bool) (*Referral, error) FilterByNullifier(string) ReferralsQ FilterInactive() ReferralsQ FilterByIDs(...string) ReferralsQ }
type ReferredReferrer ¶
type ReopenableEvent ¶
ReopenableEvent is a pair that is sufficient to build a new open event with a specific type for a user
type Withdrawal ¶ added in v1.7.1
type WithdrawalsQ ¶ added in v1.7.1
type WithdrawalsQ interface { New() WithdrawalsQ Insert(Withdrawal) (*Withdrawal, error) Page(*pgdb.CursorPageParams) WithdrawalsQ Select() ([]Withdrawal, error) FilterByNullifier(string) WithdrawalsQ }
type WithoutPassportEventBalance ¶
type WithoutPassportEventBalance struct { Balance EventID string `db:"event_id"` EventStatus EventStatus `db:"event_status"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.