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

Feature/timestamps #1559

Merged
merged 8 commits into from
Sep 13, 2021
Merged

Feature/timestamps #1559

merged 8 commits into from
Sep 13, 2021

Conversation

michaeljcollinsuk
Copy link
Contributor

@michaeljcollinsuk michaeljcollinsuk commented Aug 19, 2021

Ref #1022

This work:

  • Updates models that were using the Timestampable model to use TimeStampedModel for codebase consistency
  • Exposes the created and modified fields on the Organization, Party, and People models serializers
  • Allows models to be filtered by the modified date on each models list endpoint

Screen Shot 2021-09-13 at 9 23 50 AM
Screen Shot 2021-09-13 at 9 23 26 AM
Screen Shot 2021-09-13 at 9 41 38 AM

@VirginiaDooley VirginiaDooley self-assigned this Aug 30, 2021
@VirginiaDooley VirginiaDooley force-pushed the feature/timestamps branch 4 times, most recently from 0d18b6f to 8741ae1 Compare September 6, 2021 08:55
@VirginiaDooley VirginiaDooley changed the title WIP Feature/timestamps Feature/timestamps Sep 6, 2021
@VirginiaDooley VirginiaDooley marked this pull request as ready for review September 6, 2021 12:10
michaeljcollinsuk and others added 4 commits September 6, 2021 13:35
- 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
model = Person
fields = ["last_updated"]

last_updated = filters.DateTimeFilter(
Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@symroe
Copy link
Member

symroe commented Sep 8, 2021

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

@VirginiaDooley VirginiaDooley force-pushed the feature/timestamps branch 2 times, most recently from e5b9d94 to 1bcbd68 Compare September 9, 2021 13:43
@VirginiaDooley
Copy link
Contributor

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

Working as expected ✅

@VirginiaDooley VirginiaDooley force-pushed the feature/timestamps branch 2 times, most recently from 5a122f4 to 3bd5a6c Compare September 9, 2021 14:14
from django_filters import filterset, filters


class LastUpdatedFilter(filterset.FilterSet):
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

@michaeljcollinsuk michaeljcollinsuk left a 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.

@michaeljcollinsuk
Copy link
Contributor Author

...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.

Just added a thought about this to related issue in WCIVF

Copy link
Member

@symroe symroe left a 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")
Copy link
Member

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?

@VirginiaDooley VirginiaDooley merged commit c106177 into master Sep 13, 2021
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.

3 participants