Skip to content
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

Merged
merged 10 commits into from
Mar 21, 2023

Conversation

tshuli
Copy link
Contributor

@tshuli tshuli commented Mar 20, 2023

@tshuli tshuli requested a review from timotheeg March 20, 2023 08:02
Comment on lines +110 to +111
// TODO query submission to chedk how many forms of those forms had submissions in the past 3 weeks.

Copy link
Contributor

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 :)

Suggested change
// TODO query submission to chedk how many forms of those forms had submissions in the past 3 weeks.

Comment on lines +158 to +174
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()))
Copy link
Contributor

@timotheeg timotheeg Mar 21, 2023

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.

@tshuli tshuli merged commit b9c2307 into develop Mar 21, 2023
@tshuli tshuli deleted the script_find_invalid_whitespaces branch March 21, 2023 05:00
@wanlingt wanlingt mentioned this pull request Mar 24, 2023
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants