-
Notifications
You must be signed in to change notification settings - Fork 27
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/timestamps #1559
Feature/timestamps #1559
Conversation
0d18b6f
to
8741ae1
Compare
8741ae1
to
897ae18
Compare
897ae18
to
ff4b3f5
Compare
- Update models that were using the Timestampable model to use TimeStampedModel for consistency across the codebase - Data migrations to copy accross the existing created_at values - Change references to created_at and updated_at to created and modified
- Helper to get date four weeks before election
ff4b3f5
to
e56013c
Compare
ynr/apps/people/api/next/filters.py
Outdated
model = Person | ||
fields = ["last_updated"] | ||
|
||
last_updated = filters.DateTimeFilter( |
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.
Was having a play around with this locally, and see what you meant about the date formatting being a bit awkward. Then I came across the IsoDateTimeFilter
which I think we should use instead of the DateTimeFilter
- as then when we use the API in WCIVF, it will mean we can use the isoformat()
helper method on a datetime, rather than having to format the date ourselves.
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.
Should I do this for all filters expecting an ISO datetime?
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.
Thinks its good on just the new ones for now, as dont want to break anything by changing the pre-existing ones.
I've not looked yet, but another thing to review / check here is that the documentation gets generated properly for this. For example, the params get generated for the results endpoint here: https://candidates.democracyclub.org.uk/api/docs/next/endpoints/#results_list But not the people one here: https://candidates.democracyclub.org.uk/api/docs/next/endpoints/#people_list |
e5b9d94
to
1bcbd68
Compare
Working as expected ✅ |
5a122f4
to
3bd5a6c
Compare
3bd5a6c
to
7d551a6
Compare
ynr/apps/api/next/filters.py
Outdated
from django_filters import filterset, filters | ||
|
||
|
||
class LastUpdatedFilter(filterset.FilterSet): |
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.
Sorry one last comment! So this is the case where you would use Mixin
in the name - as you wouldn't use this on its own, its purpose is to be inherited elsewhere
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.
That makes sense, will change.
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 can't approve this as since I opened the PR myself! But added one last minor comment about naming, otherwise think this is good to be merged. I know there is more work to do, specifically about when/how we ensure the modified
value is up to date when a child relation is updated, but I think that can be tackled outside of this PR.
|
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.
One minor comment, otherwise 👍
fields = ("contact_type", "label", "note", "value") | ||
fields = ("contact_type", "label", "note", "value", "created") | ||
|
||
last_updated = serializers.DateTimeField(source="modified") |
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.
Does this need to be in the fields
tuple?
Ref #1022
This work: