-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Prevent name collision for teams #83
Open
leechou
wants to merge
12
commits into
slack-ruby:master
Choose a base branch
from
leechou:prevent-name-collision-for-Teams
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b082ba9
added namespace for Team
leechou 0da7fda
Allow customization of ActiveRecord table name
leechou b3b8e1f
modified specs to work with ActiveRecord
leechou 0e71544
fixed console script
leechou db9a303
fixed rubocop offenses
leechou 535e505
Fixed problem with not recognizing table
leechou 388c520
update docs
leechou 57040ad
changed the variable that saves the table name to Config.teams[:name]
leechou 77d8ce5
updated docs
leechou c59cc1f
missed some changes
leechou 08af36b
fixed rubocop offenses
leechou b765e9e
Fixed docs
leechou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ In the examples below, substitute your Github username for `contributor` in URLs | |
|
||
Fork the [project on Github](https://github.com/slack-ruby/slack-ruby-bot-server) and check out your copy. | ||
|
||
``` | ||
```bash | ||
git clone https://github.com/contributor/slack-ruby-bot-server.git | ||
cd slack-ruby-bot-server | ||
git remote add upstream https://github.com/slack-ruby/slack-ruby-bot-server.git | ||
|
@@ -20,7 +20,7 @@ git remote add upstream https://github.com/slack-ruby/slack-ruby-bot-server.git | |
|
||
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. | ||
|
||
``` | ||
```bash | ||
git checkout master | ||
git pull upstream master | ||
git checkout -b my-feature-branch | ||
|
@@ -30,11 +30,25 @@ git checkout -b my-feature-branch | |
|
||
Ensure that you can build the project and run tests. | ||
|
||
``` | ||
```bash | ||
export DATABASE_ADAPTER=activerecord | ||
bundle install | ||
bundle exec rake | ||
``` | ||
|
||
## Run Tests | ||
|
||
Run tests before making changes and then run tests after major commits. | ||
Make sure to test both ActiveRecord and Mongoid. | ||
|
||
```bash | ||
export DATABASE_ADAPTER=activerecord | ||
bundle install | ||
bundle exec rspec | ||
``` | ||
|
||
Test the sample apps | ||
|
||
## Write Tests | ||
|
||
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. | ||
|
@@ -64,21 +78,21 @@ Make it look like every other line, including your name and link to your Github | |
|
||
Make sure git knows your name and email address: | ||
|
||
``` | ||
```bash | ||
git config --global user.name "Your Name" | ||
git config --global user.email "[email protected]" | ||
``` | ||
|
||
Writing good commit logs is important. A commit log should describe what changed and why. | ||
|
||
``` | ||
```bash | ||
git add ... | ||
git commit | ||
``` | ||
|
||
## Push | ||
|
||
``` | ||
```bash | ||
git push origin my-feature-branch | ||
``` | ||
|
||
|
@@ -91,7 +105,7 @@ Click the 'Pull Request' button and fill out the form. Pull requests are usually | |
|
||
If you've been working on a change for a while, rebase with upstream/master. | ||
|
||
``` | ||
```bash | ||
git fetch upstream | ||
git rebase upstream/master | ||
git push origin my-feature-branch -f | ||
|
@@ -107,7 +121,7 @@ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical ent | |
|
||
Amend your previous commit and force push the changes. | ||
|
||
``` | ||
```bash | ||
git commit --amend | ||
git push origin my-feature-branch -f | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
require_relative 'methods' | ||
|
||
class Team < ActiveRecord::Base | ||
include Methods | ||
module SlackRubyBotServer | ||
class Team < ActiveRecord::Base | ||
self.table_name = SlackRubyBotServer::Config.teams[:name] | ||
|
||
def self.purge! | ||
# destroy teams inactive for two weeks | ||
Team.where(active: false).where('updated_at <= ?', 2.weeks.ago).each do |team| | ||
puts "Destroying #{team}, inactive since #{team.updated_at}, over two weeks ago." | ||
team.destroy | ||
include Methods | ||
|
||
def self.purge! | ||
# destroy teams inactive for two weeks | ||
SlackRubyBotServer::Team.where(active: false).where('updated_at <= ?', 2.weeks.ago).each do |team| | ||
puts "Destroying #{team}, inactive since #{team.updated_at}, over two weeks ago." | ||
team.destroy | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
require_relative 'methods' | ||
|
||
class Team | ||
include Mongoid::Document | ||
include Mongoid::Timestamps | ||
module SlackRubyBotServer | ||
class Team | ||
include Mongoid::Document | ||
include Mongoid::Timestamps | ||
|
||
field :team_id, type: String | ||
field :name, type: String | ||
field :domain, type: String | ||
field :token, type: String | ||
field :active, type: Boolean, default: true | ||
field :team_id, type: String | ||
field :name, type: String | ||
field :domain, type: String | ||
field :token, type: String | ||
field :active, type: Boolean, default: true | ||
|
||
include Methods | ||
include Methods | ||
|
||
def self.purge! | ||
# destroy teams inactive for two weeks | ||
Team.where(active: false, :updated_at.lte => 2.weeks.ago).each do |team| | ||
Mongoid.logger.info "Destroying #{team}, inactive since #{team.updated_at}, over two weeks ago." | ||
team.destroy | ||
def self.purge! | ||
# destroy teams inactive for two weeks | ||
SlackRubyBotServer::Team.where(active: false, :updated_at.lte => 2.weeks.ago).each do |team| | ||
Mongoid.logger.info "Destroying #{team}, inactive since #{team.updated_at}, over two weeks ago." | ||
team.destroy | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sample_apps/sample_app_activerecord/db/migrate/20170307164946_create_teams_table.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 say
SlackRubyBotServer
notSlackRubyBot
, right?Also, I could be wrong, but I think this might not work for MongoDB because it might change the name of the collection to something like
slack_ruby_bot_server_team
, that needs to be tested, so I suggest you actually do the change for mongodb as part of this PR, too.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.
ya, my bad. I'll get that changed.
Sure, I can test out MongoDB, but it might take a while though.