From 3524bc0fa0f966d61eedccba188438b2715a830e Mon Sep 17 00:00:00 2001 From: Myles <96409608+ice-myles@users.noreply.github.com> Date: Thu, 23 May 2024 17:12:12 +0300 Subject: [PATCH] Badges were moved from const to cfg (#45) --- .golangci.yml | 11 + application.yaml | 57 ++--- badges/.testdata/application.yaml | 56 ++--- badges/achieve_badges.go | 26 +-- badges/achieve_badges_test.go | 45 +++- badges/badges.go | 76 ++++++ badges/contract.go | 219 ++---------------- badges/fixture/fixture.go | 2 +- badges/get_badges.go | 6 +- badges/get_badges_test.go | 107 ++++----- ...ate_santa_badges_levels_and_roles_tasks.go | 6 +- friends-invited/friends-invited.go | 2 +- go.mod | 36 +-- go.sum | 64 ++--- levels-and-roles/fixture/fixture.go | 2 +- levels-and-roles/levels_and_roles.go | 2 +- tasks/contract.go | 2 +- tasks/fixture/fixture.go | 2 +- 18 files changed, 329 insertions(+), 392 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 5b01681..106a8bc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -510,6 +510,17 @@ linters-settings: ignore-map-index-ok: true ignore-chan-recv-ok: true + mnd: + checks: + - argument + - case + - condition + - return + ignored-numbers: + - '0' + - '1' + - '24' + linters: disable: # TODO remove asap! diff --git a/application.yaml b/application.yaml index 736877e..a8dfbcb 100644 --- a/application.yaml +++ b/application.yaml @@ -62,80 +62,81 @@ friends-invited_test: <<: *friendsInvitedMessageBroker consumingTopics: *friendsInvitedMessageBrokerTopics consumerGroup: santa-local-friends-invited-test - badges: &badges - milestones: - l1: + levels: + - name: Wave Starter toInclusive: 1 - l2: + - name: Beach Walker fromInclusive: 2 toInclusive: 3 - l3: + - name: Rhythm Keeper fromInclusive: 4 toInclusive: 5 - l4: + - name: Dance Captain fromInclusive: 6 toInclusive: 7 - l5: + - name: Vibe Master fromInclusive: 8 toInclusive: 9 - l6: + - name: Festival Guru fromInclusive: 10 - c1: + coins: + - name: Rookie Raver toInclusive: 10 - c2: + - name: Beats Saver fromInclusive: 20 toInclusive: 30 - c3: + - name: Tune Tracker fromInclusive: 40 toInclusive: 50 - c4: + - name: Rhythm Collector fromInclusive: 60 toInclusive: 70 - c5: + - name: Bass Booster fromInclusive: 80 toInclusive: 90 - c6: + - name: Melody Maker fromInclusive: 100 toInclusive: 110 - c7: + - name: Harmony Holder fromInclusive: 120 toInclusive: 130 - c8: + - name: Sound Seeker fromInclusive: 140 toInclusive: 150 - c9: + - name: Vibe Crafter fromInclusive: 160 toInclusive: 170 - c10: + - name: Festival Icon fromInclusive: 180 - s1: + socials: + - name: Meet Greeter toInclusive: 1 - s2: + - name: Friend Finder fromInclusive: 2 toInclusive: 3 - s3: + - name: Party Starter fromInclusive: 4 toInclusive: 5 - s4: + - name: Crowd Mixer fromInclusive: 6 toInclusive: 7 - s5: + - name: Dance Circle King fromInclusive: 8 toInclusive: 9 - s6: + - name: Wave Rider fromInclusive: 10 toInclusive: 11 - s7: + - name: Night Owl fromInclusive: 12 toInclusive: 13 - s8: + - name: Beach Buddy fromInclusive: 14 toInclusive: 15 - s9: + - name: Sunset Chaser fromInclusive: 16 toInclusive: 17 - s10: + - name: Dance Floor Legend fromInclusive: 18 wintr/connectors/storage/v2: runDDL: true diff --git a/badges/.testdata/application.yaml b/badges/.testdata/application.yaml index 6ea767e..68905c4 100644 --- a/badges/.testdata/application.yaml +++ b/badges/.testdata/application.yaml @@ -5,78 +5,80 @@ logger: encoder: console level: info badges: &badges - milestones: - l1: + levels: + - name: Wave Starter toInclusive: 1 - l2: + - name: Beach Walker fromInclusive: 2 toInclusive: 3 - l3: + - name: Rhythm Keeper fromInclusive: 4 toInclusive: 5 - l4: + - name: Dance Captain fromInclusive: 6 toInclusive: 7 - l5: + - name: Vibe Master fromInclusive: 8 toInclusive: 9 - l6: + - name: Festival Guru fromInclusive: 10 - c1: + coins: + - name: Rookie Raver toInclusive: 10 - c2: + - name: Beats Saver fromInclusive: 20 toInclusive: 30 - c3: + - name: Tune Tracker fromInclusive: 40 toInclusive: 50 - c4: + - name: Rhythm Collector fromInclusive: 60 toInclusive: 70 - c5: + - name: Bass Booster fromInclusive: 80 toInclusive: 90 - c6: + - name: Melody Maker fromInclusive: 100 toInclusive: 110 - c7: + - name: Harmony Holder fromInclusive: 120 toInclusive: 130 - c8: + - name: Sound Seeker fromInclusive: 140 toInclusive: 150 - c9: + - name: Vibe Crafter fromInclusive: 160 toInclusive: 170 - c10: + - name: Festival Icon fromInclusive: 180 - s1: + socials: + - name: Meet Greeter toInclusive: 1 - s2: + - name: Friend Finder fromInclusive: 2 toInclusive: 3 - s3: + - name: Party Starter fromInclusive: 4 toInclusive: 5 - s4: + - name: Crowd Mixer fromInclusive: 6 toInclusive: 7 - s5: + - name: Dance Circle King fromInclusive: 8 toInclusive: 9 - s6: + - name: Wave Rider fromInclusive: 10 toInclusive: 11 - s7: + - name: Night Owl fromInclusive: 12 toInclusive: 13 - s8: + - name: Beach Buddy fromInclusive: 14 toInclusive: 15 - s9: + - name: Sunset Chaser fromInclusive: 16 toInclusive: 17 - s10: + - name: Dance Floor Legend fromInclusive: 18 db: &badgesDatabase urls: diff --git a/badges/achieve_badges.go b/badges/achieve_badges.go index 9ac1cc3..9c5663c 100644 --- a/badges/achieve_badges.go +++ b/badges/achieve_badges.go @@ -30,10 +30,10 @@ func (r *repository) achieveBadges(ctx context.Context, userID string) error { / pr = new(progress) pr.UserID = userID } - if pr.AchievedBadges != nil && len(*pr.AchievedBadges) == len(&AllTypes) { + if pr.AchievedBadges != nil && len(*pr.AchievedBadges) == len(AllTypes) { return nil } - achievedBadges := pr.reEvaluateAchievedBadges(r) + achievedBadges := pr.reEvaluateAchievedBadges() if achievedBadges != nil && pr.AchievedBadges != nil && len(*pr.AchievedBadges) == len(*achievedBadges) { return nil } @@ -55,7 +55,7 @@ func (r *repository) achieveBadges(ctx context.Context, userID string) error { / for _, achievedBadge := range *achievedBadges { achievedBadgesCount[GroupTypeForEachType[achievedBadge]]++ } - newlyAchievedBadges := make([]*AchievedBadge, 0, len(&AllTypes)) + newlyAchievedBadges := make([]*AchievedBadge, 0, len(AllTypes)) outer: for _, achievedBadge := range *achievedBadges { if pr.AchievedBadges != nil { @@ -101,18 +101,18 @@ func (r *repository) achieveBadges(ctx context.Context, userID string) error { / return nil } -func (p *progress) reEvaluateAchievedBadges(repo *repository) *users.Enum[Type] { //nolint:funlen,gocognit,revive // . - if p.AchievedBadges != nil && len(*p.AchievedBadges) == len(&AllTypes) { +func (p *progress) reEvaluateAchievedBadges() *users.Enum[Type] { //nolint:funlen,gocognit,revive // . + if p.AchievedBadges != nil && len(*p.AchievedBadges) == len(AllTypes) { return p.AchievedBadges } - alreadyAchievedBadges := make(map[Type]any, len(&AllTypes)) + alreadyAchievedBadges := make(map[Type]any, len(AllTypes)) if p.AchievedBadges != nil { for _, badge := range *p.AchievedBadges { alreadyAchievedBadges[badge] = struct{}{} } } - achievedBadges := make(users.Enum[Type], 0, len(&AllTypes)) - for _, badgeType := range &AllTypes { + achievedBadges := make(users.Enum[Type], 0, len(AllTypes)) + for _, badgeType := range AllTypes { if _, alreadyAchieved := alreadyAchievedBadges[badgeType]; alreadyAchieved { achievedBadges = append(achievedBadges, badgeType) @@ -121,13 +121,13 @@ func (p *progress) reEvaluateAchievedBadges(repo *repository) *users.Enum[Type] var achieved bool switch GroupTypeForEachType[badgeType] { case LevelGroupType: - achieved = uint64(p.CompletedLevels) >= repo.cfg.Milestones[badgeType].FromInclusive + achieved = uint64(p.CompletedLevels) >= Milestones[badgeType].FromInclusive case CoinGroupType: if p.Balance > 0 { - achieved = uint64(p.Balance) >= repo.cfg.Milestones[badgeType].FromInclusive + achieved = uint64(p.Balance) >= Milestones[badgeType].FromInclusive } case SocialGroupType: - achieved = uint64(p.FriendsInvited) >= repo.cfg.Milestones[badgeType].FromInclusive + achieved = uint64(p.FriendsInvited) >= Milestones[badgeType].FromInclusive } if achieved { achievedBadges = append(achievedBadges, badgeType) @@ -327,7 +327,7 @@ func (s *completedLevelsSource) upsertProgress(ctx context.Context, completedLev } pr, err := s.getProgress(ctx, userID, true) if err != nil && !errors.Is(err, storage.ErrRelationNotFound) || - (pr != nil && pr.AchievedBadges != nil && (len(*pr.AchievedBadges) == len(&AllTypes))) || + (pr != nil && pr.AchievedBadges != nil && (len(*pr.AchievedBadges) == len(AllTypes))) || (pr != nil && (pr.CompletedLevels == int64(len(&levelsandroles.AllLevelTypes)) || IsBadgeGroupAchieved(pr.AchievedBadges, LevelGroupType))) { return errors.Wrapf(err, "failed to getProgress for userID:%v", userID) } @@ -376,7 +376,7 @@ func (s *balancesTableSource) upsertProgress(ctx context.Context, balance int64, pr, err := s.getProgress(ctx, userID, true) if err != nil && !errors.Is(err, storage.ErrRelationNotFound) || (pr != nil && pr.AchievedBadges != nil && - (balance > pr.Balance && (len(*pr.AchievedBadges) == len(&AllTypes) || IsBadgeGroupAchieved(pr.AchievedBadges, CoinGroupType)))) { + (balance > pr.Balance && (len(*pr.AchievedBadges) == len(AllTypes) || IsBadgeGroupAchieved(pr.AchievedBadges, CoinGroupType)))) { return errors.Wrapf(err, "failed to getProgress for userID:%v", userID) } if pr != nil && pr.Balance == balance { diff --git a/badges/achieve_badges_test.go b/badges/achieve_badges_test.go index 91ec76b..9bbf1ad 100644 --- a/badges/achieve_badges_test.go +++ b/badges/achieve_badges_test.go @@ -12,10 +12,39 @@ import ( wintrconfig "github.com/ice-blockchain/wintr/config" ) -//nolint:funlen // A lot of testcases in test +const ( + Level1Type Type = "l1" + Level2Type Type = "l2" + Level3Type Type = "l3" + Level4Type Type = "l4" + Level5Type Type = "l5" + Level6Type Type = "l6" + Coin1Type Type = "c1" + Coin2Type Type = "c2" + Coin3Type Type = "c3" + Coin4Type Type = "c4" + Coin5Type Type = "c5" + Coin6Type Type = "c6" + Coin7Type Type = "c7" + Coin8Type Type = "c8" + Coin9Type Type = "c9" + Coin10Type Type = "c10" + Social1Type Type = "s1" + Social2Type Type = "s2" + Social3Type Type = "s3" + Social4Type Type = "s4" + Social5Type Type = "s5" + Social6Type Type = "s6" + Social7Type Type = "s7" + Social8Type Type = "s8" + Social9Type Type = "s9" + Social10Type Type = "s10" +) + +//nolint:funlen,paralleltest,tparallel // A lot of testcases in test. Not needed parallel due to global variables usage. func Test_Progress_ReevaluateAchievedBadges(t *testing.T) { - t.Parallel() defCfg := defaultCfg() + loadBadges(defCfg) testCases := []*struct { *progress cfg *config @@ -36,13 +65,13 @@ func Test_Progress_ReevaluateAchievedBadges(t *testing.T) { }, { name: "Nothing to achieve cuz we already have social1 and level1", - progress: badgeProgress(&users.Enum[Type]{Social1Type, Level1Type}, 0, defCfg.Milestones[Social1Type].FromInclusive, 0), + progress: badgeProgress(&users.Enum[Type]{Social1Type, Level1Type}, 0, Milestones[Social1Type].FromInclusive, 0), cfg: defCfg, expectedNewBadgesState: &users.Enum[Type]{Social1Type, Level1Type}, }, { name: "Achieve next one for the socials", - progress: badgeProgress(&users.Enum[Type]{Social1Type, Level1Type}, 0, defCfg.Milestones[Social2Type].FromInclusive, 0), + progress: badgeProgress(&users.Enum[Type]{Social1Type, Level1Type}, 0, Milestones[Social2Type].FromInclusive, 0), cfg: defCfg, expectedNewBadgesState: &users.Enum[Type]{Social1Type, Level1Type, Social2Type}, }, @@ -96,7 +125,7 @@ func Test_Progress_ReevaluateAchievedBadges(t *testing.T) { }, { name: "Achieve next one for the balances", - progress: badgeProgress(&users.Enum[Type]{Social1Type, Level1Type}, defCfg.Milestones[Coin1Type].ToInclusive, 0, 0), + progress: badgeProgress(&users.Enum[Type]{Social1Type, Level1Type}, Milestones[Coin1Type].ToInclusive, 0, 0), cfg: defCfg, expectedNewBadgesState: &users.Enum[Type]{Social1Type, Level1Type, Coin1Type}, }, @@ -110,7 +139,7 @@ func Test_Progress_ReevaluateAchievedBadges(t *testing.T) { for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { t.Parallel() - actualAchievedBadges := tt.progress.reEvaluateAchievedBadges(&repository{cfg: tt.cfg}) + actualAchievedBadges := tt.progress.reEvaluateAchievedBadges() actualBadges := []Type{} if actualAchievedBadges != nil { actualBadges = []Type(*actualAchievedBadges) @@ -124,9 +153,9 @@ func Test_Progress_ReevaluateAchievedBadges(t *testing.T) { } } -//nolint:funlen // A lot of testcases +//nolint:funlen,paralleltest,tparallel // A lot of testcases. Not needed parallel due to global variables usage. func Test_IsBadgeGroupAchieved(t *testing.T) { - t.Parallel() + loadBadges(defaultCfg()) testCases := []*struct { name string alreadyAchievedBadges *users.Enum[Type] diff --git a/badges/badges.go b/badges/badges.go index 4729368..25c4a1c 100644 --- a/badges/badges.go +++ b/badges/badges.go @@ -4,6 +4,8 @@ package badges import ( "context" + "fmt" + "log" "sync" "github.com/goccy/go-json" @@ -22,6 +24,7 @@ func New(ctx context.Context, _ context.CancelFunc) Repository { appcfg.MustLoadFromKey(applicationYamlKey, &cfg) db := storage.MustConnect(ctx, ddl, applicationYamlKey) + loadBadges(&cfg) return &repository{ cfg: &cfg, @@ -33,6 +36,7 @@ func New(ctx context.Context, _ context.CancelFunc) Repository { func StartProcessor(ctx context.Context, cancel context.CancelFunc) Processor { var cfg config appcfg.MustLoadFromKey(applicationYamlKey, &cfg) + loadBadges(&cfg) var mbConsumer messagebroker.Client prc := &processor{repository: &repository{ @@ -174,3 +178,75 @@ func requestingUserID(ctx context.Context) (requestingUserID string) { return } + +func loadBadges(cfg *config) { + LevelTypeOrder = make(map[Type]int, len(cfg.Levels)) + CoinTypeOrder = make(map[Type]int, len(cfg.Coins)) + SocialTypeOrder = make(map[Type]int, len(cfg.Socials)) + AllTypeOrder = make(map[Type]int, len(cfg.Levels)+len(cfg.Coins)+len(cfg.Socials)) + LevelTypeNames = make(map[Type]string, len(cfg.Levels)) + CoinTypeNames = make(map[Type]string, len(cfg.Coins)) + SocialTypeNames = make(map[Type]string, len(cfg.Socials)) + GroupTypeForEachType = make(map[Type]GroupType, len(cfg.Levels)+len(cfg.Coins)+len(cfg.Socials)) + AllNames = make(map[GroupType]map[Type]string, len(GroupsOrderSummaries)) + AllGroups = make(map[GroupType][]Type, len(GroupsOrderSummaries)) + Milestones = make(map[Type]AchievingRange, len(cfg.Levels)+len(cfg.Coins)+len(cfg.Socials)) + + loadBadgesInfo(cfg.Levels, LevelGroupType) + AllNames[LevelGroupType] = make(map[Type]string, len(LevelTypeNames)) + for key, val := range LevelTypeNames { + AllNames[LevelGroupType][key] = val + } + loadBadgesInfo(cfg.Coins, CoinGroupType) + AllNames[CoinGroupType] = make(map[Type]string, len(CoinTypeNames)) + for key, val := range CoinTypeNames { + AllNames[CoinGroupType][key] = val + } + loadBadgesInfo(cfg.Socials, SocialGroupType) + AllNames[SocialGroupType] = make(map[Type]string, len(SocialTypeNames)) + for key, val := range SocialTypeNames { + AllNames[SocialGroupType][key] = val + } +} + +func loadBadgesInfo(badgeInfoList []*AchievingRange, groupType GroupType) { + offset := len(AllTypes) + for idx, val := range badgeInfoList { + typeName := getTypeName(groupType) + tpe := Type(fmt.Sprintf("%v%v", typeName, idx+1)) + AllTypes = append(AllTypes, tpe) + Milestones[tpe] = *val + + switch groupType { + case LevelGroupType: + LevelTypeOrder[tpe] = idx + LevelTypeNames[tpe] = val.Name + case CoinGroupType: + CoinTypeOrder[tpe] = idx + CoinTypeNames[tpe] = val.Name + case SocialGroupType: + SocialTypeOrder[tpe] = idx + SocialTypeNames[tpe] = val.Name + default: + log.Panic("wrong group type") + } + AllTypeOrder[tpe] = idx + offset + GroupTypeForEachType[tpe] = groupType + AllGroups[groupType] = append(AllGroups[groupType], tpe) + } +} + +func getTypeName(groupType GroupType) (typeName string) { + switch groupType { + case LevelGroupType: + typeName = "l" + case CoinGroupType: + typeName = "c" + case SocialGroupType: + typeName = "s" + default: + log.Panic("wrong group type") + } + + return +} diff --git a/badges/contract.go b/badges/contract.go index 9704e4c..b9c7fe5 100644 --- a/badges/contract.go +++ b/badges/contract.go @@ -16,227 +16,42 @@ import ( // Public API. -const ( - Level1Type Type = "l1" - Level2Type Type = "l2" - Level3Type Type = "l3" - Level4Type Type = "l4" - Level5Type Type = "l5" - Level6Type Type = "l6" - Coin1Type Type = "c1" - Coin2Type Type = "c2" - Coin3Type Type = "c3" - Coin4Type Type = "c4" - Coin5Type Type = "c5" - Coin6Type Type = "c6" - Coin7Type Type = "c7" - Coin8Type Type = "c8" - Coin9Type Type = "c9" - Coin10Type Type = "c10" - Social1Type Type = "s1" - Social2Type Type = "s2" - Social3Type Type = "s3" - Social4Type Type = "s4" - Social5Type Type = "s5" - Social6Type Type = "s6" - Social7Type Type = "s7" - Social8Type Type = "s8" - Social9Type Type = "s9" - Social10Type Type = "s10" -) - const ( LevelGroupType GroupType = "level" CoinGroupType GroupType = "coin" SocialGroupType GroupType = "social" ) +//nolint:gochecknoglobals // . var ( ErrRelationNotFound = storage.ErrRelationNotFound ErrHidden = errors.New("badges are hidden") ErrRaceCondition = errors.New("race condition") - //nolint:gochecknoglobals // It's just for more descriptive validation messages. - AllTypes = [26]Type{ - Level1Type, - Level2Type, - Level3Type, - Level4Type, - Level5Type, - Level6Type, - Coin1Type, - Coin2Type, - Coin3Type, - Coin4Type, - Coin5Type, - Coin6Type, - Coin7Type, - Coin8Type, - Coin9Type, - Coin10Type, - Social1Type, - Social2Type, - Social3Type, - Social4Type, - Social5Type, - Social6Type, - Social7Type, - Social8Type, - Social9Type, - Social10Type, - } - //nolint:gochecknoglobals,mnd,gomnd // . - LevelTypeOrder = map[Type]int{ - Level1Type: 0, - Level2Type: 1, - Level3Type: 2, - Level4Type: 3, - Level5Type: 4, - Level6Type: 5, - } - //nolint:gochecknoglobals,mnd,gomnd // . - CoinTypeOrder = map[Type]int{ - Coin1Type: 0, - Coin2Type: 1, - Coin3Type: 2, - Coin4Type: 3, - Coin5Type: 4, - Coin6Type: 5, - Coin7Type: 6, - Coin8Type: 7, - Coin9Type: 8, - Coin10Type: 9, - } - //nolint:gochecknoglobals,mnd,gomnd // . - SocialTypeOrder = map[Type]int{ - Social1Type: 0, - Social2Type: 1, - Social3Type: 2, - Social4Type: 3, - Social5Type: 4, - Social6Type: 5, - Social7Type: 6, - Social8Type: 7, - Social9Type: 8, - Social10Type: 9, - } - //nolint:gochecknoglobals,mnd,gomnd // . - AllTypeOrder = map[Type]int{ - Level1Type: 0, - Level2Type: 1, - Level3Type: 2, - Level4Type: 3, - Level5Type: 4, - Level6Type: 5, - Coin1Type: 6, - Coin2Type: 7, - Coin3Type: 8, - Coin4Type: 9, - Coin5Type: 10, - Coin6Type: 11, - Coin7Type: 12, - Coin8Type: 13, - Coin9Type: 14, - Coin10Type: 15, - Social1Type: 16, - Social2Type: 17, - Social3Type: 18, - Social4Type: 19, - Social5Type: 20, - Social6Type: 21, - Social7Type: 22, - Social8Type: 23, - Social9Type: 24, - Social10Type: 25, - } - //nolint:gochecknoglobals // . - LevelTypeNames = map[Type]string{ - Level1Type: "Ice Soldier", - Level2Type: "Wind Sergeant", - Level3Type: "Snow Lieutenant", - Level4Type: "Flake Colonel", - Level5Type: "Frost General", - Level6Type: "Ice Commander", - } - //nolint:gochecknoglobals // . - CoinTypeNames = map[Type]string{ - Coin1Type: "Poor George", - Coin2Type: "Frozen Purse", - Coin3Type: "Arctic Assistant", - Coin4Type: "IceCube Swagger", - Coin5Type: "Polar Consultant", - Coin6Type: "Igloo Broker", - Coin7Type: "Snowy Accountant", - Coin8Type: "Winter Banker", - Coin9Type: "Cold Director", - Coin10Type: "Richie Rich", - } - //nolint:gochecknoglobals // . - SocialTypeNames = map[Type]string{ - Social1Type: "Ice Breaker", - Social2Type: "Trouble Maker", - Social3Type: "Snowy Plower", - Social4Type: "Arctic Prankster", - Social5Type: "Glacial Polly", - Social6Type: "Frosty Smacker", - Social7Type: "Polar Machine", - Social8Type: "North Storm", - Social9Type: "Snow Fall", - Social10Type: "Ice Legend", - } - //nolint:gochecknoglobals // . - GroupTypeForEachType = map[Type]GroupType{ - Level1Type: LevelGroupType, - Level2Type: LevelGroupType, - Level3Type: LevelGroupType, - Level4Type: LevelGroupType, - Level5Type: LevelGroupType, - Level6Type: LevelGroupType, - Coin1Type: CoinGroupType, - Coin2Type: CoinGroupType, - Coin3Type: CoinGroupType, - Coin4Type: CoinGroupType, - Coin5Type: CoinGroupType, - Coin6Type: CoinGroupType, - Coin7Type: CoinGroupType, - Coin8Type: CoinGroupType, - Coin9Type: CoinGroupType, - Coin10Type: CoinGroupType, - Social1Type: SocialGroupType, - Social2Type: SocialGroupType, - Social3Type: SocialGroupType, - Social4Type: SocialGroupType, - Social5Type: SocialGroupType, - Social6Type: SocialGroupType, - Social7Type: SocialGroupType, - Social8Type: SocialGroupType, - Social9Type: SocialGroupType, - Social10Type: SocialGroupType, - } - //nolint:gochecknoglobals // . - AllNames = map[GroupType]map[Type]string{ - LevelGroupType: LevelTypeNames, - CoinGroupType: CoinTypeNames, - SocialGroupType: SocialTypeNames, - } - //nolint:gochecknoglobals // . - AllGroups = map[GroupType][]Type{ - LevelGroupType: append(make([]Type, 0, len(LevelTypeOrder)), Level1Type, Level2Type, Level3Type, Level4Type, Level5Type, Level6Type), //nolint:lll // . - CoinGroupType: append(make([]Type, 0, len(CoinTypeOrder)), Coin1Type, Coin2Type, Coin3Type, Coin4Type, Coin5Type, Coin6Type, Coin7Type, Coin8Type, Coin9Type, Coin10Type), //nolint:lll // . - SocialGroupType: append(make([]Type, 0, len(SocialTypeOrder)), Social1Type, Social2Type, Social3Type, Social4Type, Social5Type, Social6Type, Social7Type, Social8Type, Social9Type, Social10Type), //nolint:lll // . - } - //nolint:gochecknoglobals // . + AllTypes []Type + LevelTypeOrder map[Type]int + CoinTypeOrder map[Type]int + SocialTypeOrder map[Type]int + AllTypeOrder map[Type]int + LevelTypeNames map[Type]string + CoinTypeNames map[Type]string + SocialTypeNames map[Type]string + GroupTypeForEachType map[Type]GroupType + AllNames map[GroupType]map[Type]string + AllGroups map[GroupType][]Type GroupsOrderSummaries = [3]GroupType{ SocialGroupType, CoinGroupType, LevelGroupType, } + Milestones map[Type]AchievingRange ) type ( Type string GroupType string AchievingRange struct { + Name string `json:"-"` FromInclusive uint64 `json:"fromInclusive,omitempty"` ToInclusive uint64 `json:"toInclusive,omitempty"` } @@ -244,9 +59,9 @@ type ( Name string `json:"name"` Type Type `json:"-"` GroupType GroupType `json:"type"` //nolint:tagliatelle // Intended. + AchievingRange AchievingRange `json:"achievingRange"` PercentageOfUsersInProgress float64 `json:"percentageOfUsersInProgress"` Achieved bool `json:"achieved"` - AchievingRange AchievingRange `json:"achievingRange"` } BadgeSummary struct { Name string `json:"name"` @@ -339,7 +154,9 @@ type ( *repository } config struct { - Milestones map[Type]AchievingRange `yaml:"milestones"` + Levels []*AchievingRange `yaml:"levels"` + Coins []*AchievingRange `yaml:"coins"` + Socials []*AchievingRange `yaml:"socials"` messagebroker.Config `mapstructure:",squash"` //nolint:tagliatelle // Nope. } ) diff --git a/badges/fixture/fixture.go b/badges/fixture/fixture.go index a6d421f..a1e16fd 100644 --- a/badges/fixture/fixture.go +++ b/badges/fixture/fixture.go @@ -5,7 +5,7 @@ package fixture import ( "testing" - "github.com/testcontainers/testcontainers-go" + testcontainers "github.com/testcontainers/testcontainers-go" connectorsfixture "github.com/ice-blockchain/wintr/connectors/fixture" messagebrokerfixture "github.com/ice-blockchain/wintr/connectors/message_broker/fixture" diff --git a/badges/get_badges.go b/badges/get_badges.go index cc2024c..4368271 100644 --- a/badges/get_badges.go +++ b/badges/get_badges.go @@ -28,7 +28,7 @@ func (r *repository) GetBadges(ctx context.Context, groupType GroupType, userID return nil, ErrHidden } - return userProgress.buildBadges(r, groupType, stats), nil + return userProgress.buildBadges(groupType, stats), nil } func (r *repository) GetSummary(ctx context.Context, userID string) ([]*BadgeSummary, error) { @@ -128,11 +128,11 @@ func (*repository) calculateUnachievedPercentages(groupType GroupType, res []*st return resp } -func (p *progress) buildBadges(repo *repository, groupType GroupType, stats map[Type]float64) []*Badge { +func (p *progress) buildBadges(groupType GroupType, stats map[Type]float64) []*Badge { resp := make([]*Badge, 0, len(AllGroups[groupType])) for _, badgeType := range AllGroups[groupType] { resp = append(resp, &Badge{ - AchievingRange: repo.cfg.Milestones[badgeType], + AchievingRange: Milestones[badgeType], Name: AllNames[groupType][badgeType], Type: badgeType, GroupType: groupType, diff --git a/badges/get_badges_test.go b/badges/get_badges_test.go index 5062095..0edce16 100644 --- a/badges/get_badges_test.go +++ b/badges/get_badges_test.go @@ -74,9 +74,9 @@ func unachivedPercentageTestCase() *calculateUnachievedPercentagesTestCase { return &calculateUnachievedPercentagesTestCase{} } -//nolint:funlen // A lot of testcases here +//nolint:funlen,paralleltest,tparallel // A lot of testcases here. Not need to be parallel due to loads the global variables. func Test_Repository_calculateUnachievedPercentages(t *testing.T) { - t.Parallel() + loadBadges(defaultCfg()) tests := []*calculateUnachievedPercentagesTestCase{ unachivedPercentageTestCase(). WithDesc("All users have first 2 badges, and no one have last"). @@ -262,10 +262,10 @@ func Test_Repository_calculateUnachievedPercentages(t *testing.T) { } } -//nolint:funlen // A lot of testcases +//nolint:funlen,paralleltest,tparallel // A lot of testcases. Not needed to be the parallel due to loads the global variables. func Test_Progress_BuildBadges(t *testing.T) { - t.Parallel() repo := &repository{cfg: defaultCfg()} + loadBadges(repo.cfg) tests := []*struct { progress *progress stats map[Type]float64 @@ -279,12 +279,12 @@ func Test_Progress_BuildBadges(t *testing.T) { group: LevelGroupType, stats: map[Type]float64{}, expected: []*Badge{ - expectedBadge(repo, Level1Type, false, 0), - expectedBadge(repo, Level2Type, false, 0), - expectedBadge(repo, Level3Type, false, 0), - expectedBadge(repo, Level4Type, false, 0), - expectedBadge(repo, Level5Type, false, 0), - expectedBadge(repo, Level6Type, false, 0), + expectedBadge(Level1Type, false, 0), + expectedBadge(Level2Type, false, 0), + expectedBadge(Level3Type, false, 0), + expectedBadge(Level4Type, false, 0), + expectedBadge(Level5Type, false, 0), + expectedBadge(Level6Type, false, 0), }, }, { @@ -299,12 +299,12 @@ func Test_Progress_BuildBadges(t *testing.T) { Level3Type: 20.0, }, expected: []*Badge{ - expectedBadge(repo, Level1Type, true, 50.0), - expectedBadge(repo, Level2Type, true, 30.0), - expectedBadge(repo, Level3Type, true, 20.0), - expectedBadge(repo, Level4Type, false, 0), - expectedBadge(repo, Level5Type, false, 0), - expectedBadge(repo, Level6Type, false, 0), + expectedBadge(Level1Type, true, 50.0), + expectedBadge(Level2Type, true, 30.0), + expectedBadge(Level3Type, true, 20.0), + expectedBadge(Level4Type, false, 0), + expectedBadge(Level5Type, false, 0), + expectedBadge(Level6Type, false, 0), }, }, { @@ -327,16 +327,16 @@ func Test_Progress_BuildBadges(t *testing.T) { Coin10Type: 10, }, expected: []*Badge{ - expectedBadge(repo, Coin1Type, true, 10), - expectedBadge(repo, Coin2Type, true, 10), - expectedBadge(repo, Coin3Type, true, 10), - expectedBadge(repo, Coin4Type, true, 10), - expectedBadge(repo, Coin5Type, true, 10), - expectedBadge(repo, Coin6Type, true, 10), - expectedBadge(repo, Coin7Type, true, 10), - expectedBadge(repo, Coin8Type, true, 10), - expectedBadge(repo, Coin9Type, true, 10), - expectedBadge(repo, Coin10Type, true, 10), + expectedBadge(Coin1Type, true, 10), + expectedBadge(Coin2Type, true, 10), + expectedBadge(Coin3Type, true, 10), + expectedBadge(Coin4Type, true, 10), + expectedBadge(Coin5Type, true, 10), + expectedBadge(Coin6Type, true, 10), + expectedBadge(Coin7Type, true, 10), + expectedBadge(Coin8Type, true, 10), + expectedBadge(Coin9Type, true, 10), + expectedBadge(Coin10Type, true, 10), }, }, { @@ -345,16 +345,16 @@ func Test_Progress_BuildBadges(t *testing.T) { group: CoinGroupType, stats: map[Type]float64{}, expected: []*Badge{ - expectedBadge(repo, Coin1Type, true, 0), - expectedBadge(repo, Coin2Type, false, 0), - expectedBadge(repo, Coin3Type, false, 0), - expectedBadge(repo, Coin4Type, false, 0), - expectedBadge(repo, Coin5Type, false, 0), - expectedBadge(repo, Coin6Type, false, 0), - expectedBadge(repo, Coin7Type, false, 0), - expectedBadge(repo, Coin8Type, false, 0), - expectedBadge(repo, Coin9Type, false, 0), - expectedBadge(repo, Coin10Type, false, 0), + expectedBadge(Coin1Type, true, 0), + expectedBadge(Coin2Type, false, 0), + expectedBadge(Coin3Type, false, 0), + expectedBadge(Coin4Type, false, 0), + expectedBadge(Coin5Type, false, 0), + expectedBadge(Coin6Type, false, 0), + expectedBadge(Coin7Type, false, 0), + expectedBadge(Coin8Type, false, 0), + expectedBadge(Coin9Type, false, 0), + expectedBadge(Coin10Type, false, 0), }, }, { @@ -366,31 +366,31 @@ func Test_Progress_BuildBadges(t *testing.T) { Social2Type: 50, }, expected: []*Badge{ - expectedBadge(repo, Social1Type, false, 50), - expectedBadge(repo, Social2Type, false, 50), - expectedBadge(repo, Social3Type, false, 0), - expectedBadge(repo, Social4Type, false, 0), - expectedBadge(repo, Social5Type, false, 0), - expectedBadge(repo, Social6Type, false, 0), - expectedBadge(repo, Social7Type, false, 0), - expectedBadge(repo, Social8Type, false, 0), - expectedBadge(repo, Social9Type, false, 0), - expectedBadge(repo, Social10Type, false, 0), + expectedBadge(Social1Type, false, 50), + expectedBadge(Social2Type, false, 50), + expectedBadge(Social3Type, false, 0), + expectedBadge(Social4Type, false, 0), + expectedBadge(Social5Type, false, 0), + expectedBadge(Social6Type, false, 0), + expectedBadge(Social7Type, false, 0), + expectedBadge(Social8Type, false, 0), + expectedBadge(Social9Type, false, 0), + expectedBadge(Social10Type, false, 0), }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Parallel() - actual := tt.progress.buildBadges(repo, tt.group, tt.stats) + actual := tt.progress.buildBadges(tt.group, tt.stats) assert.Equal(t, tt.expected, actual, tt.name) }) } } -//nolint:funlen // A lot of testcases. +//nolint:funlen,paralleltest,tparallel // A lot of testcases. Not needed to be parallel due to load the global variables. func Test_Progress_BuildSummary(t *testing.T) { - t.Parallel() + loadBadges(defaultCfg()) tests := []*struct { name string progress *progress @@ -493,7 +493,7 @@ func expectedForRandomAchievedUsers(group GroupType, userCounts ...int) map[Type func randomAchievedUsers(count int) []int { achievedUserCounts := make([]int, count) //nolint:makezero // We're know size for sure. - for i := 0; i < count; i++ { //nolint:intrange // . + for i := range count { achievedUserCounts[i] = rand.Intn(totalUsers) //nolint:gosec // We dont need strong random for tests. if i > 0 && achievedUserCounts[i] > achievedUserCounts[i-1] { achievedUserCounts[i] = randomAchievedUsers(1)[0] @@ -504,7 +504,7 @@ func randomAchievedUsers(count int) []int { return achievedUserCounts } -func expectedBadge(repo *repository, badgeType Type, achieved bool, percent float64) *Badge { +func expectedBadge(badgeType Type, achieved bool, percent float64) *Badge { return &Badge{ Name: AllNames[GroupTypeForEachType[badgeType]][badgeType], Type: badgeType, @@ -512,8 +512,9 @@ func expectedBadge(repo *repository, badgeType Type, achieved bool, percent floa PercentageOfUsersInProgress: percent, Achieved: achieved, AchievingRange: AchievingRange{ - repo.cfg.Milestones[badgeType].FromInclusive, - repo.cfg.Milestones[badgeType].ToInclusive, + Name: AllNames[GroupTypeForEachType[badgeType]][badgeType], + FromInclusive: Milestones[badgeType].FromInclusive, + ToInclusive: Milestones[badgeType].ToInclusive, }, } } diff --git a/cmd/scripts/update_santa_badges_levels_and_roles_tasks/update_santa_badges_levels_and_roles_tasks.go b/cmd/scripts/update_santa_badges_levels_and_roles_tasks/update_santa_badges_levels_and_roles_tasks.go index 2a736d5..4a215d2 100644 --- a/cmd/scripts/update_santa_badges_levels_and_roles_tasks/update_santa_badges_levels_and_roles_tasks.go +++ b/cmd/scripts/update_santa_badges_levels_and_roles_tasks/update_santa_badges_levels_and_roles_tasks.go @@ -263,7 +263,7 @@ func diffBadgeStatistics(usr *commonUser, newBadgesTypeCount map[badges.Type]int } } if newBadgesTypeCount != nil { - for _, key := range &badges.AllTypes { + for _, key := range badges.AllTypes { if _, ok1 := oldBadgesTypeCounts[key]; ok1 { if _, ok2 := newBadgesTypeCount[key]; ok2 { newBadgesTypeCount[key] -= oldBadgesTypeCounts[key] @@ -340,7 +340,7 @@ func reEvaluateEnabledBadges( alreadyAchievedBadges *users.Enum[badges.Type], friendsInvited uint64, balance int64, ) (achievedBadges users.Enum[badges.Type], badgesTypeCounts map[badges.Type]int64) { badgesTypeCounts = make(map[badges.Type]int64) - achievedBadges = make(users.Enum[badges.Type], 0, len(&badges.AllTypes)) + achievedBadges = make(users.Enum[badges.Type], 0, len(badges.AllTypes)) if alreadyAchievedBadges != nil { for _, badge := range *alreadyAchievedBadges { if strings.HasPrefix(string(badge), "l") { @@ -348,7 +348,7 @@ func reEvaluateEnabledBadges( } } } - for _, badgeType := range &badges.AllTypes { + for _, badgeType := range badges.AllTypes { var achieved bool switch badges.GroupTypeForEachType[badgeType] { //nolint:exhaustive // We need to handle only 2 cases. case badges.CoinGroupType: diff --git a/friends-invited/friends-invited.go b/friends-invited/friends-invited.go index 5f70349..90dd910 100644 --- a/friends-invited/friends-invited.go +++ b/friends-invited/friends-invited.go @@ -83,7 +83,7 @@ func (p *processor) CheckHealth(ctx context.Context) error { } func (p *processor) startProcessedReferralsCleaner(ctx context.Context) { - ticker := stdlibtime.NewTicker(stdlibtime.Duration(1+rand.Intn(24)) * stdlibtime.Minute) //nolint:gosec,mnd,gomnd // Not an issue. + ticker := stdlibtime.NewTicker(stdlibtime.Duration(1+rand.Intn(24)) * stdlibtime.Minute) //nolint:gosec // Not an issue. defer ticker.Stop() for { diff --git a/go.mod b/go.mod index d3ab3cf..a470443 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,14 @@ module github.com/ice-blockchain/santa go 1.22 require ( - github.com/goccy/go-json v0.10.2 + github.com/goccy/go-json v0.10.3 github.com/hashicorp/go-multierror v1.1.1 - github.com/ice-blockchain/eskimo v1.300.0 + github.com/ice-blockchain/eskimo v1.304.0 github.com/ice-blockchain/wintr v1.135.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 - github.com/testcontainers/testcontainers-go v0.27.0 + github.com/testcontainers/testcontainers-go v0.31.0 ) require ( @@ -30,20 +30,20 @@ require ( github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/hcsshim v0.12.3 // indirect github.com/andybalholm/brotli v1.1.0 // indirect - github.com/bytedance/sonic v1.11.6 // indirect + github.com/bytedance/sonic v1.11.7 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cloudflare/circl v1.3.8 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect github.com/containerd/cgroups/v3 v3.0.3 // indirect - github.com/containerd/containerd v1.7.13 // indirect + github.com/containerd/containerd v1.7.17 // indirect github.com/containerd/continuity v0.4.3 // indirect github.com/containerd/errdefs v0.1.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/distribution/reference v0.6.0 // indirect github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/docker/docker v25.0.3+incompatible // indirect + github.com/docker/docker v26.1.3+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -52,7 +52,7 @@ require ( github.com/georgysavva/scany/v2 v2.1.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-gonic/gin v1.10.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonreference v0.21.0 // indirect @@ -68,7 +68,7 @@ require ( github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 // indirect + github.com/google/pprof v0.0.0-20240521024322-9665fa269a30 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect @@ -100,7 +100,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect - github.com/onsi/ginkgo/v2 v2.17.3 // indirect + github.com/onsi/ginkgo/v2 v2.18.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/opencontainers/runc v1.1.12 // indirect @@ -110,7 +110,7 @@ require ( github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/quic-go v0.44.0 // indirect github.com/refraction-networking/utls v1.6.6 // indirect - github.com/rs/zerolog v1.32.0 // indirect + github.com/rs/zerolog v1.33.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect @@ -130,11 +130,11 @@ require ( github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect - go.opentelemetry.io/otel v1.26.0 // indirect - go.opentelemetry.io/otel/metric v1.26.0 // indirect - go.opentelemetry.io/otel/trace v1.26.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect + go.opentelemetry.io/otel v1.27.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect + go.opentelemetry.io/otel/trace v1.27.0 // indirect go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.8.0 // indirect @@ -150,9 +150,9 @@ require ( golang.org/x/tools v0.21.0 // indirect google.golang.org/api v0.181.0 // indirect google.golang.org/appengine/v2 v2.0.6 // indirect - google.golang.org/genproto v0.0.0-20240520151616-dc85e6b867a5 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 // indirect + google.golang.org/genproto v0.0.0-20240521202816-d264139d666e // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect google.golang.org/grpc v1.64.0 // indirect google.golang.org/protobuf v1.34.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 7a1cdf0..d110fc0 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/Microsoft/hcsshim v0.12.3 h1:LS9NXqXhMoqNCplK1ApmVSfB4UnVLRDWRapB6EIl github.com/Microsoft/hcsshim v0.12.3/go.mod h1:Iyl1WVpZzr+UkzjekHZbV8o5Z9ZkxNGx6CtY2Qg/JVQ= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= -github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= -github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic v1.11.7 h1:k/l9p1hZpNIMJSk37wL9ltkcpqLfIho1vYthi4xT2t4= +github.com/bytedance/sonic v1.11.7/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= @@ -99,8 +99,8 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= @@ -125,8 +125,8 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/goccy/go-reflect v1.2.0 h1:O0T8rZCuNmGXewnATuKYnkL0xm6o8UNOJZd/gOkb9ms= github.com/goccy/go-reflect v1.2.0/go.mod h1:n0oYZn8VcV2CkWTxi8B9QjkCoq6GTtCEdfmR66YhFtE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -168,8 +168,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= -github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 h1:velgFPYr1X9TDwLIfkV7fWqsFlf7TeP11M/7kPd/dVI= -github.com/google/pprof v0.0.0-20240509144519-723abb6459b7/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= +github.com/google/pprof v0.0.0-20240521024322-9665fa269a30 h1:r6YdmbD41tGHeCWDyHF691LWtL7D1iSTyJaKejTWwVU= +github.com/google/pprof v0.0.0-20240521024322-9665fa269a30/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -188,8 +188,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/ice-blockchain/eskimo v1.300.0 h1:AsQIrae/Ls387Agicgj8y12VG3ed0gcyIDAdAZT0qJw= -github.com/ice-blockchain/eskimo v1.300.0/go.mod h1:aYaLBiJ4htVy/gZKJ+LT8At25aQDlHfSleQSPssgVtQ= +github.com/ice-blockchain/eskimo v1.304.0 h1:Tv96cG2b5HoTyNvYHLeRSCNGRqNGXQ1kgTaSrowbkO0= +github.com/ice-blockchain/eskimo v1.304.0/go.mod h1:SXqdB0XuoYfdpZshyKSk2d41H1/RX3tbfELZSvMmh2k= github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb h1:8TnFP3mc7O+tc44kv2e0/TpZKnEVUaKH+UstwfBwRkk= github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb/go.mod h1:ZsQU7i3mxhgBBu43Oev7WPFbIjP4TniN/b1UPNGbrq8= github.com/ice-blockchain/wintr v1.135.0 h1:jT+Jh6SAkYpYrrQrSLHh4nEGVwNYzosd5KjDZBE/25Q= @@ -254,10 +254,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= -github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU= -github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= -github.com/onsi/gomega v1.33.0 h1:snPCflnZrpMsy94p4lXVEkHo12lmPnc3vY5XBbreexE= -github.com/onsi/gomega v1.33.0/go.mod h1:+925n5YtiFsLzzafLUHzVMBpvvRAzrydIBiSIxjX3wY= +github.com/onsi/ginkgo/v2 v2.18.0 h1:W9Y7IWXxPUpAit9ieMOLI7PJZGaW22DTKgiVAuhDTLc= +github.com/onsi/ginkgo/v2 v2.18.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -283,8 +283,8 @@ github.com/refraction-networking/utls v1.6.6/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5D github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= @@ -345,18 +345,18 @@ github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 h1:A3SayB3rNyt+1S6qpI9mHPkeHTZbD7XILEqWnYZb2l0= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0/go.mod h1:27iA5uvhuRNmalO+iEUdVn5ZMj2qy10Mm+XRIpRmyuU= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= -go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= -go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= -go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= -go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 h1:vS1Ao/R55RNV4O7TA2Qopok8yN+X0LIP6RVWLFkprck= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0/go.mod h1:BMsdeOxN04K0L5FNUBfjFdvwWGNe/rkmSwH4Aelu/X0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 h1:9l89oX4ba9kHbBol3Xin3leYJ+252h0zszDtBwyKe2A= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0/go.mod h1:XLZfZboOJWHNKUv7eH0inh0E9VV6eWDFB/9yJyTLPp0= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= -go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -460,12 +460,12 @@ google.golang.org/appengine/v2 v2.0.6/go.mod h1:WoEXGoXNfa0mLvaH5sV3ZSGXwVmy8yf7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20240520151616-dc85e6b867a5 h1:IGsMFz879l+GhhDJ9fN5rWnkVrGnoZv8oeYfpk82QZQ= -google.golang.org/genproto v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:ch5ZrEj5+9MCxUeR3Gp3mCJ4u0eVpusYAmSr/mvpMSk= -google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 h1:P8OJ/WCl/Xo4E4zoe4/bifHpSmmKwARqyqE4nW6J2GQ= -google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:RGnPtTG7r4i8sPlNyDeikXF99hMM+hN6QMm4ooG9g2g= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 h1:Q2RxlXqh1cgzzUgV261vBO2jI5R/3DD1J2pM0nI4NhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto v0.0.0-20240521202816-d264139d666e h1:axIBUGXSVho2zB+3tJj8l9Qvm/El5vVYPYqhGA5PmJM= +google.golang.org/genproto v0.0.0-20240521202816-d264139d666e/go.mod h1:gOvX/2dWTqh+u3+IHjFeCxinlz5AZ5qhOufbQPub/dE= +google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e h1:SkdGTrROJl2jRGT/Fxv5QUf9jtdKCQh4KQJXbXVLAi0= +google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e/go.mod h1:LweJcLbyVij6rCex8YunD8DYR5VDonap/jYl3ZRxcIU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e h1:Elxv5MwEkCI9f5SkoL6afed6NTdxaGoAo39eANBwHL8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/levels-and-roles/fixture/fixture.go b/levels-and-roles/fixture/fixture.go index a6d421f..a1e16fd 100644 --- a/levels-and-roles/fixture/fixture.go +++ b/levels-and-roles/fixture/fixture.go @@ -5,7 +5,7 @@ package fixture import ( "testing" - "github.com/testcontainers/testcontainers-go" + testcontainers "github.com/testcontainers/testcontainers-go" connectorsfixture "github.com/ice-blockchain/wintr/connectors/fixture" messagebrokerfixture "github.com/ice-blockchain/wintr/connectors/message_broker/fixture" diff --git a/levels-and-roles/levels_and_roles.go b/levels-and-roles/levels_and_roles.go index 211a933..2fdd36c 100644 --- a/levels-and-roles/levels_and_roles.go +++ b/levels-and-roles/levels_and_roles.go @@ -162,7 +162,7 @@ func requestingUserID(ctx context.Context) (requestingUserID string) { } func (p *processor) startProcessedPingsCleaner(ctx context.Context) { - ticker := stdlibtime.NewTicker(stdlibtime.Duration(1+rand.Intn(24)) * stdlibtime.Minute) //nolint:gosec,mnd,gomnd // Not an issue. + ticker := stdlibtime.NewTicker(stdlibtime.Duration(1+rand.Intn(24)) * stdlibtime.Minute) //nolint:gosec // Not an issue. defer ticker.Stop() for { diff --git a/tasks/contract.go b/tasks/contract.go index 6cc2da9..882f720 100644 --- a/tasks/contract.go +++ b/tasks/contract.go @@ -37,7 +37,7 @@ var ( JoinTelegramType, InviteFriendsType, } - //nolint:gochecknoglobals,mnd,gomnd // It's just for more descriptive validation messages. + //nolint:gochecknoglobals // It's just for more descriptive validation messages. TypeOrder = map[Type]int{ ClaimUsernameType: 0, StartMiningType: 1, diff --git a/tasks/fixture/fixture.go b/tasks/fixture/fixture.go index a6d421f..a1e16fd 100644 --- a/tasks/fixture/fixture.go +++ b/tasks/fixture/fixture.go @@ -5,7 +5,7 @@ package fixture import ( "testing" - "github.com/testcontainers/testcontainers-go" + testcontainers "github.com/testcontainers/testcontainers-go" connectorsfixture "github.com/ice-blockchain/wintr/connectors/fixture" messagebrokerfixture "github.com/ice-blockchain/wintr/connectors/message_broker/fixture"