-
Notifications
You must be signed in to change notification settings - Fork 0
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
feature(Documents): Expire non required documents #358
Conversation
app/models/operator_document.rb
Outdated
} | ||
|
||
enum status: { doc_not_provided: 0, doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4, doc_not_required: 5 } | ||
enum uploaded_by: { operator: 1, monitor: 2, admin: 3, other: 4 } | ||
enum source: { company: 1, forest_atlas: 2, other_source: 3 } | ||
|
||
NON_HISTORICAL_ATTRIBUTES = %w[id attachment updated_at created_at].freeze | ||
EXPIRABLE_STATUSES = statuses.slice(:doc_valid, :doc_expired).values.freeze |
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.
%w[doc_valid doc_expired]
or %i[doc_valid doc_expired]
would be enough and it should work I think. Rails itself should change those values to integer.
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.
You can add another spec, pretty simple for #expire_documents
in operator_document_spec.rb
just to add another document with different status
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.
Other than missing spec, I think all good. Expiration task should that we already have running daily should expire those not required documents.
This commit adds "not-required" documents to the list of documents to expire.
582b799
to
759bcb7
Compare
@tsubik I updated the PR to include tests. |
Also, we should (later) refactor the |
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.
Looks great. New specs are very well organized. I'm always struggling with that ;)
@@ -20,12 +20,11 @@ | |||
rd.deleted_at.nil? | |||
end | |||
column 'required_gov_document_group' do |rd| | |||
rd.required_operator_document_group&.name | |||
rd.required_gov_document_group&.name |
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.
👍
current { true } | ||
|
||
transient do | ||
force_status { nil } |
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.
Wouldn't work if we just set status? Anyway, interesting use of transient.
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.
I always do it like this. I'm not sure if status
would work.
Task.
This PR adds "not-required" documents to the list of documents to expire.
Pull request checklist
Please check if your PR fulfills the following requirements:
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Only valid documents get expired
Issue Number: 183467740
What is the new behavior?
Not required documents also get expired.
Does this introduce a breaking change?
Other information