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

Issue 1655 moment moods cleanup #1674

Merged
merged 6 commits into from
Feb 24, 2020
Merged

Conversation

leeacto
Copy link
Contributor

@leeacto leeacto commented Feb 21, 2020

Description

Removes Moment#mood column and works with the join table relation instead.
There's a lot of shared code and metaprogramming related to strategies and categories. Since the old field was named mood (singular) and the proper relation is moods, there is some code based around mood being examined. When other models get properly related, the conditional statements will go away.


Reviewing this pull request? Check out our Code Review Practices guide if you haven't already!

julianguyen
julianguyen previously approved these changes Feb 21, 2020
Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

LGTM. We can ignore the Code Climate warnings for now. I think we should be able to clean things up once this cleanup PR is merged.

@julianguyen
Copy link
Member

Looks like you'll want to rebase and resolve some conflicts before we merge.

@@ -3,10 +3,10 @@ module CommonMethods
extend ActiveSupport::Concern

def mood_names_and_slugs
return unless attribute(:mood)
return unless self.class.reflect_on_association(:moods)
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@@ -26,9 +26,10 @@ def viewable?(item)
def get_data_type(model_object, data_type)
data = []
model_object.select do |item|
next unless item[data_type].any? && viewable?(item)
objs = data_type == 'moods' ? item.moods.pluck(:id) : item[data_type]
Copy link
Member

@julianguyen julianguyen Feb 22, 2020

Choose a reason for hiding this comment

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

We should eventually extract this into helper and generalize this for categories and strategies. This can be handled in a subsequent PR.

@@ -0,0 +1,5 @@
class DropMomentsMoodColumn < ActiveRecord::Migration[5.2]
def change
remove_column :moments, :mood
Copy link
Member

Choose a reason for hiding this comment

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

Likely won't be a big deal, but dropping a column can cause exceptions during deployment until the app is rebooted. If we want to avoid that, it's recommended that we queue up two migrations and deploy them separately.

Copy link
Member

Choose a reason for hiding this comment

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

Ooh great point!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh I see. Thanks for the link.

@julianguyen
Copy link
Member

I think this should be safe to merge!

@leeacto leeacto merged commit 03ac167 into master Feb 24, 2020
@delete-merged-branch delete-merged-branch bot deleted the issue-1655-moment-moods-cleanup branch February 24, 2020 18:53
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.

3 participants