-
Notifications
You must be signed in to change notification settings - Fork 235
feat: Aggregation pipeline for getting raw activity data #10498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/172653-contribution-graph
Are you sure you want to change the base?
feat: Aggregation pipeline for getting raw activity data #10498
Conversation
| $project: { | ||
| _id: 0, | ||
| d: '$_id', | ||
| c: '$count', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key が d, c ってわかりにくい
| action: { $in: Object.values(ActivityLogActions) }, | ||
| timestamp: { | ||
| $gte: startDate, | ||
| $lt: new Date(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
クエリキャッシュのパフォーマンスが低下する可能性
start date も end date も、hour, minute, second は 0 で初期化する
| date: '$timestamp', | ||
| timezone: 'Z', | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
クエリキャッシュのパフォーマンスが低下する可能性
$dateTrunc を使えないか?
https://www.mongodb.com/docs/manual/reference/operator/aggregation/datetrunc/
|
|
||
| expect(aggregateMockFn).toHaveBeenCalledTimes(1); | ||
| expect(mockExec).toHaveBeenCalledTimes(1); | ||
| expect(result).toEqual(mockDbOutput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テストが「本質的なテスト」になっていない
「本質的なテスト」とは?:
- arrange, act, assert パターンに於いて、arrange で act, assert に都合のいいデータや mock を作っていないか?
- 本質的でないテストでは、act, assert に都合のいいデータや mock を作っている
- 実装を利用したテストになっているか?
- 本質的でないテストでは、実装が変わってデグレしたとしてもテストが成功してしまう
現状では、runAggregationPipeline が呼ばれたかどうかだけをテストしており、実際の buildPipeline がどのように集計しどのような集計結果になるべきかをテストしていない
c659c00 to
601f4b0
Compare
69e977b to
6f72cc6
Compare
https://redmine.weseek.co.jp/issues/172653
┗ https://redmine.weseek.co.jp/issues/172666