Skip to content

Commit

Permalink
feat ✨ daily materialized view 추가
Browse files Browse the repository at this point in the history
feat: ✨ mv_daily_scale_team_counts 추가
feat: ✨ mv_daily_team_close_counts 추가
feat: ✨ mv_daily_score_values 추가
chore: ⬆️ mongodb client version update, TZ 시간 형태로 변경

- #54
  • Loading branch information
jpham005 committed Nov 13, 2023
1 parent cfab9ec commit a44fa3b
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 86 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"camelcase-keys": "^8.0.2",
"dotenv": "^16.0.3",
"la-seine": "^0.0.7",
"mongodb": "^5.3.0",
"mongodb": "^6.2.0",
"redis": "^4.6.6",
"zod": "^3.21.4"
}
Expand Down
86 changes: 40 additions & 46 deletions app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const execUpdators = async (
}
};

export const TIMEZONE = process.env.TIMEZONE;
assertEnvExist(TIMEZONE);

const main = async (): Promise<void> => {
await initSeine();

Expand Down
7 changes: 3 additions & 4 deletions app/src/location/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,21 @@ export class LocationUpdator {
* E 의 경우, 접속을 종료하는 사람들이 100명을 넘을 때 마다 한번씩 요청을 더 보내야함.
* 평소엔 1 ~ 2번으로 충분함.
*/
@UpdateAction
static async update(mongo: LambdaMongo, end: Date): Promise<void> {
await LocationUpdator.updatePrevOngoing(mongo);

await mongo.withCollectionUpdatedAt({
end,
collection: LOCATION_COLLECTION,
callback: async (start, end) => {
await LocationUpdator.updatePrevOngoing(mongo);
await LocationUpdator.updateOngoing(mongo, start, end);
await LocationUpdator.updateEnded(mongo, start, end);
await LocationUpdator.updateDailyLogtime(mongo, end);
},
});
}

@UpdateAction
@LogAsyncEstimatedTime
private static async updateOngoing(
mongo: LambdaMongo,
Expand Down Expand Up @@ -93,7 +94,6 @@ export class LocationUpdator {
return parseLocations(locationDtos);
}

@UpdateAction
@LogAsyncEstimatedTime
private static async updateEnded(
mongo: LambdaMongo,
Expand Down Expand Up @@ -128,7 +128,6 @@ export class LocationUpdator {
* location api 에 버그가 생기면 end_at 이 null 인 상태로 존재하기 때문에,
* 기존에 있던 location 들의 점검이 필요함.
*/
@UpdateAction
@LogAsyncEstimatedTime
private static async updatePrevOngoing(mongo: LambdaMongo): Promise<void> {
const prevOngoingIds = await mongo
Expand Down
2 changes: 2 additions & 0 deletions app/src/mongodb/mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { PROJECT_SESSIONS_SKILL_COLLECTION } from '#lambda/projectSessionsS
import type { PROJECTS_USER_COLLECTION } from '#lambda/projectsUser/projectsUser.js';
import type { QUESTS_USER_COLLECTION } from '#lambda/questsUser/questsUser.js';
import type { SCALE_TEAM_COLLECTION } from '#lambda/scaleTeam/scaleTeam.js';
import type { SCORE_COLLECTION } from '#lambda/score/score.js';
import type { SKILL_COLLECTION } from '#lambda/skill/skill.js';
import type { TEAM_COLLECTION } from '#lambda/team/team.js';
import type { USER_COLLECTION } from '#lambda/user/user.js';
Expand Down Expand Up @@ -44,6 +45,7 @@ type LogUpdatedAt =
| typeof COALITIONS_USER_COLLECTION
| typeof PROJECT_SESSION_COLLECTION
| typeof SKILL_COLLECTION
| typeof SCORE_COLLECTION
| typeof PROJECT_SESSIONS_SKILL_COLLECTION
| typeof USER_COLLECTION;

Expand Down
Loading

0 comments on commit a44fa3b

Please sign in to comment.