-
Notifications
You must be signed in to change notification settings - Fork 54
Show age on application #584
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
8444749
16fc9fe
fa9d110
e41766f
c602f88
69ac98a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module MembershipApplicationHelper | ||
|
|
||
| def choose_highlight_class(age) | ||
| if age >= 7.weeks && age < 2.months | ||
| "almost-due-highlighted" | ||
| elsif age > 2.months | ||
| "overdue-highlighted" | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,10 @@ def sufficient_votes? | |
| enough_yes || !few_nos | ||
| end | ||
|
|
||
| def age | ||
| Time.now - submitted_at | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is best to move logic out of the templates and into the code here (among other things, so that it can be tested), so I would change this to return the age in days, instead of just a difference between the two dates. Or you could move the computation into a helper. Either way, it would be good to remove it from the template. Also, instead of using your own logic to compute the days, you could use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! I will remove the logic from the template and put it into a helper. I won't change age because it is being used in another helper's calculation as is, but make a new age_in_days variable. Thanks for the tip on Rails Duration - will look into that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in_days doesn't seem to work in the rails console at all. I get an undefined method error.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in_days does not work in the template either. Is there anything I need to do to activate it?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine, you don't need to convert it to |
||
| end | ||
|
|
||
| def self.to_approve | ||
| all.map { |x| x if x.approvable? && x.state == "submitted" }.compact.sort_by { |x| x.submitted_at } | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.