Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

This is fun! #11

Merged
merged 1 commit into from Mar 22, 2013

Conversation

Projects
None yet
2 participants

New features to review with new pull requests every day?!

Anyways, the key here is I wanted to use ActiveRecord::Relation to keep the duplication down. When you do something like Athlete.where(:affiliate => 'southie') - Rails will just create an ActiveRecord::Relation object, and not actually hit the database. Then, you can use this object to chain on more conditions, all with never hitting the database. The database will finally be queried once you start to iterate over the results, which usually isn't until the view.

@mikepmunroe mikepmunroe added a commit that referenced this pull request Mar 22, 2013

@mikepmunroe mikepmunroe Merge pull request #11 from davekaro/master
keeping duplication down
fd0672b

@mikepmunroe mikepmunroe merged commit fd0672b into mikepmunroe:master Mar 22, 2013

Owner

mikepmunroe commented Mar 22, 2013

Dropping science, I love it!

On Thu, Mar 21, 2013 at 10:36 AM, Dave Kroondyk notifications@github.comwrote:

New features to review with new pull requests every day?!

Anyways, the key here is I wanted to use ActiveRecord::Relation to keep
the duplication down. When you do something like Athlete.where(:affiliate
=> 'southie') - Rails will just create an ActiveRecord::Relation object,
and not actually hit the database. Then, you can use this object to chain
on more conditions, all with never hitting the database. The database will
finally be queried once you start to iterate over the results, which

usually isn't until the view.

You can merge this Pull Request by running

git pull https://github.com/davekaro/games_filter master

Or view, comment on, or merge it at:

#11
Commit Summary

  • a little less duplication for queries.

File Changes

  • M app/controllers/southie_controller.rbhttps://github.com/mikepmunroe/games_filter/pull/11/files#diff-0(16)
  • M app/controllers/wicked_controller.rbhttps://github.com/mikepmunroe/games_filter/pull/11/files#diff-1(20)

Patch Links:

Mike Munroe
software engineer
mike@mikemunroe.com | 978.853.5363
@mikepmunroe http://twitter.com/mikepmunroe | mikemunroe.com

Huh. I just noticed too in the male female conditions you have == where it
should be =. Probably should just change it to a normal where(:gender =>
'Male') instead

On Thursday, March 21, 2013, Mike Munroe wrote:

Dropping science, I love it!

On Thu, Mar 21, 2013 at 10:36 AM, Dave Kroondyk <notifications@github.com<javascript:_e({}, 'cvml', 'notifications@github.com');>

wrote:

New features to review with new pull requests every day?!

Anyways, the key here is I wanted to use ActiveRecord::Relation to keep
the duplication down. When you do something like Athlete.where(:affiliate
=> 'southie') - Rails will just create an ActiveRecord::Relation object,
and not actually hit the database. Then, you can use this object to chain
on more conditions, all with never hitting the database. The database
will
finally be queried once you start to iterate over the results, which

usually isn't until the view.

You can merge this Pull Request by running

git pull https://github.com/davekaro/games_filter master

Or view, comment on, or merge it at:

#11
Commit Summary

  • a little less duplication for queries.

File Changes

Patch Links:

Mike Munroe
software engineer
mike@mikemunroe.com <javascript:_e({}, 'cvml', 'mike@mikemunroe.com');> |
978.853.5363
@mikepmunroe http://twitter.com/mikepmunroe | mikemunroe.com


Reply to this email directly or view it on GitHubhttps://github.com/mikepmunroe/games_filter/pull/11#issuecomment-15275804
.

Owner

mikepmunroe commented Mar 22, 2013

Yep, did that tonight. Just pushed.

Also added the qualified check, but the code is suspect because I did not
test it. The Crossfit Games leaderboard is not loading athlete pages for me
tonight. I tried a bunch and like 1 out of 30 loaded for me, the rest were
coming back as Not Found.

The other fun thing I have spent some time working through tonight is this
bug in Rails, rails/rails#7954 because I screwed up
my initial migration and set the new column type to :bool instead of
:boolean. Puts you into a world of pain. Migrations no longer work. I need
to do the following through sqlite,
http://stackoverflow.com/questions/8442147/how-to-delete-or-add-column-in-sqlite.
A battle to be fought another day.

On Thu, Mar 21, 2013 at 9:31 PM, Dave Kroondyk notifications@github.comwrote:

Huh. I just noticed too in the male female conditions you have == where it
should be =. Probably should just change it to a normal where(:gender =>
'Male') instead

On Thursday, March 21, 2013, Mike Munroe wrote:

Dropping science, I love it!

