Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

708 return #1083

Merged
merged 1 commit into from
Jan 9, 2015
Merged

708 return #1083

merged 1 commit into from
Jan 9, 2015

Conversation

squidgetx
Copy link
Contributor

Resolves #708 and includes #1071 so be sure to merge that one first

@orenyk
Copy link
Contributor

orenyk commented Jan 5, 2015

Attempting to visit /reservations gives me the following:

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS reservations  WHERE (start_date = '2015-01-05 05:00:00') AND (due_date >= '20' at line 2: SELECT COUNT(*) FROM (SELECT `reservations`.* FROM `reservations`  WHERE (`reservations`.`start_date` BETWEEN '2014-12-29' AND '2015-01-05') UNION
               SELECT `reservations`.* FROM `reservations`  WHERE (`reservations`.`due_date` BETWEEN '2014-12-29' AND '2015-01-05') AS reservations  WHERE (start_date = '2015-01-05 05:00:00') AND (due_date >= '2015-01-05 05:00:00') AND (checked_out IS NULL) AND (checked_in IS NULL) AND (approval_status = 'auto' OR approval_status = 'approved')

And the problem is in app/views/reservations/index.html.erb:6

Is this a MariaDB issue? I'm not familiar with the AS syntax in SQL.

@orenyk
Copy link
Contributor

orenyk commented Jan 5, 2015

Looks like it might have to do with how you're using the #count method? It appears to be calling it as a column, not as the actual record count. Not 100% sure what's going on.

@squidgetx
Copy link
Contributor Author

fixed by simply adjusting the scope and text to include reservations that begin in the date range instead of ending in it. it's too bad rails doesn't have a UNION operator for active record; it looks like my monkey patch direct-sql wasn't going to fly anyway.

@orenyk
Copy link
Contributor

orenyk commented Jan 7, 2015

Tested locally, looks pretty good although I might recommend having the total numbers in the filter buttons / headings (e.g. Returned (241/5121)) so that it's clear that it's just a subset. I still have to read through the code, will do that tomorrow.

@default = false
# if no filter is defined
return unless @reservations_set.nil?
@default = true if AppConfig.first.request_text.empty?
Copy link
Contributor

Choose a reason for hiding this comment

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

What was this?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, you should do a pull (or depending on how old your branch is, delete and re-pull because I rebased off master)

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I meant what does the request text have anything to do with it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait that's old code. And yes. I hope I didnt break anything but what would the resevation index method have anything to do with request text??

Copy link
Contributor

Choose a reason for hiding this comment

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

Ha I think it's a major typo from when I was cleaning up the Reservations controller for rubocop (see 05212fa). I'm not sure where it came from!

@orenyk
Copy link
Contributor

orenyk commented Jan 7, 2015

Alright, the code looks good. I'd still recommend updating the filter button text to include the total counts, otherwise nice job!

@squidgetx
Copy link
Contributor Author

The only issue with that is that (at least on my 1366px monitor) it doesn't really fit lol. The total counts are reflected by the date selector, which was my compromise; I also think it's a little confusing. Thoughts?

@squidgetx
Copy link
Contributor Author

wow the build passed!

latest changes include some more refactoring since I realized the entire @default variable was useless as well as the addition of a 'view all' option if the admin doesn't want to filter dates

@orenyk
Copy link
Contributor

orenyk commented Jan 7, 2015

What about a multiline label? Something like

Upcoming
(12/152)

or something along those lines? I know it's a little clunky but otherwise the counts are really confusing, I think.

@orenyk
Copy link
Contributor

orenyk commented Jan 7, 2015

The total count isn't correct anymore, it's just saying 17 of 17 reservations begin between the specified dates, etc.

<div id="date_range" class="row">
<div class="span2">
<h4>Filter By Date:</h4>
<p><%= filter_message(@reservations_set, @filter, @view_all) %></p>
Copy link
Contributor

Choose a reason for hiding this comment

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

should you be using @reservations_source instead?

@squidgetx
Copy link
Contributor Author

Ok, I'll fix that in a sec.

What if we just remove the counts completely from the buttons? @mnquintana?

@orenyk
Copy link
Contributor

orenyk commented Jan 8, 2015

Hmmm... we could remove the counts from the buttons, but maybe we could have them show up on mouseover? I guess they're not critical, but it would be nice to have them somewhere.

@mnquintana
Copy link
Contributor

Hmmm those really shouldn't be buttons at all – they should be tabs or pills: http://getbootstrap.com/2.3.2/components.html#navs

(The benefit of pills is that they can be vertically stacked, which might be necessary to make them fit)

EDIT: Looking at it more I feel like vertically stacked pills/tabs in the left-hand column under the "Filter By Date" box might be the way to go

<%= render :partial => "reservations_list", locals: {reservations_set: @reservations_set} %>
</div>
</div>

Copy link
Contributor

Choose a reason for hiding this comment

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

One too many newlines here

@mnquintana
Copy link
Contributor

screenshot 2015-01-08 08 11 52
or

screenshot 2015-01-08 08 18 06

(I think the second one looks better)

@orenyk
Copy link
Contributor

orenyk commented Jan 8, 2015

That makes so much more sense! Agreed about the second one, navigation skills are a higher priority than date selection. @squidgetx, how does it look to you?

@squidgetx
Copy link
Contributor Author

Finished!

@orenyk
Copy link
Contributor

orenyk commented Jan 8, 2015

I'll quickly review later and will let you know when we can squash / merge :-)

@mnquintana
Copy link
Contributor

One last thing - @squidgetx can you make the parentheticals (e.g. (100/6789)) Bootstrap badges?

@mnquintana
Copy link
Contributor

I think visually it would work better if you made the active tab badge .badge-info and the others just .badge – blue is more of a highlight color than gray IMO, so it would emphasize that tab being "active".

@mnquintana
Copy link
Contributor

Also, the spacing is a little tight – I think you could safely make that a .span3 column.

(It won't look as good, but it's very possible that the badge could overlap "Checked Out" if any of the numbers are big enough – mine almost are)

<%= form_tag update_index_dates_path, method: :put do %>
<%= hidden_field_tag "list[filter]", @filter %>
<%= label_tag :start_date, 'Begin' %>
<%= text_field "list", "start_date", class: "date_start_no_min span2", value: @start_date.strftime('%m/%d/%Y') %>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these look a little less awkward in the wider column if you change them to span3

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, even though they'll be long for dates it will still fit with the rest of the column.

@mnquintana
Copy link
Contributor

Alright, looks good! Just make that one change and we should be good to squash and merge.

@orenyk
Copy link
Contributor

orenyk commented Jan 9, 2015

Looks good to me too. The only thing I can think of is if you want to add a few extra tests for any of the methods you wrote? Nominally these would have been written in advance, but it can't hurt to expand our test suite a little :-). Up to you!

@orenyk orenyk mentioned this pull request Jan 9, 2015
@@ -0,0 +1,3 @@
.count {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class is redundant – Bootstrap already provides a .pull-right utility class for this! 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I thought there might be something like that

Implement date filtering for reservations#index method
as well as general refactoring of the #index method
and controller tests for added functionality

basic functionality

prettify frontend

fix test

fix rubocop offenses

rubocop2 and spec

rubocop3

bs typo

bs typo

simplify scope

adjust scope

remove confusing comment

refactor + rubocop

fix spec

fix bugs with default views

add view all button

cop

routes and typo

remove @default from spec

fix filter message

implement table and links for eq objects

rubocop offenses

badges

refactor bad smells

cosmetic changes

rubocop

fix span of date boxes

tests

fix tests

remove unnecessary class
@squidgetx
Copy link
Contributor Author

Definitely should add tests for new functionality

squidgetx added a commit that referenced this pull request Jan 9, 2015
@squidgetx squidgetx merged commit c732aac into master Jan 9, 2015
@mnquintana mnquintana deleted the 708_return branch February 20, 2015 13:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List of returned reservations crashes browser
3 participants