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
[READY] adding mileage #279
Conversation
Hey, friendly reminder that we all get an email for each issue that hound finds ^^ |
e339a9a
to
62350f0
Compare
apologies for the mails, still cant get rubocop setup correctly to check localy |
No worries :) |
@mischaboldy you can download the Rubocop config file that Hound uses here: https://houndci.com/configuration#ruby |
so everything seems to be working. I still want to rework this to 1 entries table instead of the 2 i've got now and any refactoring tips are appreciated. |
return Hour.find(params[:entry_id]).audits | ||
elsif params[:entry_type] == "mileages" | ||
return Mileage.find(params[:entry_id]).audits | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use constantize for this?
http://apidock.com/rails/Inflector/constantize
If you want to only have one entries table you can do STI (single table inheritance), there is a lot of documentation and guides out there. However, one of the main reasons for wanting to do this is is because you would generally want to Q for all entries. I thought this would be rare as in our use case you'd generally either get all hours or all 'milages', right? |
6130190
to
85f81bb
Compare
Did some refactoring, Still not quite sure how to remove the == "string" everywhere. Suggestions welcome. |
|
||
def edit_entry(new_project, new_mileages, new_date) | ||
click_link I18n.t("navbar.entries") | ||
click_link "edit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n
d2b3cdb
to
4f91c2b
Compare
def entry_type? | ||
if request.fullpath == mileage_entry_path | ||
return true | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the name describes what it does
also this could be a oneliner :)
ec73ecb
to
1db2445
Compare
@@ -4,22 +4,32 @@ class EntriesController < ApplicationController | |||
DATE_FORMAT = "%d/%m/%Y".freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could put this code in two seperate controllers? One for HoursEntries and one for MilesEntries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would mean 2 controllers with very similar code. I chose not to do this to adhere to the DRY rule. It does make the coding more complicated to read and it contains a few horrible if statements. If you think two separate controllers is a better solution then i'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just see a lot of if/else statements which would suggest two seperate controllers would be better, you could also do it with inheritance, put methods like resource
in the parent controller and create method in the child controller.
Other than that looks good |
def to_object(entry_type) | ||
entry_type.singularize.camelize.constantize | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still necessary after you seperated the controllers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still used by two other controllers, billables_controller and reports_controller
ac9abfb
to
1b02597
Compare
Anyone else with comments or suggestions? |
476c975
to
cbe896c
Compare
$(this).addClass('is-active'); | ||
} else { | ||
event.preventDefault(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could change the if and else codeblock, and drop the !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix
83f5ad4
to
df5f660
Compare
@@ -35,4 +26,20 @@ def options | |||
|
|||
CSV::DEFAULT_OPTIONS | |||
end | |||
|
|||
def get_fields(entry, entry_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment Branch Condition size for get_fields is too high. [15.17/15]
merging this to test on staging |
pull request for review