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

A Bunch of Banadies (Phoebe, Mary, Abinnet, Mariko) - Ampers #17

Open
wants to merge 487 commits into
base: master
Choose a base branch
from

Conversation

marikoja
Copy link

bEtsy

Congratulations! You're submitting your assignment! These comprehension questions should be answered by all members of your team, not by a single teammate.

Comprehension Questions

Question Answer
How did your team break up the work to be done? We broke up the work using trello. We would check in during stand-up or while working next to each other to make sure we were not doing duplicate work. We tried to rotate responsibilities as much as we could.
How did your team utilize git to collaborate? We used branches and checked git log.
What did your group do to try to keep your code DRY while many people collaborated on it? We added trello cards for pieces of code that needed to be refactored.
What was a technical challenge that you faced as a group? One major challenge was figuring out how to code the cart functionality and how to debug Heroku.
What was a team/personal challenge that you faced as a group? Our first team merge attempt. Talking about how we might implement the cart before.
What could your team have done better? We could have done more designing before coding. We also could have implemented more controller tests before coding the controllers. We could have also done more routing planning instead of just using resources. In general, more design before coding.
What was your application's ERD? (include a link) https://www.lucidchart.com/documents/edit/9e22397f-1df9-4bb5-a414-c86697ca215b/0
What is your Trello URL? https://trello.com/b/d6Po3Y1l/betsy
What is the Heroku URL of your deployed application? https://fruetsy.herokuapp.com/

mmlamkin and others added 30 commits April 23, 2018 17:29

describe "index" do
it "redirects to root path if user is not a merchant" do
user = nil
Copy link

Choose a reason for hiding this comment

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

this line just makes a local variable named user and assigns the value to it as nil-- this doesn't affect the app at all

Think about what you're trying to test here and how you would make the "user" in the app not-exist... or "logged out"

@@ -0,0 +1,341 @@
/*! normalize.css v8.0.0 | MIT License | github.com/necolas/normalize.css */
Copy link

Choose a reason for hiding this comment

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

Why is this file here?

flash[:status] = :success
flash[:result_text] = "#{@user.name} logged in successfully"
session[:uid] = @user.uid
session[:user_id] = @user.id
Copy link

Choose a reason for hiding this comment

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

There's a lot of setting on session the values uid and user_id, and from what I can tell, it's mostly that the code didn't conform to using one or the other, even though they represent the same thing. You'll prevent bugs and confusion if you conform to one standard here!

def create
auth_hash = request.env['omniauth.auth']
if auth_hash['uid']
@user = User.find_by(uid: auth_hash[:uid], provider: 'github')
Copy link

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 make user an instance variable in this method

@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
Copy link

Choose a reason for hiding this comment

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

Interesting, I'm not sure what this does


<% if flash[:result_text] or flash[:messages] %>
<section class="callout <%= flash[:status] %>">
<p><%= flash[:status] == :failure ? "A problem occurred: " : "" %><%= flash[:result_text] %></>
Copy link

@tildeee tildeee May 7, 2018

Choose a reason for hiding this comment

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

I think you meant to close a paragraph tag instead of </>?

paid_items << item
end
end
return paid_items
Copy link

Choose a reason for hiding this comment

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

Code like this works, but you could definitely make this so much shorter with using enumerables methods!

def order_item_paid(order_items)
  return order_items.select { |item| item.status == 'paid' }
end

and for the rest of the methods below this!

if @user
@order_items = OrderItem.where(order_id: @order.id)
else
product_ids = @user.products.map{ |i| i.id }
Copy link

Choose a reason for hiding this comment

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

When would the code ever get into this branch?

If @user is falsey (is nil) and gets into this else block, why would we be able to call product_ids = @user.products.map{ |i| i.id }?

if @user
else
@user = User.find(1)
end
Copy link

Choose a reason for hiding this comment

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

try cleaner code style, like

if !@user
  @user = User.find(1)

end

def index
@user = User.find_by(id: params[:user_id])
Copy link

Choose a reason for hiding this comment

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

@user doesn't need to be an instance variable in this case. Variables only need to be instance variables (with the @) in rails when you need to share that variable between the Controller and the View... since the value of user isn't important for the products#index, you can just assume it's safe as a local variable

end
if @product
@product.order_items.each do |i|
i.destroy
Copy link

Choose a reason for hiding this comment

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

I normally would personally discourage using variable names like i and r, but it's pretty clear in this context what it means.

return User.new(uid: auth_hash[:uid], provider: auth_hash[:provider], email: auth_hash[:info][:email], name: auth_hash[:info][:nickname])
end

MERCHANT_PICS = ['https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-4.jpg', 'https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-26.jpg', 'https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-27.jpg', 'https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-28.jpg', 'https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-29.jpg', 'https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-30.jpg', 'https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-34.jpg', 'https://www.icreativeideas.com/wp-content/uploads/2014/08/Creative-Animals-Made-of-Fruits-And-Vegetables-32.jpg']
Copy link

Choose a reason for hiding this comment

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

I like declaring my constants at the top of the file!

@tildeee
Copy link

tildeee commented May 7, 2018

bEtsy

What We're Looking For

Feature Feedback
Baseline
Appropriate Git Usage with all members contributing x
Answered comprehension questions x
Trello board is created and utilized in project management x
Heroku instance is online x
General
Nested routes follow RESTful conventions there are a bunch of routes around /order that go to the sessions controller? otherwise, looks great
oAuth used for User authentication x
Functionality restricted based on user roles x
Products can be added and removed from cart x
Users can view past orders x
Merchants can add, edit and view their products x
Errors are reported to the user x
Order Functionality
Reduces products' inventory x
Cannot order products that are out of stock x
Changes order state x
Clears current cart x
Database
ERD includes all necessary tables and relationships don't have access to your ERD :(
Table relationships x
Models
Validation rules for Models x
Business logic is in the models x, making categories didn't seem to work?
Controllers
Controller Filters used to DRY up controller code used a little bit...
Testing
Model Testing I tried updating my name on my merchant profile to an empty string "". It said it was a successful update but I don't see that change saved. I think there are a lot of missing model tests for custom model logic
Controller Testing mostly
Session Testing There is SO much logic in your SessionsController and no tests for it!
SimpleCov at 90% for controller and model tests 90.42%
Front-end
The app is styled to create an attractive user interface x
Content is organized with HTML5 semantic tags x
CSS is DRY x
Overall

Only the person who submitted the PR will get an email about this feedback. Please let the rest of your team know about it.

Overall fruEtsy is a pretty successful app; I didn't come across any major broken features. It has a lot of features and it's clear there was a lot of work, coordination, styling, etc that was put into it

The code is quite a thing to look through!

I have one major specific comment on one specific piece of code:
I am really struggling to understand what the method make_order_items in OrderItem is doing. Is it okay to assume that the key of every key/value pair you iterate through in a hash is going to be a valid product_id to give an order item? or that every value in that hash is going to be a valid quantity?
I tried to find unit tests for this method to help me understand it but I couldn't...

This block of code to me signals some big warning signs for me: the more that this code base grows, the more obscure code like this will be. Developers in the future will ask: What does this mean? Does it have to be this way? Could I make it better? But there are no tests, how can I be sure that it isn't broken?

Overall, I saw a fair bit of messiness in the code: there were a lot of unused local variables, a lot of duplicated code, a lot of unused methods, etc. ... These things added up, and end up creating a small cloud of confusion in the code. I know a lot of the feedback you all gave in your comprehension questions was around needing more design to be discussed in the beginning. A lot of my comments focused on smaller questions about code style and code quality, and I think that really working on that too will be really beneficial as well.

That being said, this is an ambitious project and you all pulled through. Good work

(random comments: The merchant images of the snail orange and banana dolphins and stuff are very cute....... the rating bananas are so weird (and cute)......)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants