-
Notifications
You must be signed in to change notification settings - Fork 2
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
Migrates to using an enum to indicate what type of status you receive #4
base: master
Are you sure you want to change the base?
Conversation
@@ -1,6 +1,6 @@ | |||
source 'http://rubygems.org' | |||
|
|||
ruby '2.5.3' | |||
ruby '~> 2.5.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to compile every patch of ruby for every different project, so just moved this to any 2.5.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn’t know this worked!
mongoid (7.0.2) | ||
activemodel (>= 5.1, < 6.0.0) | ||
mongoid (5.4.0) | ||
activemodel (~> 4.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, this goes back 2 versions - blocker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for sure. Don’t downgrade mongoid. Something’s off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just revert Gemfile.lock
and bundle without a bundle update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like mongoid-enum hasn't been maintained.
I had opened thetron/mongoid-enum#39 a while ago. Emailed the maintainer now. You should probably just use a String
field for now.
field :is_bot, type: Boolean, default: false | ||
enum :status, %i[unsubscribed emoji] # , :github] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum :status, [:unsubscribed, :emoji]
feels like what I'm actually doing IMO, but I'm not gonna fight rubocop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rubocop -a ; rubocop --auto-gen-config
"ruby.useLanguageServer": true, | ||
"ruby.intellisense": "rubyLocate", | ||
"ruby.codeCompletion": "rcodetools" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets vscode jump between all in-app code
….g. emoji or not. To allow extra status update types
|
||
belongs_to :team, index: true | ||
validates_presence_of :team | ||
|
||
index({ user_id: 1, team_id: 1 }, unique: true) | ||
index(user_name: 1, team_id: 1) | ||
|
||
scope :with_emoji, -> { where(emoji: true, :access_token.ne => nil) } | ||
scope :with_emoji, -> { where(status_type: 'emoji', :access_token.ne => nil) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be status:
or the field should be status_type
no? Needs a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use a symbol or the enum, not a string.
def emoji_count? | ||
!emoji_count.nil? || emoji_count == 0 | ||
def not_updating_status? | ||
status == :unsubscribed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe :off
is better than unsubscribe, nbd.
case emoji_count | ||
when 0 then 'No Emoji' | ||
else "#{emoji_count} Emoji" | ||
if using_emoji_status? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turn this into
case status
when :off
when :emoji
else
end
This way you don't need those helpers like using_emoji_status?
. Those will proliferate.
e.g. emoji or not. This means more status update types can be built from that.
Accepting this would automatically unsubscribe folks from emoji updates, so maybe worth migrating anyone with emoji set up to be
status: "_emoji"
in their Mongo documents.Irony that in grabbing the docs for this mongoid enum, I found that you had wrote a ruby enum too. Will comment inline on a few other unrelated changes.