Skip to content

Resolves #55: rpt by site#112

Open
glroman wants to merge 6 commits into
rubyforgood:masterfrom
glroman:issue-55-RptBySite
Open

Resolves #55: rpt by site#112
glroman wants to merge 6 commits into
rubyforgood:masterfrom
glroman:issue-55-RptBySite

Conversation

@glroman
Copy link
Copy Markdown
Contributor

@glroman glroman commented Jan 1, 2017

After many delays (travel, death in family, holidays) I'm finally done with this. I rearranged the input fields and added a header to indicate which site (or "All Sites") the report is for. Tests look for this. Please take a look; thanks.

@bjmllr
Copy link
Copy Markdown
Member

bjmllr commented Jan 2, 2017

Thanks for working on this!

It looks like Travis is failing on the style check. Most of the issues that it reported are auto-correctable, so a bundle exec rubocop -a should clear those up. After that, I think the only style issues left would be relating to method lengths, so the prescription would be extract method or extract class refactoring.

Copy link
Copy Markdown
Collaborator

@leesharma leesharma left a comment

Choose a reason for hiding this comment

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

Hooray, nice PR! 🎉 It'll be really nice to have this feature in the app.

It looks like the build is passing now, but I added a few comments and suggestions. Let me know if you have any questions or disagree with anything!

<img src="<%= event.signature %>"
style="width: 15em;
padding: 2px;
border: 3px solid #069;" /> </td>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice! Can this be turned into a CSS class?

Comment thread app/reports/signatures_report.rb Outdated
.order(:occurred_at)
end

def pull_join(site_id = 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Our database is zero-indexed, so site_id = 0 might be a valid site. I'd set the fallback to -1 or something similar so that all valid sites are reachable.


class SignaturesReportsController < ApplicationController
before_action :authenticate_user!
expose(:work_sites) do
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Manipulating arrays of tuples isn't a common practice in ruby (code tends to be very object oriented and method-focused), so I worry that having this in the main body of the controller will be confusing down the line. I know that the select box takes this format for its input, but can we isolate this so that it doesn't get tangled up in the the rest of the application logic?

Since it's basically a scope on WorkSite, maybe something like this?

class WorkSite
  # ...
  def select_box_input
    fallback = ['All Sites', -1] # see justification for -1 in another comment
    addresses = where(active: true).order(:address).pluck(:address, :id) # like your #map, but at the db level
    addresses.unshift fallback
  end
end

It's not a perfect solution (there's still some array manipulation going on later in the controller), but this provides a clear place for the tuple-related code to live and discourages mingling.

@glroman
Copy link
Copy Markdown
Contributor Author

glroman commented Jan 9, 2017

Lee, thank you very much for the feedback. I've made the changes you recommended, but I must point out that using zero as a legitimate database id violates database best practices. Ids are expected (by database geeks like me at least) to be positive integers.

@bjmllr
Copy link
Copy Markdown
Member

bjmllr commented Jan 18, 2017

@glroman please take a look at glroman#1 when you get a chance, this should resolve the test failures.

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.

3 participants