Skip to content

Commit

Permalink
[chore] hardcode levels to client (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Vieira authored Sep 11, 2023
1 parent beb6ced commit f95c5fe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/controllers/v2/learnAndEarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LearnAndEarnController {
}

services.learnAndEarn
.total(req.user.userId)
.total(req.user.userId, req.clientId || 1)
.then(r => standardResponse(res, 200, true, r))
.catch(e => standardResponse(res, 400, false, '', { error: e }));
};
Expand Down
7 changes: 7 additions & 0 deletions packages/api/src/routes/v2/learnAndEarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ export default (app: Router): void => {
* tags:
* - "learn-and-earn"
* summary: "Get user metrics"
* parameters:
* - in: header
* name: client-id
* schema:
* type: integer
* required: false
* description: optional client id
* responses:
* "200":
* description: OK
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/services/learnAndEarn/userData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { BaseError } from '../../utils/baseError';
import { formatObjectToNumber } from '../../utils';
import { models } from '../../database';

export async function total(userId: number): Promise<{
export async function total(
userId: number,
clientId: number
): Promise<{
lesson: {
completed: number;
total: number;
Expand Down Expand Up @@ -91,6 +94,11 @@ export async function total(userId: number): Promise<{
const level = formatObjectToNumber<Steps>(levels[0]);
const lesson = formatObjectToNumber<Steps>(lessons[0]);

if (clientId === 2) {
level.total = 1;
lesson.total = 7;
}

return {
lesson,
level,
Expand Down

0 comments on commit f95c5fe

Please sign in to comment.