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

Split datetime into three UI types #1093

Merged
merged 16 commits into from
Mar 8, 2022

Conversation

dmos62
Copy link
Contributor

@dmos62 dmos62 commented Feb 22, 2022

Fixes #960

Changes the definition of Mathesar/UI types. What was before datetime UI type, now is date, time and datetime types.

Technical details

Below description is outdated. See this comment: #1093 (comment)

@pavish @seancolsen these types' display options are different too. datetime initially accepted format display option. Now, datetime accepts date_format and time_format display options: date accepts date_format: and, time accepts time_format.

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.

@dmos62 dmos62 added affects: architecture Improvements or additions to architecture work: backend Related to Python, Django, and simple SQL status: draft labels Feb 22, 2022
@dmos62 dmos62 added this to the [07] Initial Data Types milestone Feb 22, 2022
@dmos62 dmos62 self-assigned this Feb 22, 2022
@dmos62 dmos62 changed the base branch from master to time-filter-aliases March 1, 2022 13:22
@dmos62
Copy link
Contributor Author

dmos62 commented Mar 1, 2022

Dependent on #1089.

@dmos62 dmos62 added the pr-status: review A PR awaiting review label Mar 1, 2022
@dmos62 dmos62 marked this pull request as ready for review March 1, 2022 13:52
@dmos62 dmos62 requested a review from a team March 1, 2022 13:52
@github-actions github-actions bot requested review from eito-fis, kgodey, mathemancer, pavish and silentninja and removed request for a team March 1, 2022 13:52
@dmos62
Copy link
Contributor Author

dmos62 commented Mar 1, 2022

@kgodey
Copy link
Contributor

kgodey commented Mar 1, 2022

@dmos62 can you mark as a draft since this isn't ready to be merged (due to other PRs needing to be merged first?)

@dmos62
Copy link
Contributor Author

dmos62 commented Mar 1, 2022

@kgodey undrafting is part of the process to mark this as ready for review. Should I undraft and redraft in this case?

Edit: code review guidelines for authors don't account for the scenario where a PR shouldn't be merged, but can be reviewed.

@dmos62
Copy link
Contributor Author

dmos62 commented Mar 1, 2022

Major changes after sync call. What frontend needs to know (first post is now outdated):

  • the datetime UI type was split into time, date, datetime;
  • time, date and datetime formats accept only the format display option;
  • format display option is validated on the backend to contain no more than 255 characters.

@kgodey
Copy link
Contributor

kgodey commented Mar 1, 2022

undrafting is part of the process to mark this as ready for review. Should I undraft and redraft in this case?

Edit: code review guidelines for authors don't account for the scenario where a PR shouldn't be merged, but can be reviewed.

@dmos62 I would either:

  • leave it as draft and set status to review, assign reviewers manually, and post in the Code Review channel
  • not mark it as ready for review until it's actually ready to be merged and instead remind people to prioritize reviewing the PRs blocking the merge of the current PR.

Please update the code review guidelines in the wiki.

Also, I recommend basing as many PRs as you can off of master if what you're working on doesn't depend on functionality from previous PRs. You might already be doing that.

@dmos62 dmos62 marked this pull request as draft March 1, 2022 15:47
@dmos62
Copy link
Contributor Author

dmos62 commented Mar 1, 2022

@kgodey I'll update the wiki.

Also, I recommend basing as many PRs as you can off of master if what you're working on doesn't depend on functionality from previous PRs. You might already be doing that.

I'm already doing that. Most PRs end up implementing something that will affect the other PRs. I also sometimes base off another dev branch to avoid having to resolve merge conflicts.

@dmos62
Copy link
Contributor Author

dmos62 commented Mar 1, 2022

@silentninja I made some slight refactors to the display options serializer.

See https://github.com/centerofci/mathesar/pull/1093/files#diff-0cba368aff485c57e63a82055dfe283abac0a640d1896e087ae59d160210270cL105

and https://github.com/centerofci/mathesar/pull/1093/files#diff-0cba368aff485c57e63a82055dfe283abac0a640d1896e087ae59d160210270cR250

Could you give it a quick glance for a sanity check?

@silentninja after implementing changes requested in sync call, most of the refactor I mentioned has been removed, because most of the code it was refactoring isn't necessary anymore. You might want to take a look anyway, but now the code is pretty simple, so you're not missing out if you don't.

serializers.Serializer
):
format = serializers.CharField(validators=[TimeWithoutTimeZoneFormatValidator()])
format = serializers.CharField(validators=[is_time_format_valid])
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to use the max_length parameter instead of custom validator, this would help up to throw errors with proper error codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed 27f75ca

Base automatically changed from time-filter-aliases to master March 3, 2022 15:38
@dmos62 dmos62 marked this pull request as ready for review March 3, 2022 16:19
@dmos62
Copy link
Contributor Author

dmos62 commented Mar 3, 2022

@kgodey should be ready for merge.

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2022

Codecov Report

Merging #1093 (890064a) into master (67e615a) will decrease coverage by 0.12%.
The diff coverage is 100.00%.

❗ Current head 890064a differs from pull request most recent head 837550f. Consider uploading reports for the commit 837550f to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1093      +/-   ##
==========================================
- Coverage   93.38%   93.25%   -0.13%     
==========================================
  Files         112      112              
  Lines        4291     4243      -48     
==========================================
- Hits         4007     3957      -50     
- Misses        284      286       +2     
Flag Coverage Δ
pytest-backend 93.25% <100.00%> (-0.13%) ⬇️

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% <ø> (ø)
db/functions/hints.py 94.73% <100.00%> (+0.29%) ⬆️
db/types/base.py 97.54% <100.00%> (+0.17%) ⬆️
mathesar/api/serializers/shared_serializers.py 78.08% <100.00%> (-7.97%) ⬇️
mathesar/database/types.py 97.67% <100.00%> (+0.05%) ⬆️
mathesar/api/exceptions/mixins.py 86.84% <0.00%> (-5.27%) ⬇️
db/columns/operations/alter.py 96.57% <0.00%> (-0.10%) ⬇️
db/columns/operations/infer_types.py 97.05% <0.00%> (-0.09%) ⬇️

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 67e615a...837550f. Read the comment docs.

@kgodey
Copy link
Contributor

kgodey commented Mar 3, 2022

@dmos62 sounds good, assigned to @silentninja to merge since he already reviewed it.

Copy link
Contributor

@silentninja silentninja left a comment

Choose a reason for hiding this comment

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

Also, remove the arrow library` as it is unnecessary. Please make the requested changes and merge.



class DurationDisplayOptionSerializer(MathesarErrorMessageMixin, OverrideRootPartialMixin, serializers.Serializer):
format = serializers.CharField(validators=[DurationFormatValidator()])
format = serializers.CharField(max_length=255, validators=[raise_if_duration_format_invalid])
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on our conclusion, other than a character length check, we don't need any additional validators. So the validators field and the validation function should be removed

@silentninja silentninja removed their assignment Mar 7, 2022
@silentninja silentninja 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 Mar 7, 2022
@dmos62 dmos62 requested a review from a team March 8, 2022 13:05
@dmos62
Copy link
Contributor Author

dmos62 commented Mar 8, 2022

Removed arrow library and custom time/duration format validation.

@dmos62 dmos62 requested a review from silentninja March 8, 2022 13:06
@silentninja silentninja merged commit 10fa641 into master Mar 8, 2022
@silentninja silentninja deleted the split-datetime-into-three-ui-types branch March 8, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: architecture Improvements or additions to architecture pr-status: revision A PR awaiting follow-up work from its author after review work: backend Related to Python, Django, and simple SQL
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Split Date & Time data type into three Mathesar types
4 participants