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

Update weather script #32384

Merged
merged 6 commits into from
Jan 13, 2020
Merged

Update weather script #32384

merged 6 commits into from
Jan 13, 2020

Conversation

ajpal
Copy link
Contributor

@ajpal ajpal commented Dec 11, 2019

Description

Switch to using the daily API per curriculum request: https://openweathermap.org/forecast16
Before:
image

After:
image

Testing story

Manual testing only

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

WeatherRecord = Struct.new(:id, :city, :state, :timestamp, :temp_min, :temp_max, :weather, :icon, :wind_speed)

def cardinal_dir_from_degrees(degrees)
dirs = %w(N NE E SE S SW W NW N)
Copy link
Contributor

@jmkulwik jmkulwik Dec 16, 2019

Choose a reason for hiding this comment

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

Is it intentional that N is in here twice?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. For 0 and 360.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, second question. Is it ever possible to get degrees above 360 or below 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, intentional for N twice, for 0 and 360 as you said :)
I don't think the API response will ever have numbers outside that range.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. What about error input? If degrees is "nil" or something similar, will it cause the script to error out and exit early? Is that ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

✔️ Nice update

@@ -165,6 +197,7 @@ end
def main
fb = FirebaseHelper.new('shared')
records, columns = get_weather_data
fb.delete_shared_table('weather')
fb.upload_shared_table('weather', records, columns)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a possibility that students querying the weather table will get nothing because it's been deleted but not re-uploaded? Is this a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If someone happens to be looking at the table when the script is run (once per day), then yes I think they will see nothing for a fraction of a second. But then the new data will pop in automatically when the new table is uploaded. To me that doesn't seem like a big deal, especially for v1, but what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

✔️ ^ I agree. Since it auto-populates, it's not a big deal.

Copy link
Contributor

Choose a reason for hiding this comment

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

✔️ ^ I agree. Since it auto-populates, it's not a big deal.

@ajpal ajpal requested a review from a team as a code owner December 18, 2019 18:35
@ajpal ajpal changed the base branch from staging-next to staging December 18, 2019 18:35
Copy link
Contributor

@jmkulwik jmkulwik left a comment

Choose a reason for hiding this comment

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

LGTM!

@ajpal ajpal closed this Jan 7, 2020
@ajpal ajpal reopened this Jan 8, 2020
"cats",
"dogs",
"states",
"weather",
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you intend to keep weather?

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!

@ajpal ajpal merged commit 0785903 into staging Jan 13, 2020
@ajpal ajpal deleted the dec2-weather branch January 13, 2020 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants