-
Notifications
You must be signed in to change notification settings - Fork 87
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
docs: Script to find invalid whitespaces #5945
Conversation
tshuli
commented
Mar 20, 2023
- Adds a reference script which was used for trailing whitespaces incident
- Reference hotfix: build: release 6.36.1 hotfix #5940
// TODO query submission to chedk how many forms of those forms had submissions in the past 3 weeks. | ||
|
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.
Can remove this TODO since it was done :)
// TODO query submission to chedk how many forms of those forms had submissions in the past 3 weeks. |
const allSubmissions = await submissionCollection | ||
.find({ | ||
created: { | ||
$gte: new Date(START_DATE_TIME), | ||
$lt: new Date(END_DATE_TIME), | ||
}, | ||
}) | ||
.project({ _id: 1, form: 1 }) | ||
.toArray() | ||
|
||
console.log(allSubmissions.length) | ||
|
||
console.log('-----') | ||
console.log( | ||
'Total number of forms which received submissions during that timeframe:', | ||
) | ||
const allForms = new Set(allSubmissions.map((s) => s.form.toString())) |
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.
This works fine, but just some feedback: the process as coded here gathers a huge dataset of repeated entries, that needs to be stored entirely in memory (~1.3M entries in this case).
When computing stats, leverage the DB as much as possible to reduce the size of datasets to just what you need. In this case, it would have probably been better to query for an aggregate of submission count by formid, and then do a summation of the submission counts in code to derive the total number of submissions received overall.