-
Notifications
You must be signed in to change notification settings - Fork 210
Fix some minor "gotchas" with the dashboard / review summation handling #7181
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -577,6 +577,10 @@ export function buildStatisticsData(reviewSummations = []) { | |
| if (!summation) { | ||
| return false; | ||
| } | ||
| const score = normalizeScoreValue(_.get(summation, 'aggregateScore')); | ||
| if (_.isNil(score)) { | ||
| return false; | ||
| } | ||
| return getSummationScoreClassification(summation).isProvisional; | ||
| }); | ||
|
|
||
|
|
@@ -587,6 +591,19 @@ export function buildStatisticsData(reviewSummations = []) { | |
| return; | ||
| } | ||
|
|
||
| const timestamp = getSummationTimestamp(summation); | ||
| const timestampValue = toTimestampValue(timestamp); | ||
| const score = normalizeScoreValue(_.get(summation, 'aggregateScore')); | ||
| if (_.isNil(score)) { | ||
| return; | ||
| } | ||
| const scoreType = getSummationScoreClassification(summation); | ||
| if (includeOnlyProvisional) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| if (!scoreType.isProvisional) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| const handle = getSummationHandle(summation); | ||
| if (!grouped.has(handle)) { | ||
| grouped.set(handle, { | ||
|
|
@@ -597,25 +614,11 @@ export function buildStatisticsData(reviewSummations = []) { | |
| } | ||
|
|
||
| const entry = grouped.get(handle); | ||
|
|
||
| const rating = getSummationRating(summation); | ||
| if (_.isNil(entry.rating) && !_.isNil(rating)) { | ||
| entry.rating = rating; | ||
| } | ||
|
|
||
| const timestamp = getSummationTimestamp(summation); | ||
| const timestampValue = toTimestampValue(timestamp); | ||
| const score = normalizeScoreValue(_.get(summation, 'aggregateScore')); | ||
| if (_.isNil(score)) { | ||
| return; | ||
| } | ||
| if (includeOnlyProvisional) { | ||
| const scoreType = getSummationScoreClassification(summation); | ||
| if (!scoreType.isProvisional) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| const rawSubmissionId = _.get( | ||
| summation, | ||
| 'submissionId', | ||
|
|
@@ -643,20 +646,22 @@ export function buildStatisticsData(reviewSummations = []) { | |
| entry.submissionsMap.set(submissionId, updatedSubmission); | ||
| }); | ||
|
|
||
| return Array.from(grouped.values()).map(entry => ({ | ||
| handle: entry.handle, | ||
| rating: entry.rating, | ||
| submissions: Array.from(entry.submissionsMap.values()) | ||
| .map(submission => ({ | ||
| submissionId: submission.submissionId, | ||
| created: submission.created, | ||
| createdAt: submission.createdAt, | ||
| score: submission.score, | ||
| })) | ||
| .sort( | ||
| (a, b) => toTimestampValue(b.createdAt) - toTimestampValue(a.createdAt), | ||
| ), | ||
| })); | ||
| return Array.from(grouped.values()) | ||
| .map(entry => ({ | ||
| handle: entry.handle, | ||
| rating: entry.rating, | ||
| submissions: Array.from(entry.submissionsMap.values()) | ||
| .map(submission => ({ | ||
| submissionId: submission.submissionId, | ||
| created: submission.created, | ||
| createdAt: submission.createdAt, | ||
| score: submission.score, | ||
| })) | ||
| .sort( | ||
| (a, b) => toTimestampValue(b.createdAt) - toTimestampValue(a.createdAt), | ||
| ), | ||
| })) | ||
| .filter(entry => Array.isArray(entry.submissions) && entry.submissions.length > 0); | ||
| } | ||
|
|
||
| export default { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,8 +199,10 @@ export function getUnSelectedColors(rating) { | |
| */ | ||
| export function getAuthTokens(req = {}) { | ||
| const cookies = req.cookies || {}; | ||
| let tokenV2 = cookies.tcjwt; | ||
| let tokenV3 = cookies.tcjwt; | ||
| // Support both historical cookie names used across environments. | ||
| const authToken = cookies.tcjwt || cookies.tcJwt; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| let tokenV2 = authToken; | ||
| let tokenV3 = authToken; | ||
|
|
||
| if (!tokenV2 || isTokenExpired(tokenV2, config.AUTH_DROP_TIME)) { | ||
| tokenV2 = ''; | ||
|
|
||
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.
[⚠️
performance]The
normalizeScoreValuefunction is called multiple times for the sameaggregateScorevalue within the same loop iteration. Consider storing the result in a variable to avoid redundant computations.