Skip to content

Add INNER_VOICE clan task and balanced daily-task generation - #981

Merged
tickBit merged 6 commits into
devfrom
967-feature-implement-INNER-VOCE-daily-task
Sep 13, 2026
Merged

tickBit merged 6 commits into
devfrom
967-feature-implement-INNER-VOCE-daily-task

Conversation

@EemeliJ

@EemeliJ EemeliJ commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Brief description

(closes #967 & #974 )

Adds the clan-level INNER_VOICE daily task and replaces random initial server-task generation with a balanced shuffled task bag. Updating a clan’s phrase to a new value completes INNER_VOICE, rewards the clan, and publishes a clan MQTT update after the database transaction commits.

Change list

  • Add INNER_VOICE to the active server daily-task registry.
  • Generate 11 server tasks per clan with every active type appearing at least twice.
  • Use the shared balanced generator for new clans and startup refresh.
  • Validate that the configured task-slot count can satisfy the minimum-occurrence rule.
  • Progress INNER_VOICE when an authorized player saves a genuinely changed clan phrase.
  • Make phrase save, task completion, and clan rewards transactional.
  • Prevent individual player rewards for clan-level INNER_VOICE completion.
  • Publish CLAN_UPDATED MQTT notifications with { clan_id, phrase } after commit.
  • Add tests for balanced generation, phrase-triggered completion, no-op phrase updates, transaction rollback, clan rewards, and MQTT payloads.

…complete INNER_VOICE when clan phrase changes
@codecov-alt

codecov-alt Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.98198% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/dailyTasks/dailyTasks.service.ts 62.06% 11 Missing ⚠️
src/dailyTasks/dailyTaskProgress.service.ts 75.00% 5 Missing ⚠️
...ervice/EventEmitterService/EventEmitter.service.ts 0.00% 2 Missing ⚠️
src/dailyTasks/taskGenerator.service.ts 95.23% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/box/sessionStarter/sessionStarter.service.ts 93.06% <ø> (ø)
src/clan/clan.notifier.ts 100.00% <100.00%> (ø)
src/clan/clan.service.ts 87.75% <100.00%> (ø)
src/common/service/basicService/BasicService.ts 82.14% <100.00%> (+0.24%) ⬆️
src/dailyTasks/dailyTask.queue.ts 51.72% <ø> (ø)
src/dailyTasks/dailyTasksStartupRefresh.service.ts 96.66% <100.00%> (-0.81%) ⬇️
src/rewarder/clanRewarder/clanRewarder.service.ts 100.00% <100.00%> (ø)
...ervice/EventEmitterService/EventEmitter.service.ts 60.00% <0.00%> (-15.00%) ⬇️
src/dailyTasks/taskGenerator.service.ts 96.00% <95.23%> (+3.40%) ⬆️
src/dailyTasks/dailyTaskProgress.service.ts 91.66% <75.00%> (-8.34%) ⬇️
... and 1 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tickBit tickBit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 👍 ! Approved.

I looked carefully and to get context looked also other files and noticed a bug outside this PR. In dailyTask.queue.ts at line 56 there is field playerId, it should be player_id to clear the ID:

$unset: {
  player_id: '',     // Correct, but at the moment there is playerId
  startedAt: '',
}

Just wondering, that could you also change that field name in dailyTask.queue.ts in this PR? It's one field in one line only.

The branch was out of date, I updated it from the UI, so refreshing the branch locally is necessary. I'll wait until Monday morning before merging. That other fix isn't required. It can be fixed in other PR, too.

@github-project-automation github-project-automation Bot moved this from Backlog to Done in Altzone-Server Sep 12, 2026
@EemeliJ

EemeliJ commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Great work 👍 ! Approved.

I looked carefully and to get context looked also other files and noticed a bug outside this PR. In dailyTask.queue.ts at line 56 there is field playerId, it should be player_id to clear the ID:

$unset: {
  player_id: '',     // Correct, but at the moment there is playerId
  startedAt: '',
}

Just wondering, that could you also change that field name in dailyTask.queue.ts in this PR? It's one field in one line only.

The branch was out of date, I updated it from the UI, so refreshing the branch locally is necessary. I'll wait until Monday morning before merging. That other fix isn't required. It can be fixed in other PR, too.

I fixed this naming mismatch, but i also spotted another similar one at dailyTasks.schema.ts at line 54: DailyTaskSchema.index({ playerId: 1 }, { unique: true, sparse: true }); Should i apply the same fix to this one too? @tickBit

@tickBit

tickBit commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Great work 👍 ! Approved.
I looked carefully and to get context looked also other files and noticed a bug outside this PR. In dailyTask.queue.ts at line 56 there is field playerId, it should be player_id to clear the ID:

$unset: {
  player_id: '',     // Correct, but at the moment there is playerId
  startedAt: '',
}

Just wondering, that could you also change that field name in dailyTask.queue.ts in this PR? It's one field in one line only.
The branch was out of date, I updated it from the UI, so refreshing the branch locally is necessary. I'll wait until Monday morning before merging. That other fix isn't required. It can be fixed in other PR, too.

I fixed this naming mismatch, but i also spotted another similar one at dailyTasks.schema.ts at line 54: DailyTaskSchema.index({ playerId: 1 }, { unique: true, sparse: true }); Should i apply the same fix to this one too? @tickBit

Good observation! I missed that. Yes, I think, that it should be DailyTaskSchema.index({ player_id: 1 }, { unique: true, sparse: true });. I looked, that GET /dailyTasks shows the field as player_id.

@tickBit

tickBit commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Nice! Now all all tests are green 👍 .

I'll merge this now.

@EemeliJ

EemeliJ commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Failing daily-task CI tests?

Root cause: clan and unreserved tasks use player_id: null. The previous unique sparse index still indexed null, so MongoDB allowed only one such task and rejected subsequent task creation as a duplicate key.
The index is now a partial unique index: uniqueness applies only when a task is reserved by an actual player (player_id is an ObjectId). Clan/unreserved tasks can now coexist normally.

NOTE: A one-time production database maintenance step is required after deployment. The database currently has an old daily-task rule that treats every clan/unreserved task as the same because they have no player ID. A database admin must replace that rule with the new one, which allows multiple clan/unreserved tasks while still allowing each player to reserve only one task at a time.

@tickBit
tickBit merged commit afcd7f6 into dev Sep 13, 2026
5 checks passed
@tickBit
tickBit deleted the 967-feature-implement-INNER-VOCE-daily-task branch September 13, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

2 participants