-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: Add submission limits for storage mode form submissions #1097
Conversation
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.
Changes to make after discussion
- Ship form deactivation without notification feature
- Form status should be set to deactivated when submission limit is reached (it would be good to log this)
- Align UI to design screens
f204fcc
to
4b3ac7a
Compare
@liangyuanruo I am not sure how to fix these build errors, can you take a look? Thanks!
|
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.
To be launched for both Storage and Email mode forms, and add tests.
The email submission route (as defined in email-submission.routes.ts) doesn't support |
98fbf82
to
b2e5684
Compare
Ah, I think this is because we recently refactored to combine the email submission middlewares together into a single I think you can get around this by first extracting all the business logic from the Does this make sense? |
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.
Follow-up from discussions:
- drop
hasSubmissionLimit
boolean - refactor logic out of
checkFormSubmissionLimitAndDeactivate
middleware into a service function for reuse with both storage and email mode forms
@liangyuanruo made all the changes -- PTAL, thanks! |
src/app/modules/submission/email-submission/email-submission.controller.ts
Outdated
Show resolved
Hide resolved
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.
thanks @frankchn - clarified with @syan-syan and I think we need some further refinements to both the processing flow and data model.
…r email mode forms
ed82e66
to
1d9a11d
Compare
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.
Thanks @frankchn , almost there!
Co-authored-by: Yuan Ruo <yuanruo@data.gov.sg>
changes from reviewing staging
|
Problem
This pull request adds a submission limits feature for storage.
Closes #148
Solution
Instead of using the
formStatisticsTotal
collection, I am simply queryingSubmissionModel.countDocuments({ form: form._id })
for the number of submissions up till now. I think this is probably fine as the submission model has an index on theform
field and we are already using that to count the total number of submissions for export and attachment downloads and those seem reasonably fast.Otherwise, we are allowing users to specify a submission limit, but will simply show them an error message instead of attempting to deactivate the form, which is more complicated and requires us to touch the form document itself instead of simply checking for number of submissions before we render the form and before the form is submitted.
This also doesn't require re-CAPTCHA to be turned on (maybe we should?).
Features:
Before & After Screenshots
Tests
Deploy Notes
This introduces a new
submissionLimit
field in theForm
collection.