feat(profiles): add aim trainer statistics schema
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
73d689a680
commit
a6a7a5639d
4 changed files with 118 additions and 0 deletions
|
|
@ -122,6 +122,7 @@ export const Profiles: CollectionConfig = {
|
||||||
flappyBird?: { xpEarned?: number | null };
|
flappyBird?: { xpEarned?: number | null };
|
||||||
eodMinesweeper?: { xpEarned?: number | null };
|
eodMinesweeper?: { xpEarned?: number | null };
|
||||||
radioTraffic?: { xpEarned?: number | null };
|
radioTraffic?: { xpEarned?: number | null };
|
||||||
|
aimTrainer?: { xpEarned?: number | null };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const awardsList = progressionData?.awards || [];
|
const awardsList = progressionData?.awards || [];
|
||||||
|
|
@ -135,6 +136,7 @@ export const Profiles: CollectionConfig = {
|
||||||
const flappyXp = progressionData?.minigames?.flappyBird?.xpEarned ?? 0;
|
const flappyXp = progressionData?.minigames?.flappyBird?.xpEarned ?? 0;
|
||||||
const eodXp = progressionData?.minigames?.eodMinesweeper?.xpEarned ?? 0;
|
const eodXp = progressionData?.minigames?.eodMinesweeper?.xpEarned ?? 0;
|
||||||
const radioTrafficXp = progressionData?.minigames?.radioTraffic?.xpEarned ?? 0;
|
const radioTrafficXp = progressionData?.minigames?.radioTraffic?.xpEarned ?? 0;
|
||||||
|
const aimTrainerXp = progressionData?.minigames?.aimTrainer?.xpEarned ?? 0;
|
||||||
|
|
||||||
if (awardIds.length > 0) {
|
if (awardIds.length > 0) {
|
||||||
await req.payload
|
await req.payload
|
||||||
|
|
@ -175,6 +177,7 @@ export const Profiles: CollectionConfig = {
|
||||||
// EOD Minesweeper: XP from cleared minefields
|
// EOD Minesweeper: XP from cleared minefields
|
||||||
xpAcc += eodXp;
|
xpAcc += eodXp;
|
||||||
xpAcc += radioTrafficXp;
|
xpAcc += radioTrafficXp;
|
||||||
|
xpAcc += aimTrainerXp;
|
||||||
|
|
||||||
return xpAcc;
|
return xpAcc;
|
||||||
},
|
},
|
||||||
|
|
@ -482,6 +485,66 @@ export const Profiles: CollectionConfig = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "aimTrainer",
|
||||||
|
label: "Aim Trainer",
|
||||||
|
type: "group",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "gamesPlayed",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bestScore",
|
||||||
|
label: "Best Score",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "recruitBestScore",
|
||||||
|
label: "Recruit Best Score",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "veteranBestScore",
|
||||||
|
label: "Veteran Best Score",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eliteBestScore",
|
||||||
|
label: "Elite Best Score",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "recruitBestAccuracy",
|
||||||
|
label: "Recruit Best Accuracy",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "veteranBestAccuracy",
|
||||||
|
label: "Veteran Best Accuracy",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eliteBestAccuracy",
|
||||||
|
label: "Elite Best Accuracy",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "xpEarned",
|
||||||
|
label: "XP Earned",
|
||||||
|
type: "number",
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
25
src/migrations/20260903_062000_add_aim_trainer_stats.ts
Normal file
25
src/migrations/20260903_062000_add_aim_trainer_stats.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { MigrateDownArgs, MigrateUpArgs, sql } from '@payloadcms/db-postgres'
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
'progression_minigames_aim_trainer_games_played',
|
||||||
|
'progression_minigames_aim_trainer_best_score',
|
||||||
|
'progression_minigames_aim_trainer_recruit_best_score',
|
||||||
|
'progression_minigames_aim_trainer_veteran_best_score',
|
||||||
|
'progression_minigames_aim_trainer_elite_best_score',
|
||||||
|
'progression_minigames_aim_trainer_recruit_best_accuracy',
|
||||||
|
'progression_minigames_aim_trainer_veteran_best_accuracy',
|
||||||
|
'progression_minigames_aim_trainer_elite_best_accuracy',
|
||||||
|
'progression_minigames_aim_trainer_xp_earned',
|
||||||
|
] as const
|
||||||
|
|
||||||
|
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
||||||
|
for (const column of columns) {
|
||||||
|
await db.execute(sql.raw(`ALTER TABLE "profiles" ADD COLUMN "${column}" numeric DEFAULT 0;`))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
||||||
|
for (const column of [...columns].reverse()) {
|
||||||
|
await db.execute(sql.raw(`ALTER TABLE "profiles" DROP COLUMN "${column}";`))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,7 @@ import * as migration_20260903_044047 from './20260903_044047';
|
||||||
import * as migration_20260903_053419 from './20260903_053419';
|
import * as migration_20260903_053419 from './20260903_053419';
|
||||||
import * as migration_20260903_060000_add_radio_mode_stats from './20260903_060000_add_radio_mode_stats';
|
import * as migration_20260903_060000_add_radio_mode_stats from './20260903_060000_add_radio_mode_stats';
|
||||||
import * as migration_20260903_061000_add_radio_incorrect_counts from './20260903_061000_add_radio_incorrect_counts';
|
import * as migration_20260903_061000_add_radio_incorrect_counts from './20260903_061000_add_radio_incorrect_counts';
|
||||||
|
import * as migration_20260903_062000_add_aim_trainer_stats from './20260903_062000_add_aim_trainer_stats';
|
||||||
|
|
||||||
export const migrations = [
|
export const migrations = [
|
||||||
{
|
{
|
||||||
|
|
@ -132,4 +133,9 @@ export const migrations = [
|
||||||
down: migration_20260903_061000_add_radio_incorrect_counts.down,
|
down: migration_20260903_061000_add_radio_incorrect_counts.down,
|
||||||
name: '20260903_061000_add_radio_incorrect_counts',
|
name: '20260903_061000_add_radio_incorrect_counts',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
up: migration_20260903_062000_add_aim_trainer_stats.up,
|
||||||
|
down: migration_20260903_062000_add_aim_trainer_stats.down,
|
||||||
|
name: '20260903_062000_add_aim_trainer_stats',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1803,6 +1803,17 @@ export interface Profile {
|
||||||
watchBestAccuracy?: number | null;
|
watchBestAccuracy?: number | null;
|
||||||
xpEarned?: number | null;
|
xpEarned?: number | null;
|
||||||
};
|
};
|
||||||
|
aimTrainer?: {
|
||||||
|
gamesPlayed?: number | null;
|
||||||
|
bestScore?: number | null;
|
||||||
|
recruitBestScore?: number | null;
|
||||||
|
veteranBestScore?: number | null;
|
||||||
|
eliteBestScore?: number | null;
|
||||||
|
recruitBestAccuracy?: number | null;
|
||||||
|
veteranBestAccuracy?: number | null;
|
||||||
|
eliteBestAccuracy?: number | null;
|
||||||
|
xpEarned?: number | null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|
@ -3832,6 +3843,19 @@ export interface ProfilesSelect<T extends boolean = true> {
|
||||||
watchBestAccuracy?: T;
|
watchBestAccuracy?: T;
|
||||||
xpEarned?: T;
|
xpEarned?: T;
|
||||||
};
|
};
|
||||||
|
aimTrainer?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
gamesPlayed?: T;
|
||||||
|
bestScore?: T;
|
||||||
|
recruitBestScore?: T;
|
||||||
|
veteranBestScore?: T;
|
||||||
|
eliteBestScore?: T;
|
||||||
|
recruitBestAccuracy?: T;
|
||||||
|
veteranBestAccuracy?: T;
|
||||||
|
eliteBestAccuracy?: T;
|
||||||
|
xpEarned?: T;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue