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

Jmw/week util methods #12

Merged
merged 5 commits into from
Jun 5, 2017
Merged

Jmw/week util methods #12

merged 5 commits into from
Jun 5, 2017

Conversation

jonworek
Copy link
Contributor

I've added a few helper methods that allow me to get a start/end date for a given merch week. I need this to query AA's actualized data api for the rof.

Our UI uses merch weeks/months/quarters, and AA's API likes date ranges.

@coveralls
Copy link

coveralls commented May 31, 2017

Coverage Status

Coverage increased (+0.2%) to 96.517% when pulling a876092 on jmw/week-util-methods into 6f35274 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 96.517% when pulling a876092 on jmw/week-util-methods into 6f35274 on master.

@coveralls
Copy link

coveralls commented May 31, 2017

Coverage Status

Coverage increased (+0.2%) to 96.517% when pulling 3f46c13 on jmw/week-util-methods into 6f35274 on master.

@coveralls
Copy link

coveralls commented May 31, 2017

Coverage Status

Coverage increased (+0.2%) to 96.517% when pulling 3f46c13 on jmw/week-util-methods into 6f35274 on master.

end

def end_of_week(year, month, merch_week)
start_of_week(year, month, merch_week) + 6

Choose a reason for hiding this comment

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

What's the 6 about? Can we define/name magic numbers please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lol, you should see the rest of this file beyond just this small diff. One might say I was keeping consistent with the style of the code around it 😉

But, point taken. I can do better. Will address.

def start_of_week(year, month, merch_week)
weeks = MerchCalendar.weeks_for_month(year, month)

week = weeks.find { |week| week.week == merch_week }

Choose a reason for hiding this comment

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

This is a bit smelly. Do you have any other ideas how to go about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Digging through the code, MerchCalendar::MerchWeek.find(2017, 4, 1) will give the same result. So it'll clean this up here, though that code is doing something similar.

* remove magic number
* use pre-existing method to locate merch week
@coveralls
Copy link

coveralls commented Jun 1, 2017

Coverage Status

Coverage increased (+0.2%) to 96.517% when pulling 3905eb1 on jmw/week-util-methods into 6f35274 on master.

@jonworek
Copy link
Contributor Author

jonworek commented Jun 1, 2017

After digging through the code a little bit more and discovering some new methods that I didn't know existed, I don't think this PR holds as much value as when I started out.

But, I still think the convenience I've added is nice. @davidamcclain are you willing to give a 👍 ?

@jonworek jonworek merged commit f98aeb8 into master Jun 5, 2017
@jonworek jonworek deleted the jmw/week-util-methods branch June 5, 2017 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants