service

package
v0.0.0-...-485fe8d Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HealthOK          = "ok"
	HealthDegraded    = "degraded"
	HealthUnreachable = "unreachable"
)
View Source
const (
	DropDataLicenseURL  = "https://creativecommons.org/licenses/by-nc/4.0/"
	DropDataLicenseName = "CC BY-NC 4.0"
)

The license of the drop data (meta.footer.copyright of the frontend)

View Source
const (
	StatsSectionItem  = "item"
	StatsSectionStage = "stage"
)

The sections of the stats routes: the list of the items or stages, and the pages under it

View Source
const SEOCatalogRefreshInterval = time.Minute

SEOCatalogRefreshInterval is how often SEOData reloads the items, stages and zones.

View Source
const SEOSourceCategory = constant.SourceCategoryAll

SEOSourceCategory is the source category of the matrix the stats pages show: the one the frontend shows by default (frontend-v2 src/store/modules/dataSource.js).

View Source
const StatsDefaultLang = "en"

StatsDefaultLang is the fallback locale of the frontend: the x-default of the hreflang links of the pages

View Source
const (
	UpyunAuthorizationHeaderRealm = "UPYUN"
)

Variables

View Source
var (
	ErrReportNotFound = pgerr.ErrInvalidReq.Msg("report not existed or has already been recalled")
	ErrAccountMissing = pgerr.ErrInvalidReq.Msg("account missing")
	ErrNatsTimeout    = errors.New("timeout waiting for NATS response")

	ErrReportQueueUnavailable = pgerr.New(fiber.StatusServiceUnavailable, pgerr.CodeServiceUnavailable, "report queue is temporarily unavailable: please retry later")
)
View Source
var (
	ErrSnapshotNotFound    = errors.New("snapshot not found")
	ErrSnapshotNonNullable = errors.New("snapshot content cannot be empty")
)
View Source
var ListedItemTypes = []string{"MATERIAL", "CARD_EXP", "CHIP", "FURN", "ACTIVITY_ITEM"}

ListedItemTypes are the types of the items the frontend lists (src/utils/getters.js), in the order its item list groups them

View Source
var StatsLangs = []string{"zh", "en", "ja", "ko"}

StatsLangs are the languages of the stats routes of the frontend (src/router.js statsLanguages)

Functions

func IsListedItemType

func IsListedItemType(t string) bool

IsListedItemType tells whether the frontend lists the items of type t

func IsRecruitStage

func IsRecruitStage(stage *SEOStage) bool

IsRecruitStage tells whether the stage is the recruitment statistics, which the frontend shows in beta with measures of their own

func ItemOnServer

func ItemOnServer(item *SEOItem, server string, matrix *SEOMatrix) bool

ItemOnServer tells whether the item has a stats page on server: an item the frontend lists that exists there or has drops there. matrix is the matrix of server, nil while it is not calculated.

func ItemPageURL

func ItemPageURL(site, lang, server, itemID string) (u string, ok bool)

ItemPageURL is the URL of the stats page of an item on server in lang, at site (an origin). ok is false if there is no such page to link: a language or server without stats routes, or an ID that is routed as another path (see routablePage).

func Module

func Module() fx.Option

func StageOnServer

func StageOnServer(stage *SEOStage, server string, matrix *SEOMatrix) bool

StageOnServer tells whether the stage has a stats page on server: a stage in a zone that exists there or has drops there. matrix is the matrix of server, nil while it is not calculated.

func StagePageURL

func StagePageURL(site, lang, server string, stage *SEOStage) (u string, ok bool)

StagePageURL is the URL of the stats page of a stage on server in lang, at site (an origin), whose path holds the zone of the stage. ok is false if there is no such page to link: a stage without a zone, as ItemPageURL otherwise.

func StatsPagePath

func StatsPagePath(lang, server, section string, ids ...string) string

StatsPagePath is the path of a stats page of the frontend: /{lang}/result/{server}, then the section, if any, and the IDs, escaped.

Types

type Account

type Account struct {
	AccountRepo *repo.Account
}

func NewAccount

func NewAccount(accountRepo *repo.Account) *Account

func (*Account) CreateAccountWithRandomPenguinId

func (s *Account) CreateAccountWithRandomPenguinId(ctx context.Context) (*model.Account, error)

func (*Account) GetAccountByPenguinId

func (s *Account) GetAccountByPenguinId(ctx context.Context, penguinId string) (*model.Account, error)

Cache: account#penguinId:{penguinId}, 1 hr

func (*Account) GetAccountFromRequest

func (s *Account) GetAccountFromRequest(ctx *fiber.Ctx) (*model.Account, error)

type Activity

type Activity struct {
	ActivityRepo *repo.Activity
}

func NewActivity

func NewActivity(activityRepo *repo.Activity) *Activity

func (*Activity) GetActivities

func (s *Activity) GetActivities(ctx context.Context) ([]*model.Activity, error)

Cache: (singular) activities, 1 hr; records last modified time

func (*Activity) GetActivityById

func (s *Activity) GetActivityById(ctx context.Context, activityId int) (*model.Activity, error)

func (*Activity) GetShimActivities

func (s *Activity) GetShimActivities(ctx context.Context) ([]*modelv2.Activity, error)

Cache: (singular) shimActivities, 1 hr; records last modified time

type Admin

type Admin struct {
	DB                *bun.DB
	AdminRepo         *repo.Admin
	DropReportService *DropReport
	RejectRuleRepo    *repo.RejectRule
	ZoneService       *Zone
	StageService      *Stage
	ActivityService   *Activity
	TimeRangeService  *TimeRange
	DropInfoService   *DropInfo
}

func NewAdmin

func NewAdmin(
	db *bun.DB,
	adminRepo *repo.Admin,
	dropReportService *DropReport,
	rejectRuleRepo *repo.RejectRule,
	zoneService *Zone,
	stageService *Stage,
	activityService *Activity,
	timeRangeService *TimeRange,
	dropInfoService *DropInfo,
) *Admin

func (*Admin) CloneFromCN

func (s *Admin) CloneFromCN(ctx context.Context, req types.CloneFromCNRequest) error

func (*Admin) EvaluateRejectRules

func (s *Admin) EvaluateRejectRules(ctx context.Context, evaluationContexts []RejectRulesReevaluationEvaluationContext, ruleId int) (RejectRulesReevaluationEvaluationResultSet, error)

func (*Admin) SaveRenderedObjects

func (s *Admin) SaveRenderedObjects(ctx context.Context, objects *gamedata.RenderedObjects) error

type Analytics

type Analytics struct {
	DropReportService *DropReport
}

func NewAnalytics

func NewAnalytics(dropReportService *DropReport) *Analytics

func (*Analytics) GetRecentUniqueUserCountBySource

func (s *Analytics) GetRecentUniqueUserCountBySource(ctx context.Context, recent string) (map[string]int, error)

type DropInfo

type DropInfo struct {
	DropInfoRepo     *repo.DropInfo
	TimeRangeService *TimeRange
}

func NewDropInfo

func NewDropInfo(dropInfoRepo *repo.DropInfo, timeRangeService *TimeRange) *DropInfo

func (*DropInfo) CloneDropInfosFromCN

func (s *DropInfo) CloneDropInfosFromCN(ctx context.Context, originRangeId int, destRangeId int, server string) error

func (*DropInfo) GetAppearStageIdsByServer

func (s *DropInfo) GetAppearStageIdsByServer(ctx context.Context, server string) ([]int, error)

func (*DropInfo) GetDropInfosByServer

func (s *DropInfo) GetDropInfosByServer(ctx context.Context, server string) ([]*model.DropInfo, error)

func (*DropInfo) GetDropInfosWithFilters

func (s *DropInfo) GetDropInfosWithFilters(ctx context.Context, server string, timeRanges []*model.TimeRange, stageIdFilter []int, itemIdFilter []int) ([]*model.DropInfo, error)

func (*DropInfo) GetItemDropSetByStageIdAndRangeId

func (s *DropInfo) GetItemDropSetByStageIdAndRangeId(ctx context.Context, server string, stageId int, rangeId int) ([]int, error)

Cache: itemDropSet#server|stageId|rangeId:{server}|{stageId}|{rangeId}, 24 hrs

func (*DropInfo) GetItemDropSetByStageIdAndTimeRange

func (s *DropInfo) GetItemDropSetByStageIdAndTimeRange(ctx context.Context, server string, stageId int, startTime *time.Time, endTime *time.Time) ([]int, error)

Cache: itemDropSet#server|stageId|startTime|endTime:{server}|{stageId}|{startTime}|{endTime}, 24 hrs

func (*DropInfo) GetOpeningStageIdsByServer

func (s *DropInfo) GetOpeningStageIdsByServer(ctx context.Context, server string) ([]int, error)

GetOpeningStageIdsByServer returns the distinct ids of the stages of server with a drop info in a current time range, reading only those stage ids instead of every drop info of server.

type DropMatrix

type DropMatrix struct {
	Config                   *appconfig.Config
	TimeRangeService         *TimeRange
	DropReportService        *DropReport
	DropInfoService          *DropInfo
	DropMatrixElementService *DropMatrixElement
	StageService             *Stage
	ItemService              *Item
	SiteStatsService         *SiteStats
}

func NewDropMatrix

func NewDropMatrix(
	config *appconfig.Config,
	timeRangeService *TimeRange,
	dropReportService *DropReport,
	dropInfoService *DropInfo,
	dropMatrixElementService *DropMatrixElement,
	stageService *Stage,
	itemService *Item,
	siteStatsService *SiteStats,
) *DropMatrix

func (*DropMatrix) DropGlobalDropMatrixCaches

func (s *DropMatrix) DropGlobalDropMatrixCaches(server string)

DropGlobalDropMatrixCaches deletes the cached global drop matrices of server that RefreshGlobalDropMatrixCaches replaces, those cached only: a refresh of them in another process left them stale, and requests recalculate them.

func (*DropMatrix) GetShimCustomizedDropMatrixResults

func (s *DropMatrix) GetShimCustomizedDropMatrixResults(
	ctx context.Context, server string, timeRange *model.TimeRange, stageIds []int, itemIds []int, accountId null.Int, sourceCategory string,
) (*modelv2.DropMatrixQueryResult, error)

func (*DropMatrix) GetShimDropMatrix

func (s *DropMatrix) GetShimDropMatrix(
	ctx context.Context, server string, showClosedZones bool, stageFilterStr string, itemFilterStr string, accountId null.Int, sourceCategory string,
) (*modelv2.DropMatrixQueryResult, error)

Cache: shimGlobalDropMatrix#server|showClosedZones|sourceCategory:{server}|{showClosedZones}|{sourceCategory}, 24 hrs, records last modified time Called by frontend, used for both global and personal, only for max accumulable results

func (*DropMatrix) GlobalDropMatrixCachesUsed

func (s *DropMatrix) GlobalDropMatrixCachesUsed(server string) bool

GlobalDropMatrixCachesUsed reports whether any of the global drop matrices of server that RefreshGlobalDropMatrixCaches replaces is used (see cache.Set.Used): whether this process serves them, and should follow their refreshes (cachesync).

func (*DropMatrix) RefreshGlobalDropMatrixCaches

func (s *DropMatrix) RefreshGlobalDropMatrixCaches(ctx context.Context, server string) error

RefreshGlobalDropMatrixCaches recalculates the global drop matrices of server and replaces the cached ones (for every source category, raw and shim with and without closed zones). Requests keep getting the previous ones in the meantime instead of all waiting for a recalculation. If the recalculation fails, the cached ones are dropped, also if it panics (the worker recovers the panic): the source categories cached before it must not keep matrices of this refresh while the others keep those of an earlier one.

func (*DropMatrix) RunCalcDropMatrixJob

func (s *DropMatrix) RunCalcDropMatrixJob(ctx context.Context, server string) error

Calc today's drop matrix elements and save to DB Called by worker

func (*DropMatrix) UpdateDropMatrixByGivenDate

func (s *DropMatrix) UpdateDropMatrixByGivenDate(ctx context.Context, server string, date *time.Time) error

Update drop matrix elements for a given date (entire day) Called by admin api

func (*DropMatrix) WarmUpGlobalDropMatrixCaches

func (s *DropMatrix) WarmUpGlobalDropMatrixCaches(ctx context.Context, server string) error

WarmUpGlobalDropMatrixCaches fills the cached global drop matrices of server (for every source category, raw and shim with and without closed zones) as requests do: it skips those cached, and waits for a calculation a request runs instead of running another one. RefreshGlobalDropMatrixCaches recalculates them instead.

type DropMatrixElement

type DropMatrixElement struct {
	DropMatrixElementRepo *repo.DropMatrixElement
}

func NewDropMatrixElement

func NewDropMatrixElement(dropMatrixElementRepo *repo.DropMatrixElement) *DropMatrixElement

func (*DropMatrixElement) BatchSaveElements

func (s *DropMatrixElement) BatchSaveElements(ctx context.Context, elements []*model.DropMatrixElement, server string) error

func (*DropMatrixElement) CalcGlobalDropMatrixAggregates

func (s *DropMatrixElement) CalcGlobalDropMatrixAggregates(
	ctx context.Context, server string, targets []*model.GlobalDropMatrixTarget, sourceCategories []string,
) (map[model.GlobalDropMatrixKey]*model.GlobalDropMatrixAggregate, error)

func (*DropMatrixElement) CalcSiteStatsAggregates

func (s *DropMatrixElement) CalcSiteStatsAggregates(
	ctx context.Context, server string, fromDayNum, toDayNum null.Int,
) ([]*model.SiteStatsAggregate, error)

func (*DropMatrixElement) DeleteByServerAndDayNum

func (s *DropMatrixElement) DeleteByServerAndDayNum(ctx context.Context, server string, dayNum int) error

func (*DropMatrixElement) GetElementsByServerAndSourceCategoryAndDayNumRange

func (s *DropMatrixElement) GetElementsByServerAndSourceCategoryAndDayNumRange(
	ctx context.Context, server string, sourceCategory string, startDayNum int, endDayNum int,
) ([]*model.DropMatrixElement, error)

func (*DropMatrixElement) IsExistByServerAndDayNum

func (s *DropMatrixElement) IsExistByServerAndDayNum(ctx context.Context, server string, dayNum int) (bool, error)

type DropPatternElement

type DropPatternElement struct {
	DropPatternElementRepo *repo.DropPatternElement
}

func NewDropPatternElement

func NewDropPatternElement(dropPatternElementRepo *repo.DropPatternElement) *DropPatternElement

func (*DropPatternElement) GetDropPatternElementsByPatternId

func (s *DropPatternElement) GetDropPatternElementsByPatternId(ctx context.Context, patternId int) ([]*model.DropPatternElement, error)

Cache: dropPatternElements#patternId:{patternId}, 24hrs

func (*DropPatternElement) GetDropPatternElementsMapByPatternIds

func (s *DropPatternElement) GetDropPatternElementsMapByPatternIds(ctx context.Context, patternIds []int) (map[int][]*model.DropPatternElement, error)

type DropReport

type DropReport struct {
	DropReportRepo *repo.DropReport
	// ColdDropReportRepo, when not nil, serves the archived part of the time ranges of the drop matrix, of the
	// pattern matrix and of the customized trend (see CalcDropMatrixForIntervalsBySourceCategories,
	// CalcTotalQuantityForPatternMatrixBySourceCategories and CalcTotalQuantityForTrend). In shadow mode
	// (ColdstoreShadowEnabled), those answer from PostgreSQL alone and compare the split results in the background.
	ColdDropReportRepo *repo.ColdDropReport
	// contains filtered or unexported fields
}

func NewDropReport

func NewDropReport(dropReportRepo *repo.DropReport, coldDropReportRepo *repo.ColdDropReport) *DropReport

func (*DropReport) CalcDropMatrixForIntervalsBySourceCategories

func (s *DropReport) CalcDropMatrixForIntervalsBySourceCategories(
	ctx context.Context, queryCtxs []*model.DropReportQueryContext, sourceCategories []string,
) ([]map[string][]*model.TotalTimesResult, []map[string][]*model.QuantityUniqCountResultForDropMatrix, error)

CalcDropMatrixForIntervalsBySourceCategories, with the cold storage enabled for queries (ColdDropReportRepo), reads the part of each interval before the hot boundary from the cold storage and the rest from PostgreSQL, and adds the two up.

func (*DropReport) CalcQuantityUniqCount

func (s *DropReport) CalcQuantityUniqCount(
	ctx context.Context, queryCtx *model.DropReportQueryContext,
) ([]*model.QuantityUniqCountResultForDropMatrix, error)

func (*DropReport) CalcRecentUniqueUserCountBySource

func (s *DropReport) CalcRecentUniqueUserCountBySource(ctx context.Context, duration time.Duration) ([]*modelv2.UniqueUserCountBySource, error)

func (*DropReport) CalcTotalQuantityForPatternMatrix

func (s *DropReport) CalcTotalQuantityForPatternMatrix(
	ctx context.Context, queryCtx *model.DropReportQueryContext,
) ([]*model.TotalQuantityResultForPatternMatrix, error)

func (*DropReport) CalcTotalQuantityForPatternMatrixBySourceCategories

func (s *DropReport) CalcTotalQuantityForPatternMatrixBySourceCategories(
	ctx context.Context, queryCtx *model.DropReportQueryContext, sourceCategories []string,
) (map[string][]*model.TotalQuantityResultForPatternMatrix, error)

CalcTotalQuantityForPatternMatrixBySourceCategories, with the cold storage enabled for queries (ColdDropReportRepo), reads the part of the interval before the hot boundary from the cold storage and the rest from PostgreSQL, and adds the two up.

func (*DropReport) CalcTotalQuantityForTrend

func (s *DropReport) CalcTotalQuantityForTrend(
	ctx context.Context, server string, startTime *time.Time, intervalLength time.Duration, intervalNum int, stageIdItemIdMap map[int][]int, accountId null.Int, sourceCategory string,
) ([]*model.TotalQuantityResultForTrend, error)

CalcTotalQuantityForTrend, with the cold storage enabled for queries (ColdDropReportRepo), reads the reports before the hot boundary from the cold storage and the rest from PostgreSQL, and adds the two up per bucket. A bucket that straddles the boundary is counted from both.

func (*DropReport) CalcTotalStageQuantityForShimSiteStats

func (s *DropReport) CalcTotalStageQuantityForShimSiteStats(ctx context.Context, server string, isRecent24h bool) ([]*modelv2.TotalStageTime, error)

func (*DropReport) CalcTotalTimesForDropMatrix

func (s *DropReport) CalcTotalTimesForDropMatrix(
	ctx context.Context, queryCtx *model.DropReportQueryContext,
) ([]*model.TotalTimesResult, error)

func (*DropReport) CalcTotalTimesForPatternMatrix

func (s *DropReport) CalcTotalTimesForPatternMatrix(
	ctx context.Context, queryCtx *model.DropReportQueryContext,
) ([]*model.TotalTimesResult, error)

func (*DropReport) CalcTotalTimesForTrend

func (s *DropReport) CalcTotalTimesForTrend(
	ctx context.Context, server string, startTime *time.Time, intervalLength time.Duration, intervalNum int, stageIds []int, accountId null.Int, sourceCategory string,
) ([]*model.TotalTimesResultForTrend, error)

CalcTotalTimesForTrend splits the trend at the hot boundary as CalcTotalQuantityForTrend.

func (*DropReport) GetDropReports

func (s *DropReport) GetDropReports(
	ctx context.Context, queryCtx *model.DropReportQueryContext,
) ([]*model.DropReport, error)

func (*DropReport) RunWithStatementTimeout

func (s *DropReport) RunWithStatementTimeout(ctx context.Context, timeout time.Duration, fn func(ctx context.Context) error) error

RunWithStatementTimeout runs fn with a context in which PostgreSQL cancels the drop report aggregations still running timeout after it was called. Each aggregation runs in a transaction of its own; fn holds no connection between them.

type Export

type Export struct {
	DropReportService         *DropReport
	DropPatternElementService *DropPatternElement
	ItemService               *Item
}

func NewExport

func NewExport(
	dropReportService *DropReport,
	dropPatternElementService *DropPatternElement,
	itemService *Item,
) *Export

func (*Export) ExportDropReportsAndPatterns

func (s *Export) ExportDropReportsAndPatterns(
	ctx context.Context, server string, startTime *time.Time, endTime *time.Time, times null.Int, stageId int, itemIds []int, accountId null.Int, sourceCategory string,
) (*model.ExportDropReportsAndPatternsResult, error)

type Formula

type Formula struct {
	PropertyRepo *repo.Property
}

func NewFormula

func NewFormula(propertyRepo *repo.Property) *Formula

func (*Formula) GetFormula

func (s *Formula) GetFormula(ctx context.Context) (json.RawMessage, error)

Cache: (singular) formula, 1 hr

type FrontendConfig

type FrontendConfig struct {
	PropertyRepo *repo.Property
}

func NewFrontendConfig

func NewFrontendConfig(propertyRepo *repo.Property) *FrontendConfig

func (*FrontendConfig) GetFrontendConfig

func (s *FrontendConfig) GetFrontendConfig(ctx context.Context) (json.RawMessage, error)

Cache: (singular) frontend_config, 1 hr

type GeoIP

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

func NewGeoIP

func NewGeoIP(db *geoip2.Reader) *GeoIP

func (*GeoIP) Country

func (s *GeoIP) Country(ip string) (*geoip2.Country, error)

func (*GeoIP) InChinaMainland

func (s *GeoIP) InChinaMainland(ip string) bool

type Health

type Health struct {
	DB    *bun.DB
	Redis *redis.Client
	NATS  *nats.Conn
}

func NewHealth

func NewHealth(db *bun.DB, redis *redis.Client, nats *nats.Conn) *Health

func (*Health) Check

func (s *Health) Check(ctx context.Context) *HealthStatus

type HealthStatus

type HealthStatus struct {
	Status   string `json:"status"`
	Postgres string `json:"postgres"`
	Redis    string `json:"redis"`
	// NATS is the connection status, e.g. CONNECTED or RECONNECTING
	NATS string `json:"nats"`
}

HealthStatus is the state of the dependencies: "degraded" when any of them is down.

type Item

type Item struct {
	ItemRepo *repo.Item
}

func NewItem

func NewItem(itemRepo *repo.Item) *Item

func (*Item) GetItemByArkId

func (s *Item) GetItemByArkId(ctx context.Context, arkItemId string) (*model.Item, error)

Cache: item#arkItemId:{arkItemId}, 1 hr

func (*Item) GetItemById

func (s *Item) GetItemById(ctx context.Context, itemId int) (*model.Item, error)

func (*Item) GetItems

func (s *Item) GetItems(ctx context.Context) ([]*model.Item, error)

Cache: items, 1 hr

func (*Item) GetItemsMapByArkId

func (s *Item) GetItemsMapByArkId(ctx context.Context) (map[string]*model.Item, error)

Cache: (singular) itemsMapByArkId, 1 hr

func (*Item) GetItemsMapById

func (s *Item) GetItemsMapById(ctx context.Context) (map[int]*model.Item, error)

Cache: (singular) itemsMapById, 1 hr

func (*Item) GetRecruitTagItemsByBilingualName

func (s *Item) GetRecruitTagItemsByBilingualName(ctx context.Context) (map[string]string, error)

Cache: (singular) recruitTagMap, 1 hr

func (*Item) GetShimItemByArkId

func (s *Item) GetShimItemByArkId(ctx context.Context, arkItemId string) (*modelv2.Item, error)

Cache: shimItem#arkItemId:{arkItemId}, 1 hr

func (*Item) GetShimItems

func (s *Item) GetShimItems(ctx context.Context) ([]*modelv2.Item, error)

Cache: (singular) shimItems, 1 hr; records last modified time

func (*Item) SearchItemByName

func (s *Item) SearchItemByName(ctx context.Context, name string) (*model.Item, error)

type Notice

type Notice struct {
	NoticeRepo *repo.Notice
}

func NewNotice

func NewNotice(noticeRepo *repo.Notice) *Notice

func (*Notice) GetNotices

func (s *Notice) GetNotices(ctx context.Context) ([]*model.Notice, error)

Cache: (singular) notices, 10 seconds; records last modified time

type PatternMatrix

type PatternMatrix struct {
	Config                      *appconfig.Config
	TimeRangeService            *TimeRange
	DropReportService           *DropReport
	DropInfoService             *DropInfo
	PatternMatrixElementService *PatternMatrixElement
	DropPatternElementService   *DropPatternElement
	StageService                *Stage
	ItemService                 *Item
}

func NewPatternMatrix

func NewPatternMatrix(
	config *appconfig.Config,
	timeRangeService *TimeRange,
	dropReportService *DropReport,
	dropInfoService *DropInfo,
	patternMatrixElementService *PatternMatrixElement,
	dropPatternElementService *DropPatternElement,
	stageService *Stage,
	itemService *Item,
) *PatternMatrix

func (*PatternMatrix) DropGlobalPatternMatrixCaches

func (s *PatternMatrix) DropGlobalPatternMatrixCaches(server string)

DropGlobalPatternMatrixCaches deletes the cached global pattern matrices of server that RefreshGlobalPatternMatrixCaches replaces, those cached only: a refresh of them in another process left them stale, and requests recalculate them.

func (*PatternMatrix) GetShimPatternMatrix

func (s *PatternMatrix) GetShimPatternMatrix(ctx context.Context, server string, accountId null.Int, sourceCategory string, showAllPatterns bool,
) (*modelv2.PatternMatrixQueryResult, error)

Cache: shimGlobalPatternMatrix#server|sourceCategory|showAllPatterns:{server}|{sourceCategory}|{showAllPatterns}, 24hrs, records last modified time Called by frontend, used for both global and personal, only for latest timeranges

func (*PatternMatrix) GlobalPatternMatrixCachesUsed

func (s *PatternMatrix) GlobalPatternMatrixCachesUsed(server string) bool

GlobalPatternMatrixCachesUsed reports whether any of the global pattern matrices of server that RefreshGlobalPatternMatrixCaches replaces is used (see cache.Set.Used): whether this process serves them, and should follow their refreshes (cachesync).

func (*PatternMatrix) RefreshGlobalPatternMatrixCaches

func (s *PatternMatrix) RefreshGlobalPatternMatrixCaches(ctx context.Context, server string) error

RefreshGlobalPatternMatrixCaches recalculates the global pattern matrices of server and replaces the cached ones (for every source category, with all and with the top patterns). Requests keep getting the previous ones in the meantime instead of all waiting for a recalculation. If the recalculation fails, the cached ones are dropped, also if it panics (the worker recovers the panic): the source categories cached before it must not keep matrices of this refresh while the others keep those of an earlier one.

func (*PatternMatrix) RunCalcPatternMatrixJob

func (s *PatternMatrix) RunCalcPatternMatrixJob(ctx context.Context, server string) error

Calc today's pattern matrix elements and save to DB Called by worker

func (*PatternMatrix) UpdatePatternMatrixByGivenDate

func (s *PatternMatrix) UpdatePatternMatrixByGivenDate(ctx context.Context, server string, date *time.Time) error

Update pattern matrix elements for a given date (entire day) Called by admin api

func (*PatternMatrix) WarmUpGlobalPatternMatrixCaches

func (s *PatternMatrix) WarmUpGlobalPatternMatrixCaches(ctx context.Context, server string) error

WarmUpGlobalPatternMatrixCaches fills the cached global pattern matrices of server (for every source category, with all and with the top patterns) as requests do: it skips those cached, and waits for a calculation a request runs instead of running another one. RefreshGlobalPatternMatrixCaches recalculates them instead.

type PatternMatrixElement

type PatternMatrixElement struct {
	PatternMatrixElementRepo *repo.PatternMatrixElement
}

func NewPatternMatrixElement

func NewPatternMatrixElement(patternMatrixElementRepo *repo.PatternMatrixElement) *PatternMatrixElement

func (*PatternMatrixElement) BatchSaveElements

func (s *PatternMatrixElement) BatchSaveElements(ctx context.Context, elements []*model.PatternMatrixElement, server string) error

func (*PatternMatrixElement) CalcGlobalPatternMatrixAggregates

func (s *PatternMatrixElement) CalcGlobalPatternMatrixAggregates(
	ctx context.Context, server string, targets []*model.GlobalPatternMatrixTarget, sourceCategories []string,
) (map[string]*model.GlobalPatternMatrixAggregates, error)

func (*PatternMatrixElement) DeleteByServerAndDayNum

func (s *PatternMatrixElement) DeleteByServerAndDayNum(ctx context.Context, server string, dayNum int) error

func (*PatternMatrixElement) IsExistByServerAndDayNum

func (s *PatternMatrixElement) IsExistByServerAndDayNum(ctx context.Context, server string, dayNum int) (bool, error)

type RejectRulesReevaluationEvaluationContext

type RejectRulesReevaluationEvaluationContext struct {
	OriginalReport  *model.DropReport           `json:"originalReport"`
	EvaluateContext *reportverifs.ReportContext `json:"evaluateContext"`
}

type RejectRulesReevaluationEvaluationResult

type RejectRulesReevaluationEvaluationResult struct {
	RejectRulesReevaluationEvaluationContext

	EvaluationShouldRejectToReliability *int `json:"evaluationShouldRejectToReliability"`
}

type RejectRulesReevaluationEvaluationResultSet

type RejectRulesReevaluationEvaluationResultSet []*RejectRulesReevaluationEvaluationResult

func (RejectRulesReevaluationEvaluationResultSet) ChangeSet

func (RejectRulesReevaluationEvaluationResultSet) Summary

type RejectRulesReevaluationEvaluationResultSetChangeSet

type RejectRulesReevaluationEvaluationResultSetChangeSet []*RejectRulesReevaluationEvaluationResultSetDiff

type RejectRulesReevaluationEvaluationResultSetDiff

type RejectRulesReevaluationEvaluationResultSetDiff struct {
	ReportID        int `json:"reportId"`
	FromReliability int `json:"fromReliability"`
	ToReliability   int `json:"toReliability"`
}

type RejectRulesReevaluationEvaluationResultSetSummary

type RejectRulesReevaluationEvaluationResultSetSummary struct {
	TotalCount         int                                                                   `json:"totalCount"`
	ChangeSetCount     int                                                                   `json:"changeSetCount"`
	ReliabilityChanges []RejectRulesReevaluationEvaluationResultSetSummaryReliabilityChanges `json:"reliabilityChanges"`

	SampledEvaluations RejectRulesReevaluationEvaluationResultSetSummarySampledEvaluations `json:"sampledEvaluations"`
}

type RejectRulesReevaluationEvaluationResultSetSummaryReliabilityChanges

type RejectRulesReevaluationEvaluationResultSetSummaryReliabilityChanges struct {
	From int `json:"from"`
	To   int `json:"to"`

	Count int `json:"count"`
}

type RejectRulesReevaluationEvaluationResultSetSummarySampledEvaluations

type RejectRulesReevaluationEvaluationResultSetSummarySampledEvaluations struct {
	ShouldReject []*RejectRulesReevaluationEvaluationResult `json:"shouldReject"`
	ShouldPass   []*RejectRulesReevaluationEvaluationResult `json:"shouldPass"`
}

type Report

type Report struct {
	DB                     *bun.DB
	Redis                  *redis.Client
	NatsConn               *nats.Conn
	NatsJS                 nats.JetStreamContext
	ItemService            *Item
	StageService           *Stage
	AccountService         *Account
	TimeRangeService       *TimeRange
	StageRepo              *repo.Stage
	DropInfoRepo           *repo.DropInfo
	DropReportRepo         *repo.DropReport
	DropPatternRepo        *repo.DropPattern
	DropReportExtraRepo    *repo.DropReportExtra
	DropPatternElementRepo *repo.DropPatternElement
}

func NewReport

func NewReport(db *bun.DB, redisClient *redis.Client, natsConn *nats.Conn, natsJs nats.JetStreamContext, itemService *Item, stageService *Stage, stageRepo *repo.Stage, dropInfoRepo *repo.DropInfo, dropReportRepo *repo.DropReport, dropReportExtraRepo *repo.DropReportExtra, dropPatternRepo *repo.DropPattern, dropPatternElementRepo *repo.DropPatternElement, accountService *Account, timeRangeService *TimeRange) *Report

func (*Report) PipelineAccount

func (s *Report) PipelineAccount(ctx *fiber.Ctx) (accountId int, err error)

func (*Report) PipelineAggregateGachaboxDrops

func (s *Report) PipelineAggregateGachaboxDrops(ctx context.Context, singleReport *types.ReportTaskSingleReport) error

func (*Report) PipelineMergeDropsAndMapDropTypes

func (s *Report) PipelineMergeDropsAndMapDropTypes(ctx context.Context, drops []types.ArkDrop) ([]*types.Drop, error)

func (*Report) PipelinePreprocessRecruitmentTags

func (s *Report) PipelinePreprocessRecruitmentTags(ctx context.Context, req *types.SingularReportRequest) error

func (*Report) PipelinePreprocessRerunStageIdForMaa

func (s *Report) PipelinePreprocessRerunStageIdForMaa(ctx context.Context, req *types.SingularReportRequest) error

func (*Report) PipelineTaskId

func (s *Report) PipelineTaskId(ctx *fiber.Ctx) string

func (*Report) PreprocessAndQueueBatchReport

func (s *Report) PreprocessAndQueueBatchReport(ctx *fiber.Ctx, req *types.BatchReportRequest) (taskId string, err error)

func (*Report) PreprocessAndQueueSingularReport

func (s *Report) PreprocessAndQueueSingularReport(ctx *fiber.Ctx, req *types.SingularReportRequest) (taskId string, err error)

returns taskID and error, if any

func (*Report) RecallSingularReport

func (s *Report) RecallSingularReport(ctx context.Context, req *types.SingularReportRecallRequest) error

type SEOCatalog

type SEOCatalog struct {
	Items map[string]*SEOItem
	// ItemList is ordered by sort ID
	ItemList []*SEOItem
	Stages   map[string]*SEOStage
	// StageList is ordered by the numerical stage ID
	StageList []*SEOStage
	Zones     map[string]*SEOZone
	// ChangedAt is when the catalog replaced one with other rows, which the rows have no time of their own to tell;
	// zero for the first one loaded after a start, so that a start does not move the Last-Modified of every page
	ChangedAt time.Time
}

SEOCatalog holds the items, stages and zones.

func NewSEOCatalog

func NewSEOCatalog(items []*model.Item, stages []*model.Stage, zones []*model.Zone) *SEOCatalog

type SEOData

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

SEOData is the data of the server-rendered stats pages. It never waits for the database: the items, stages and zones are reloaded in the background, and the matrix is the cached global matrix of the frontend, which the calc worker keeps up to date.

func NewSEOData

func NewSEOData(lc fx.Lifecycle, conf *appconfig.Config, itemService *Item, stageService *Stage, zoneService *Zone, dropMatrixService *DropMatrix) *SEOData

func (*SEOData) Catalog

func (d *SEOData) Catalog() *SEOCatalog

Catalog returns the items, stages and zones, or nil before they are loaded.

func (*SEOData) Matrix

func (d *SEOData) Matrix(server string) *SEOMatrix

Matrix returns the global matrix of server shown by the frontend, or nil if it is not calculated (yet). It only looks at the cache, as calculating the matrix takes long.

func (*SEOData) RefreshCatalog

func (d *SEOData) RefreshCatalog(ctx context.Context) error

RefreshCatalog reloads the items, stages and zones, and replaces the catalog if they changed. It is not safe for concurrent use.

type SEOExistence

type SEOExistence map[string]struct {
	Exist     bool     `json:"exist"`
	OpenTime  null.Int `json:"openTime"`
	CloseTime null.Int `json:"closeTime"`
}

SEOExistence is the existence of an item, stage or zone in each server. Stages and zones of events have the times they open and close (epoch milliseconds), items none.

func (SEOExistence) In

func (e SEOExistence) In(server string) bool

func (SEOExistence) OpenAt

func (e SEOExistence) OpenAt(server string, now time.Time) bool

OpenAt tells whether the item, stage or zone is open on server at now, like the frontend (src/utils/existUtils.js): it exists there, has opened (no open time, or one not after now) and has not closed (no close time, or one after now). The close time of what never closes, constant.FakeEndTimeMilli, counts as none.

type SEOI18n

type SEOI18n map[string]string

SEOI18n is a text in the languages of the frontend (zh, en, ja, ko).

func (SEOI18n) In

func (s SEOI18n) In(lang string) string

In returns the text in lang, or else in en, or else in zh, like the frontend (src/utils/strings.js translate); "" if there is none.

type SEOItem

type SEOItem struct {
	ArkID string
	Type  string
	Name  SEOI18n
	// Rarity is the rarity as stored, 0 to 4 (the tier minus 1)
	Rarity    int
	SortID    int
	Group     string
	Existence SEOExistence
	// Alias holds the other names of the item per language for the search of the frontend (zh and ja only, October
	// 2026). They are not unique: 土块 is each of 30011 to 30014.
	Alias map[string][]string
	// Pron holds the readings of the aliases per language, syllables separated by backticks (gu`yuan`yan)
	Pron map[string][]string
}

func (*SEOItem) DisplayName

func (i *SEOItem) DisplayName(lang string) string

DisplayName is the name of the item in lang (see SEOI18n.In), or its ID if it has none.

type SEOMatrix

type SEOMatrix struct {
	Server       string
	LastModified time.Time
	// ByItem holds the rows of each item ordered by rate, then times descending, then stage ID: the frontend's order
	ByItem map[string][]SEORow
	// ByStage holds the rows of each stage ordered by rate, then times descending, then item ID
	ByStage map[string][]SEORow
}

SEOMatrix is the global matrix of a server indexed by item and by stage.

func NewSEOMatrix

func NewSEOMatrix(server string, rows []*modelv2.OneDropMatrixElement, lastModified time.Time) *SEOMatrix

type SEORow

type SEORow struct {
	*modelv2.OneDropMatrixElement
	// Rate is quantity / times rounded to 5 decimals, the frontend's percentage (src/utils/getters.js): the expected
	// quantity per run, which exceeds 1 for items dropped more than once per run on average
	Rate float64
}

SEORow is a row of the matrix with its drop rate.

type SEOStage

type SEOStage struct {
	ArkID   string
	StageID int
	Code    SEOI18n
	// Sanity is the sanity cost of a full clear, null for stages without one (the gachas, the recruitment)
	Sanity null.Int
	// IsGacha tells whether the stage is a gacha (extra process GACHABOX), whose times count the items drawn
	IsGacha   bool
	Zone      *SEOZone
	Existence SEOExistence
}

func (*SEOStage) DisplayCode

func (s *SEOStage) DisplayCode(lang string) string

DisplayCode is the code of the stage in lang (see SEOI18n.In), or its ID if it has none.

func (*SEOStage) DisplayName

func (s *SEOStage) DisplayName(lang string) string

DisplayName is the code of the stage and the name of its zone in lang: stages have no name of their own. A stage named like its zone (the recruitment statistics) is named once.

func (*SEOStage) SanityCost

func (s *SEOStage) SanityCost() (sanity int64, ok bool)

SanityCost is the sanity a run of the stage costs. ok is false if it has none to compare drops by: none known (or the placeholder 99 the v2 API fills in for none), 0, or a gacha or the recruitment, whose rows count draws and recruitments rather than runs.

func (*SEOStage) SanityPerItem

func (s *SEOStage) SanityPerItem(times, quantity int) (perItem float64, ok bool)

SanityPerItem is the sanity required per item of a row of the stage with times and quantity: sanity × times ÷ quantity, from the counts rather than the rounded rate the pages divide by (stats.headers.apPPR). ok is false if the stage has no sanity cost (see SanityCost) or the row no drops.

type SEOZone

type SEOZone struct {
	ArkID     string
	ZoneID    int
	Index     int
	Category  string
	Name      SEOI18n
	Existence SEOExistence
}

func (*SEOZone) DisplayName

func (z *SEOZone) DisplayName(lang string) string

DisplayName is the name of the zone in lang (see SEOI18n.In), or its ID if it has none; "" for no zone.

type ShortURL

type ShortURL struct {
	ItemService  *Item
	StageService *Stage
	ZoneService  *Zone
	GeoIPService *GeoIP
}

func NewShortURL

func NewShortURL(itemService *Item, stageService *Stage, zoneService *Zone, geoIPService *GeoIP) *ShortURL

func (*ShortURL) Resolve

func (s *ShortURL) Resolve(ctx *fiber.Ctx, path string) string

type SiteStats

type SiteStats struct {
	DropReportService        *DropReport
	DropMatrixElementService *DropMatrixElement
	StageService             *Stage
	ItemService              *Item
	// contains filtered or unexported fields
}

func NewSiteStats

func NewSiteStats(
	dropReportService *DropReport,
	dropMatrixElementService *DropMatrixElement,
	stageService *Stage,
	itemService *Item,
	redisClient *redis.Client,
) *SiteStats

func (*SiteStats) DropShimSiteStats

func (s *SiteStats) DropShimSiteStats(server string)

DropShimSiteStats deletes the cached site stats of server, if they are cached: a refresh of them in another process left them stale, and requests recalculate them.

func (*SiteStats) GetShimSiteStats

func (s *SiteStats) GetShimSiteStats(ctx context.Context, server string) (*modelv2.SiteStats, error)

Cache: shimSiteStats#server:{server}, 24hrs, records last modified time

A request on a cold cache calculates under the calculation lock, after any refresh in progress, and caches its stats after releasing it: should a refresh then calculate and cache newer stats first, MutexGetSet notices the write and does not cache the request's. The calculation lock is taken while holding the cache's key lock, which refreshes never take, and released before caching, so that no lock cycle with the cache's own locks exists.

func (*SiteStats) InvalidateSiteStatsBase

func (s *SiteStats) InvalidateSiteStatsBase(ctx context.Context, server string) error

InvalidateSiteStatsBase must be called after drop matrix elements of a past day of a server have been rewritten: every process, including those calculating a base right now, then recalculates its base.

func (*SiteStats) RefreshShimSiteStats

func (s *SiteStats) RefreshShimSiteStats(ctx context.Context, server string) (*modelv2.SiteStats, error)

RefreshShimSiteStats recalculates the site stats of server and replaces the cached ones. Requests keep getting the previous ones in the meantime instead of waiting for a recalculation, unless the cache is cold. If the recalculation fails, the cached ones are dropped, also if it panics.

func (*SiteStats) ShimSiteStatsUsed

func (s *SiteStats) ShimSiteStatsUsed(server string) bool

ShimSiteStatsUsed reports whether the site stats of server are used (see cache.Set.Used): whether this process serves them, and should follow their refreshes (cachesync).

type Snapshot

type Snapshot struct {
	SnapshotRepo *repo.Snapshot
}

func NewSnapshot

func NewSnapshot(snapshotRepo *repo.Snapshot) *Snapshot

func (*Snapshot) CalculateVersion

func (s *Snapshot) CalculateVersion(content string) string

func (*Snapshot) SaveSnapshot

func (s *Snapshot) SaveSnapshot(ctx context.Context, key string, content string) (*model.Snapshot, error)

type Stage

type Stage struct {
	StageRepo *repo.Stage
}

func NewStage

func NewStage(stageRepo *repo.Stage) *Stage

func (*Stage) GetGachaBoxStages

func (s *Stage) GetGachaBoxStages(ctx context.Context) ([]*model.Stage, error)

func (*Stage) GetShimStageByArkId

func (s *Stage) GetShimStageByArkId(ctx context.Context, arkStageId string, server string) (*modelv2.Stage, error)

Cache: shimStages#server:{server}, through GetShimStages

func (*Stage) GetShimStages

func (s *Stage) GetShimStages(ctx context.Context, server string) ([]*modelv2.Stage, error)

Cache: shimStages#server:{server}, 1 hr; records last modified time

func (*Stage) GetShimStagesForFakeTime

func (s *Stage) GetShimStagesForFakeTime(ctx context.Context, server string, t time.Time) ([]*modelv2.Stage, error)

Not Cached

func (*Stage) GetStageByArkId

func (s *Stage) GetStageByArkId(ctx context.Context, arkStageId string) (*model.Stage, error)

Cache: stage#arkStageId:{arkStageId}, 1 hr

func (*Stage) GetStageById

func (s *Stage) GetStageById(ctx context.Context, stageId int) (*model.Stage, error)

func (*Stage) GetStages

func (s *Stage) GetStages(ctx context.Context) ([]*model.Stage, error)

Cache: (singular) stages, 1 hr

func (*Stage) GetStagesByZoneId

func (s *Stage) GetStagesByZoneId(ctx context.Context, zoneId int) ([]*model.Stage, error)

func (*Stage) GetStagesMapByArkId

func (s *Stage) GetStagesMapByArkId(ctx context.Context) (map[string]*model.Stage, error)

Cache: (singular) stagesMapByArkId, 1 hr

func (*Stage) GetStagesMapById

func (s *Stage) GetStagesMapById(ctx context.Context) (map[int]*model.Stage, error)

Cache: (singular) stagesMapById, 1 hr

func (*Stage) SearchStageByCode

func (s *Stage) SearchStageByCode(ctx context.Context, code string) (*model.Stage, error)

type TimeRange

type TimeRange struct {
	TimeRangeRepo *repo.TimeRange
	DropInfoRepo  *repo.DropInfo
}

func NewTimeRange

func NewTimeRange(timeRangeRepo *repo.TimeRange, dropInfoRepo *repo.DropInfo) *TimeRange

func (*TimeRange) GetAllMaxAccumulableTimeRangesByServer

func (s *TimeRange) GetAllMaxAccumulableTimeRangesByServer(ctx context.Context, server string) (map[int]map[int][]*model.TimeRange, error)

GetAllMaxAccumulableTimeRangesByServer returns, for every stage and item of server, all of its accumulable segments (see accumulableSegments) in chronological order, each as one time range from the start of its first time range to the latest end of its time ranges. The global drop matrix is calculated over the last one, and the drop matrix elements of a day are rendered per segment. Cache: allMaxAccumulableTimeRanges#server:{server}, 5 min

func (*TimeRange) GetCurrentTimeRangesByServer

func (s *TimeRange) GetCurrentTimeRangesByServer(ctx context.Context, server string) ([]*model.TimeRange, error)

func (*TimeRange) GetLatestTimeRangesByServer

func (s *TimeRange) GetLatestTimeRangesByServer(ctx context.Context, server string) (map[int]*model.TimeRange, error)

Cache: latestTimeRanges#server:{server}, 5 min

func (*TimeRange) GetMaxAccumulableTimeRangesByServer

func (s *TimeRange) GetMaxAccumulableTimeRangesByServer(ctx context.Context, server string) (map[int]map[int][]*model.TimeRange, error)

GetMaxAccumulableTimeRangesByServer returns, for every stage and item of server, the time ranges of its latest accumulable segment (see accumulableSegments), newest first. The personal drop matrices are calculated over them. Cache: maxAccumulableTimeRanges#server:{server}, 5 min

func (*TimeRange) GetTimeRangeById

func (s *TimeRange) GetTimeRangeById(ctx context.Context, rangeId int) (*model.TimeRange, error)

Cache: timeRange#rangeId:{rangeId}, 1 hr

func (*TimeRange) GetTimeRangeByServerAndName

func (s *TimeRange) GetTimeRangeByServerAndName(ctx context.Context, server string, name string) (*model.TimeRange, error)

func (*TimeRange) GetTimeRangesByServer

func (s *TimeRange) GetTimeRangesByServer(ctx context.Context, server string) ([]*model.TimeRange, error)

Cache: timeRanges#server:{server}, 1 hr

func (*TimeRange) GetTimeRangesMap

func (s *TimeRange) GetTimeRangesMap(ctx context.Context, server string) (map[int]*model.TimeRange, error)

Cache: timeRangesMap#server:{server}, 5 min

type Trend

type Trend struct {
	DropReportService        *DropReport
	DropInfoService          *DropInfo
	StageService             *Stage
	ItemService              *Item
	DropMatrixElementService *DropMatrixElement
}

func NewTrend

func NewTrend(
	dropReportService *DropReport,
	dropInfoService *DropInfo,
	stageService *Stage,
	itemService *Item,
	dropMatrixElementService *DropMatrixElement,
) *Trend

func (*Trend) DropShimTrend

func (s *Trend) DropShimTrend(server string)

DropShimTrend deletes the cached trend of server, if it is cached: a refresh of it in another process left it stale, and requests recalculate it.

func (*Trend) GetShimCustomizedTrendResults

func (s *Trend) GetShimCustomizedTrendResults(
	ctx context.Context, server string, startTime *time.Time, intervalLength time.Duration, intervalNum int, stageIds []int, itemIds []int, accountId null.Int, sourceCategory string,
) (*modelv2.TrendQueryResult, error)

func (*Trend) GetShimTrend

func (s *Trend) GetShimTrend(ctx context.Context, server string) (*modelv2.TrendQueryResult, error)

Cache: shimTrend#server:{server}, 24hrs, records last modified time Called by frontend, only for global

func (*Trend) RefreshShimTrend

func (s *Trend) RefreshShimTrend(ctx context.Context, server string) error

RefreshShimTrend recalculates the trend of server from the drop matrix elements and replaces the cached one. Requests keep getting the previous one in the meantime instead of waiting for a recalculation, unless the cache is cold: then they wait for the refresh, see cache.Set.Refresh. The trend is not cached if it was dropped or replaced meanwhile (e.g. purged after an admin recalculation of the elements): it may have been calculated from the elements before. If the recalculation fails, the cached one is dropped, also if it panics (the worker recovers the panic). The trend is cached while its last modified time is recorded, as a request's calculation is (see cache.SetLastModifiedTime).

func (*Trend) ShimTrendUsed

func (s *Trend) ShimTrendUsed(server string) bool

ShimTrendUsed reports whether the trend of server is used (see cache.Set.Used): whether this process serves it, and should follow its refreshes (cachesync).

func (*Trend) WarmUpShimTrend

func (s *Trend) WarmUpShimTrend(ctx context.Context, server string) error

WarmUpShimTrend fills the cached trend of server as a request does: it skips it if it is cached, and waits for a calculation a request runs instead of running another one. RefreshShimTrend recalculates it instead.

type Upyun

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

func NewUpyun

func NewUpyun(conf *appconfig.Config) *Upyun

func (*Upyun) ImageURIToSignedURL

func (c *Upyun) ImageURIToSignedURL(uri, style string) (path string, err error)

func (*Upyun) InitImageUpload

func (c *Upyun) InitImageUpload(prefix string, uploadId string) (types.UpyunInitResponse, error)

func (*Upyun) MarshalImageURI

func (c *Upyun) MarshalImageURI(path string) string

func (*Upyun) VerifyImageUploadCallback

func (c *Upyun) VerifyImageUploadCallback(ctx *fiber.Ctx) (path string, err error)

type Zone

type Zone struct {
	ZoneRepo *repo.Zone
}

func NewZone

func NewZone(zoneRepo *repo.Zone) *Zone

func (*Zone) GetShimZoneByArkId

func (s *Zone) GetShimZoneByArkId(ctx context.Context, arkZoneId string) (*modelv2.Zone, error)

Cache: shimZone#arkZoneId:{arkZoneId}, 1 hr

func (*Zone) GetShimZones

func (s *Zone) GetShimZones(ctx context.Context) ([]*modelv2.Zone, error)

Cache: (singular) shimZones, 1 hr; records last modified time

func (*Zone) GetZoneByArkId

func (s *Zone) GetZoneByArkId(ctx context.Context, arkZoneId string) (*model.Zone, error)

Cache: zone#arkZoneId:{arkZoneId}, 1 hr

func (*Zone) GetZoneById

func (s *Zone) GetZoneById(ctx context.Context, id int) (*model.Zone, error)

func (*Zone) GetZones

func (s *Zone) GetZones(ctx context.Context) ([]*model.Zone, error)

Cache: (singular) zones, 1 hr

Jump to

Keyboard shortcuts

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