On Thu, Mar 21, 2013 at 10:36 AM, Dave Kroondyk <
notifications@github.com<javascript:_e({}, 'cvml', '
notifications@github.com');>

wrote:

New features to review with new pull requests every day?!

Anyways, the key here is I wanted to use ActiveRecord::Relation to
keep
the duplication down. When you do something like
Athlete.where(:affiliate
=> 'southie') - Rails will just create an ActiveRecord::Relation
object,
and not actually hit the database. Then, you can use this object to
chain
on more conditions, all with never hitting the database. The database
will
finally be queried once you start to iterate over the results, which

usually isn't until the view.

You can merge this Pull Request by running

git pull https://github.com/davekaro/games_filter master

Or view, comment on, or merge it at:

#11
Commit Summary

  • a little less duplication for queries.

File Changes

Patch Links:

Mike Munroe
software engineer
mike@mikemunroe.com <javascript:_e({}, 'cvml', 'mike@mikemunroe.com');>
|
978.853.5363
@mikepmunroe http://twitter.com/mikepmunroe | mikemunroe.com


Reply to this email directly or view it on GitHub<
https://github.com/mikepmunroe/games_filter/pull/11#issuecomment-15275804>

.


Reply to this email directly or view it on GitHubhttps://github.com/mikepmunroe/games_filter/pull/11#issuecomment-15276558
.

Mike Munroe
software engineer
mike@mikemunroe.com | 978.853.5363
@mikepmunroe http://twitter.com/mikepmunroe | mikemunroe.com

lol at the Rails bug. The wonders of open source. Though, I'd wager you run
into that kind of crap with Microsoft/Oracle products as well... but you
don't have a simple link to an issue thread on github detailing all the
problems/solutions. Open source for the win? You should upgrade to 3.2.13
anyways. And use the same database locally as production. I don't know how
DHH get's away with SQLite in development and MySQL or whatever in prod.
PostgreSQL all the way.

On Thu, Mar 21, 2013 at 10:29 PM, Mike Munroe notifications@github.comwrote:

Yep, did that tonight. Just pushed.

Also added the qualified check, but the code is suspect because I did not
test it. The Crossfit Games leaderboard is not loading athlete pages for
me
tonight. I tried a bunch and like 1 out of 30 loaded for me, the rest were
coming back as Not Found.

The other fun thing I have spent some time working through tonight is this
bug in Rails, rails/rails#7954 because I screwed
up
my initial migration and set the new column type to :bool instead of
:boolean. Puts you into a world of pain. Migrations no longer work. I need
to do the following through sqlite,

http://stackoverflow.com/questions/8442147/how-to-delete-or-add-column-in-sqlite.

A battle to be fought another day.

On Thu, Mar 21, 2013 at 9:31 PM, Dave Kroondyk notifications@github.comwrote:

Huh. I just noticed too in the male female conditions you have == where
it
should be =. Probably should just change it to a normal where(:gender =>
'Male') instead

On Thursday, March 21, 2013, Mike Munroe wrote:

Dropping science, I love it!

On Thu, Mar 21, 2013 at 10:36 AM, Dave Kroondyk <
notifications@github.com<javascript:_e({}, 'cvml', '
notifications@github.com');>

wrote:

New features to review with new pull requests every day?!

Anyways, the key here is I wanted to use ActiveRecord::Relation to
keep
the duplication down. When you do something like
Athlete.where(:affiliate
=> 'southie') - Rails will just create an ActiveRecord::Relation
object,
and not actually hit the database. Then, you can use this object to
chain
on more conditions, all with never hitting the database. The
database
will
finally be queried once you start to iterate over the results, which

usually isn't until the view.

You can merge this Pull Request by running

git pull https://github.com/davekaro/games_filter master

Or view, comment on, or merge it at:

#11
Commit Summary

  • a little less duplication for queries.

File Changes

Patch Links:

Mike Munroe
software engineer
mike@mikemunroe.com <javascript:_e({}, 'cvml', 'mike@mikemunroe.com');>

|
|
|


Reply to this email directly or view it on GitHub<

https://github.com/mikepmunroe/games_filter/pull/11#issuecomment-15275804>

.


Reply to this email directly or view it on GitHub<
https://github.com/mikepmunroe/games_filter/pull/11#issuecomment-15276558>

.

Mike Munroe
software engineer
mike@mikemunroe.com | 978.853.5363
@mikepmunroe http://twitter.com/mikepmunroe | mikemunroe.com


Reply to this email directly or view it on GitHubhttps://github.com/mikepmunroe/games_filter/pull/11#issuecomment-15278023
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment