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

Datetime display options #885

Merged
merged 12 commits into from
Jan 13, 2022
Merged

Datetime display options #885

merged 12 commits into from
Jan 13, 2022

Conversation

silentninja
Copy link
Contributor

@silentninja silentninja commented Dec 13, 2021

Fixes #428

Accept display options for datetime column types.

Technical details
This PR adds a serializer to accept and validate datetime column display_options. It uses arrow library to validate format field values to accept only valid datetime object and restrict the format string based on types(date column can't accept format string with time formats).

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the master branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

… the javascript date format is correct for a display option

Add Date time display options serializer
Add validation for date time display option serializer
Fix Column serializer and column reflection to use plain_type as `DISPLAY_OPTIONS_SERIALIZER_MAPPING_KEY` for display options serializer mapping instead of sql alchemy type
@silentninja silentninja requested a review from a team December 13, 2021 15:36
@github-actions github-actions bot requested review from dmos62, eito-fis, kgodey, mathemancer and pavish and removed request for a team December 13, 2021 15:36
@silentninja silentninja linked an issue Dec 13, 2021 that may be closed by this pull request
@silentninja silentninja added the needs: unblocking Blocked by other work label Dec 13, 2021
@silentninja
Copy link
Contributor Author

Blocked by #865

@silentninja silentninja marked this pull request as draft December 13, 2021 15:38
@kgodey kgodey self-assigned this Dec 16, 2021
@kgodey kgodey removed their assignment Dec 23, 2021
Base automatically changed from timestamp-type to master January 6, 2022 22:24
@silentninja silentninja added ready Ready for implementation and removed needs: unblocking Blocked by other work labels Jan 8, 2022
@silentninja silentninja marked this pull request as ready for review January 8, 2022 19:12
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2022

Codecov Report

Merging #885 (7babb26) into master (13289cc) will increase coverage by 0.08%.
The diff coverage is 98.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #885      +/-   ##
==========================================
+ Coverage   93.20%   93.29%   +0.08%     
==========================================
  Files          86       86              
  Lines        3104     3160      +56     
==========================================
+ Hits         2893     2948      +55     
- Misses        211      212       +1     
Flag Coverage Δ
pytest-backend 93.29% <98.36%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mathesar/api/display_options.py 100.00% <ø> (ø)
mathesar/reflection.py 98.70% <ø> (ø)
mathesar/api/serializers/shared_serializers.py 85.59% <98.30%> (+11.39%) ⬆️
mathesar/api/serializers/columns.py 98.76% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13289cc...7babb26. Read the comment docs.

@kgodey kgodey added pr-status: review A PR awaiting review and removed ready Ready for implementation labels Jan 10, 2022
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks pretty good. Some comments:

  • The validation is spread over two functions called in different ways, which is a bit confusing. Couldn't one call the other?
  • One of the validations was missing a piece (I think; see the specific comment)
  • Please make vulture happy so the pipeline passes.

mathesar/api/serializers/shared_serializers.py Outdated Show resolved Hide resolved
@silentninja silentninja added pr-status: revision A PR awaiting follow-up work from its author after review pr-status: review A PR awaiting review and removed pr-status: review A PR awaiting review pr-status: revision A PR awaiting follow-up work from its author after review labels Jan 11, 2022
@kgodey kgodey added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Jan 11, 2022
@kgodey kgodey assigned silentninja and unassigned kgodey Jan 11, 2022
@silentninja silentninja added pr-status: review A PR awaiting review and removed pr-status: revision A PR awaiting follow-up work from its author after review labels Jan 12, 2022
@silentninja silentninja removed their assignment Jan 12, 2022
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me; thanks!

@mathemancer mathemancer merged commit d62fd6f into master Jan 13, 2022
@mathemancer mathemancer deleted the datetime-display-options branch January 13, 2022 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Implement display options for date & time types
4 participants