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

Validate start/end when scheduling queries #7508

Merged
merged 2 commits into from
May 16, 2019

Conversation

betodealmeida
Copy link
Member

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

This PR adds validation to start and end dates when scheduling queries in SQL Lab, ensuring that the end date doesn't come before the start date.

It also initializes the form with defaults. Ideally we want these to be relative dates, so I used the Sugar library to parse human readable dates. For example, with this config:

            'start_date': {
                'type': 'string',
                'format': 'date-time',
                'title': 'Start date',
                'default': 'today at 9am',
            },
            'end_date': {
                'type': 'string',
                'format': 'date-time',
                'title': 'End date',
                'default': '9am in 30 days',
            },

We get:

Screen Shot 2019-05-14 at 1 38 31 PM

TEST PLAN

Tested locally:

Screen Shot 2019-05-14 at 1 46 01 PM

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@DiggidyDave @khtruong @datability-io

@codecov-io
Copy link

codecov-io commented May 14, 2019

Codecov Report

Merging #7508 into lyft-release-sp8 will decrease coverage by 0.07%.
The diff coverage is 4%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           lyft-release-sp8   #7508      +/-   ##
===================================================
- Coverage             65.27%   65.2%   -0.08%     
===================================================
  Files                   435     435              
  Lines                 21389   21414      +25     
  Branches               2357    2361       +4     
===================================================
+ Hits                  13961   13962       +1     
- Misses                 7308    7332      +24     
  Partials                120     120
Impacted Files Coverage Δ
...sets/src/SqlLab/components/ScheduleQueryButton.jsx 9.09% <4%> (-4.25%) ⬇️

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 a4bddc6...fc8670a. Read the comment docs.

'title': 'Start date',
# date-time is parsed using the Sugar library, see
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we already had some logic or a library that handles relative dates. I am a little iffy about using this library because it looks like it's maintained by one developer and the last version was 5 months ago so I am not sure how often this library is maintained.

Copy link
Member Author

Choose a reason for hiding this comment

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

@khtruong we use moment.js, but it can't parse relative dates like these, which is what we really want.

Copy link
Contributor

@khtruong khtruong left a comment

Choose a reason for hiding this comment

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

Still a little iffy about using the Sugar library but if you felt that it was the best that suits your needs, I trust ya.

@betodealmeida
Copy link
Member Author

@khtruong yeah, I understand your point. I found another library called chrono which does the same and depends only on moment.js, I'll use that instead.

@betodealmeida
Copy link
Member Author

TBH, I don't think the time-of-last update is a good factor for determining if we should use a library. Some libraries are small, do one thing, and do it well, and no longer need to be updated at some point. But Sugar does more than one thing, and it has many dependencies, so even if we're using it for something that might never change (date parsing) it might break in the future if its dependencies change.

Chrono, on the other hand, does only one thing (date parsing), and only depends on moment.js, which we also depend on, so I think it's a safer bet. I'll update this PR in a bit.

@betodealmeida betodealmeida merged commit c7f8f27 into apache:lyft-release-sp8 May 16, 2019
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* Validate start/end when scheduling queries

* Use chrono instead of Sugar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants