-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
121 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
packages/central-server/src/apiV2/meditrakApp/getLeaderboardList.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Tupaia | ||
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd | ||
*/ | ||
import { | ||
SurveyResponseModel as BaseSurveyResponseModel, | ||
SurveyResponseType as BaseSurveyResponseType, | ||
} from '@tupaia/database'; | ||
import { Model } from '@tupaia/server-boilerplate'; | ||
|
||
export type SurveyResponseModelFields = Readonly<{ | ||
id: string; | ||
survey_id: string; | ||
user_id: string; | ||
start_time: string; | ||
end_time: string; | ||
metadata: Record<string, any>; | ||
timezone: string | null; | ||
entity_id: string; | ||
data_time: string | null; | ||
outdated: boolean | null; | ||
approval_status: string; | ||
}>; | ||
|
||
export interface SurveyResponseModelType | ||
extends SurveyResponseModelFields, | ||
Omit<BaseSurveyResponseType, 'id'> {} // Omit base `id: any` type as we explicity define as a string here | ||
|
||
export interface SurveyResponseModel | ||
extends Model<BaseSurveyResponseModel, SurveyResponseModelFields, SurveyResponseModelType> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/datatrak-web-server/src/routes/LeaderboardRoute.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Tupaia | ||
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import { Request } from 'express'; | ||
import camelcaseKeys from 'camelcase-keys'; | ||
import { Route } from '@tupaia/server-boilerplate'; | ||
import { DatatrakWebLeaderboardRequest } from '@tupaia/types'; | ||
|
||
export type LeaderboardRequest = Request< | ||
DatatrakWebLeaderboardRequest.Params, | ||
DatatrakWebLeaderboardRequest.ResBody, | ||
DatatrakWebLeaderboardRequest.ReqBody, | ||
DatatrakWebLeaderboardRequest.ReqQuery | ||
>; | ||
|
||
export class LeaderboardRoute extends Route<LeaderboardRequest> { | ||
public async buildResponse() { | ||
const { models } = this.req; | ||
|
||
const leaderboard = await models.surveyResponse.getLeaderboard(); | ||
return camelcaseKeys(leaderboard, { deep: true }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/types/src/types/requests/datatrak-web-server/LeaderboardRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import { LeaderboardItem } from '../../models-extra'; | ||
|
||
export type Params = Record<string, never>; | ||
|
||
export type ResBody = LeaderboardItem[]; | ||
export type ReqBody = Record<string, never>; | ||
export type ReqQuery = Record<string, never>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters