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

Implement display options for Duration type #1091

Merged
merged 8 commits into from
Feb 25, 2022

Conversation

silentninja
Copy link
Contributor

@silentninja silentninja commented Feb 21, 2022

Fixes #433

Adds display options for the duration type.

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.

@silentninja silentninja requested a review from a team February 21, 2022 21:23
@kgodey kgodey self-assigned this Feb 22, 2022
@kgodey kgodey added the pr-status: review A PR awaiting review label Feb 22, 2022
Copy link
Contributor

@kgodey kgodey left a comment

Choose a reason for hiding this comment

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

@silentninja It seems like this point from #433 is not addressed here:

(4) We should add supported display options to the types endpoint.

See individual comments also.

@@ -256,6 +257,7 @@ def test_column_create_display_options(
name = "anewcolumn"
data = {"name": name, "type": type_, "display_options": display_options}
response = client.post(f"/api/db/v0/tables/{column_test_table.id}/columns/", data)
print(response.data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this print statement.

@@ -180,6 +180,14 @@ def validate(self, datetime_obj, display_format, serializer_field):
return super().validate(datetime_obj, display_format, serializer_field)


class DurationFormatValidator(TimeWithoutTimeZoneFormatValidator):
"""
The validation is same as Time Without TimeZone as of now,
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not make sense. Durations can span weeks, months, days, and years. Times cannot.

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 it, it was meant to be timestamp. I have changed the validation method anyway since we need a different error message, though the logic is similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I haven't restricted using a weekdate format string(2019-W17), though the duration value returned from the database follows RFC 3339 and does not return a weekdate, as the user might have a different requirement

@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 Feb 23, 2022
@kgodey
Copy link
Contributor

kgodey commented Feb 23, 2022

I also wanted to verify that this point was addressed, I don't see it anywhere.

(3) If the column type is changed, the display options should be deleted.

@kgodey kgodey changed the title mathesar-433 Implement display options for Duration type Implement display options for Duration type Feb 23, 2022
@kgodey kgodey assigned silentninja and unassigned kgodey Feb 23, 2022
@codecov-commenter
Copy link

codecov-commenter commented Feb 23, 2022

Codecov Report

Merging #1091 (e124ca2) into master (8591a14) will decrease coverage by 0.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1091      +/-   ##
==========================================
- Coverage   93.25%   93.24%   -0.02%     
==========================================
  Files         112      112              
  Lines        4078     4084       +6     
==========================================
+ Hits         3803     3808       +5     
- Misses        275      276       +1     
Flag Coverage Δ
pytest-backend 93.24% <85.71%> (-0.02%) ⬇️

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/api/serializers/shared_serializers.py 86.04% <85.71%> (-0.14%) ⬇️

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 8591a14...e124ca2. Read the comment docs.

@silentninja
Copy link
Contributor Author

I also wanted to verify that this point was addressed, I don't see it anywhere.

(3) If the column type is changed, the display options should be deleted.

This was handled as part of the initial display options PR, it is taken care of when a column is reflected

@silentninja
Copy link
Contributor Author

silentninja commented Feb 23, 2022

(4) We should add supported display options to the types endpoint.

Available Display options are part of the types serializer. I have added it to the list

@kgodey
Copy link
Contributor

kgodey commented Feb 23, 2022

Available Display options are part of the types serializer. I have added it to the list

Sorry I missed this, I think I reviewed too many PRs in a row. :/

@silentninja silentninja requested a review from kgodey February 24, 2022 23:06
@silentninja silentninja assigned kgodey and unassigned silentninja Feb 24, 2022
@kgodey kgodey 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 Feb 24, 2022
@kgodey kgodey merged commit 02e22cb into master Feb 25, 2022
@kgodey kgodey deleted the mathesar-433-duration-display-options branch February 25, 2022 23:11
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 Duration type
3 participants