-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fire - Roshni and Pauline - Slack CLI #6
base: master
Are you sure you want to change the base?
Conversation
…l.rb, output should be hash rather than returnable
…clarification line in slack.rb to reprint menu after every action, added sleep to get in recipient in case of infinite loop
…workspace select_channel test
…ackApiError calls in send_message
…ests that have thankfully passed
…share in details, completed adjusting user_test, started adjusting workspace_test
…to current_bot field
…d send_message to account for new parameters
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.
Excellent job! There were some small things I called out in the comments but overall your solution was really strong.
You did an extremely good job of turning the UML diagrams we gave you into a coherent set of classes that all work well together and have clearly defined responsibilities. 😃
Slack CLI
Major Learning Goals/Code Review
Criteria | yes/no, and optionally any details/lines of code to reference |
---|---|
Practices best practices working with APIs. The .env is not checked into git, and no API token was directly used in the Ruby code without ENV . |
✔️ |
Practices error handling with APIs. For all pieces of code that make an API call, it handles API requests that come back with errors/error status codes appropriately. | ✔️ |
Implements inheritance and inheritance idioms. There is a Recipient class. User and Channel inherit from Recipient . In Recipient , there are appropriate methods defined that are used in both User and Channel . Some may be implemented. Some may be template methods. |
✔️ |
Practices clean code. lib/slack.rb only interacts with Workspace to show a separation of responsibilities. Complex logic is broken into smaller helper methods. |
✔️ |
Practices instance methods vs. class methods appropriately. The methods to list all Channels or Users is likely a class method within those respective classes. | ✔️ |
Practices best practices for testing. The project has and uses VCR mocking when running tests, and can run offline. | ✔️ |
Practices writing tests. The User , Channel , and Workspace classes have unit tests. |
✔️ |
Practices writing tests. There are tests for sending messages (the location of these tests may differ, but is likely in Recipient ) |
✔️ |
Practices git with at least 15 small commits and meaningful commit messages | ✔️ |
Functional Requirements
Functional Requirement | yes/no |
---|---|
As a user of the CLI program, I can list users and channels | ✔️ |
As a user of the CLI program, I can select users and channels | ✔️ |
As a user of the CLI program, I can show the details of a selected user or channel | ✔️ |
As a user of the CLI program, when I input something inappropriately, the program runs without crashing | ✔️ |
Overall Feedback
Overall Feedback | Criteria | yes/no |
---|---|---|
Green (Meets/Exceeds Standards) | 7+ in Code Review && 3+ in Functional Requirements | ✔️ |
Yellow (Approaches Standards) | 6+ in Code Review && 2+ in Functional Requirements | |
Red (Not at Standard) | 0-5 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging |
Code Style Bonus Awards
Was the code particularly impressive in code style for any of these reasons (or more...?)
Quality | Yes? |
---|---|
Perfect Indentation | ✅ |
Elegant/Clever | ✅ |
Descriptive/Readable | ✅ |
Concise | ✅ |
Logical/Organized | ✅ |
# we don't want to break the program here because the reason | ||
# could be anything | ||
raise SlackApiError, "Error: #{response.parsed_response['error']}. Please try again" | ||
return false |
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.
You don't need to return false
here. The raise
will make sure this line never runs.
url = 'https://slack.com/api/auth.test' | ||
query = {token: Bot.token} | ||
sleep(0.5) | ||
response = HTTParty.get(url, query: query)['user_id'] |
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.
You should check the response code of this request.
|
||
def self.list_all | ||
bots = super | ||
bots = bots.filter{ |user| user.is_bot || user.slack_id == "USLACKBOT"} |
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.
Nice touch filtering out the bot users.
end | ||
|
||
def details | ||
tp self, :slack_id, :name, :topic, :member_count |
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.
You should leave the actual printing of things up to slack.rb
. (This is why your unit tests print out tables in the middle.)
url = "https://slack.com/api/conversations.list" | ||
param = {token: Channel.token} | ||
raw_channels = Channel.get(url, param)['channels'] | ||
all_channels = raw_channels.map do |channel| |
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.
Nice use of map
!
|
||
attr_reader :real_name, :time_zone, :is_bot | ||
|
||
def initialize(slack_id:, name:, real_name:, time_zone: "Pacific Daylight Time", is_bot: false) |
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.
Configurable timezones! 🎉
raw_users = User.get(url, param)['members'] | ||
all_users = [] # to skip over deleted users | ||
raw_users.each do |member| | ||
next if member['deleted'] |
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 really like your attention to detail with skipping bad entries like this.
end | ||
end | ||
end | ||
return nil # returns nil to indicate user not found |
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 might raise a UserNotFoundError
instead of returning nil
.
You can forget to check for a nil
return value but you notice right away if you got an exception.
# NOTE: We didn't write a test to check whether the token is valid because that has already been tested in the | ||
# .get method in Recipient.rb from which it inherits, meaning it should work here too for channel.rb |
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.
Nice documentation! 😃
message = "" | ||
4005.times do | ||
message += "A" | ||
end |
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.
Ruby actually has built in syntax for this (for some reason):
message = "" | |
4005.times do | |
message += "A" | |
end | |
message = "A" * 4005 |
Assignment Submission: Slack CLI
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection