Chitter - Eleanor CS#218
Conversation
|
|
||
|
|
||
| <% @peeps.each do |peep| %> | ||
| <div class="Peeps" style="border: 3px solid aqua; width:fit-content; width:-webkit-fit-content; width:-moz-fit-content;"> |
There was a problem hiding this comment.
The styling would be better placed in a css file I reckon, especially given that this code will repeat on every iteration of the loop.
| </div> | ||
| <% end %> | ||
|
|
||
| <form action="/peeps/reverse" method="get"> |
There was a problem hiding this comment.
Love that this is a button (I did mine the lazy way!)
|
|
||
| result = connection.exec("SELECT * FROM peeps;") | ||
| result.map do |peep| | ||
| row_to_peep(peep) |
There was a problem hiding this comment.
This line being refactored into its own method is nice
| @entry_date = entry_date | ||
| end | ||
|
|
||
| def self.open_connection |
There was a problem hiding this comment.
It's possible to refactor this into its own class and have an always on db connection while the app is running. There's a walkthrough on how to do this in Ex.15 on the Bookmark task.
| def self.reverse_chronology | ||
| connection = open_connection | ||
|
|
||
| result = connection.exec("SELECT * FROM peeps ORDER BY entry_date DESC;") |
There was a problem hiding this comment.
Oh interesting, I did this with a .reverse method on the array.
There was a problem hiding this comment.
Which approach is more computationally efficient? How would you test it?
|
|
||
| def self.filter(filter) | ||
| connection = open_connection | ||
| result = connection.exec("SELECT * FROM peeps WHERE lower(message) LIKE '%#{filter.downcase}%';") |
There was a problem hiding this comment.
Using downcase on everything is better than what I did
| Peeps.create(message: 'Second test peep!', entry_date: "2021-02-15") | ||
|
|
||
| visit ('/peeps') | ||
| fill_in('filter', with: 'peep') |
There was a problem hiding this comment.
Given that both test peeps contain the word 'peep' maybe another word could have been used to test the filter function, such as 'Second'? Even better would be 'second' as then you test your downcase code as well.
|
|
||
| click_button "View Newest First" | ||
|
|
||
| page.body.index("2021-03-18").should < page.body.index("2021-02-15") |
There was a problem hiding this comment.
I have never seen page.body.index before. Nice.
| @@ -0,0 +1,2 @@ | |||
| <h1> Welcome to Chitter! </h1> | |||
| <img src="https://gl.audubon.org/sites/default/files/styles/hero_mobile/public/aud_apa-2020_barn-swallow_a1-11258-1_nape_photo-xianwei-zeng.jpg?itok=aTU-t6nJ" alt="Chitter Birds"> No newline at end of file | |||
There was a problem hiding this comment.
Maybe this picture could link to your /peeps page?
| require 'sinatra/base' | ||
| require './lib/peeps' | ||
|
|
||
| class Chitter < Sinatra::Base |
There was a problem hiding this comment.
You could probably delete this test route.
| 'Test page' | ||
| end | ||
|
|
||
| get '/' do |
There was a problem hiding this comment.
these are generally good RESTful routes – nice work!
You could consider ways of combining the routes for all the requests that show multiple Peeps but, then again, you could also make the argument that such an approach would break SRP.
|
This is a really nice solution that clearly hits all the learning objectives. Great work 👍 |
Your name
Please write your full name here to make it easier to find your pull request.
User stories
Please list which user stories you've implemented (delete the ones that don't apply).
README checklist
Does your README contains instructions for
Here is a pill that can help you write a great README!