Skip to content

Commit

Permalink
Add setAchievementProgress query
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceManiac committed May 3, 2024
1 parent 0fa78af commit 21afec7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/node-sdk/paima-db/src/sql/achievements.queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/** Types generated for queries found in "src/sql/achievements.sql" */
import { PreparedQuery } from '@pgtyped/runtime';

export type DateOrString = Date | string;

/** 'GetAchievementProgress' parameters type */
export interface IGetAchievementProgressParams {
names: readonly (string | null | void)[];
Expand Down Expand Up @@ -35,3 +37,38 @@ const getAchievementProgressIR: any = {"usedParamSet":{"wallet":true,"names":tru
export const getAchievementProgress = new PreparedQuery<IGetAchievementProgressParams,IGetAchievementProgressResult>(getAchievementProgressIR);


/** 'SetAchievementProgress' parameters type */
export interface ISetAchievementProgressParams {
completed_date?: DateOrString | null | void;
name: string;
progress?: number | null | void;
total?: number | null | void;
wallet: string;
}

/** 'SetAchievementProgress' return type */
export type ISetAchievementProgressResult = void;

/** 'SetAchievementProgress' query type */
export interface ISetAchievementProgressQuery {
params: ISetAchievementProgressParams;
result: ISetAchievementProgressResult;
}

const setAchievementProgressIR: any = {"usedParamSet":{"wallet":true,"name":true,"completed_date":true,"progress":true,"total":true},"params":[{"name":"wallet","required":true,"transform":{"type":"scalar"},"locs":[{"a":89,"b":96}]},{"name":"name","required":true,"transform":{"type":"scalar"},"locs":[{"a":99,"b":104}]},{"name":"completed_date","required":false,"transform":{"type":"scalar"},"locs":[{"a":107,"b":121}]},{"name":"progress","required":false,"transform":{"type":"scalar"},"locs":[{"a":124,"b":132}]},{"name":"total","required":false,"transform":{"type":"scalar"},"locs":[{"a":135,"b":140}]}],"statement":"INSERT INTO achievement_progress (wallet, name, completed_date, progress, total)\nVALUES (:wallet!, :name!, :completed_date, :progress, :total)\nON CONFLICT (wallet, name)\nDO UPDATE SET\n completed_date = EXCLUDED.completed_date,\n progress = EXCLUDED.progress,\n total = EXCLUDED.total"};

/**
* Query generated from SQL:
* ```
* INSERT INTO achievement_progress (wallet, name, completed_date, progress, total)
* VALUES (:wallet!, :name!, :completed_date, :progress, :total)
* ON CONFLICT (wallet, name)
* DO UPDATE SET
* completed_date = EXCLUDED.completed_date,
* progress = EXCLUDED.progress,
* total = EXCLUDED.total
* ```
*/
export const setAchievementProgress = new PreparedQuery<ISetAchievementProgressParams,ISetAchievementProgressResult>(setAchievementProgressIR);


9 changes: 9 additions & 0 deletions packages/node-sdk/paima-db/src/sql/achievements.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ SELECT * FROM achievement_progress
WHERE wallet = :wallet!
AND ('*' in :names OR name IN :names)
;

/* @name setAchievementProgress */
INSERT INTO achievement_progress (wallet, name, completed_date, progress, total)
VALUES (:wallet!, :name!, :completed_date, :progress, :total)
ON CONFLICT (wallet, name)
DO UPDATE SET
completed_date = EXCLUDED.completed_date,
progress = EXCLUDED.progress,
total = EXCLUDED.total;

0 comments on commit 21afec7

Please sign in to comment.