Conversation
Travis alerted that the build of the application broke because of some mistakes inside gemfile like double instances of gems. The file were changed and submited to a PR evaluation.
All the files listed were changed according with the rubocop code evaluation, mostly for methods with many code lines and process time.
For Travis build changes, the test regarding user model were updated to use the new area/sub_area attributes instead of the priority type.
All the files listed were changed according with the rubocop code evaluation automaticaly.
The user file were modified to update the priority attribute with the new area/sub_area.
For refactor purpose about CodeClimate evaluation, the add_filter_elements method inside overview_points were changed to use only 4 parameters, not including now the index variable.
There was a problem hiding this comment.
@Pedro-Pezoa valeuu man pelo fix! Fiz algumas sugestões pra ti, confere elas aí!
| end | ||
|
|
||
| def month_finished?(day) | ||
| def month_finished?(_day) |
There was a problem hiding this comment.
Se o day não é usado, ele nem precisaria ser passado aqui não?
| @@ -98,8 +97,7 @@ def am_filter(user_id, index, first, type) | |||
| when 'CS' | |||
| [index, fetch_contract_sum_with_ids(user_id, first.id)] | |||
| when 'CP' | |||
There was a problem hiding this comment.
Quase ninguém mais usa case/when em ruby, até acho estranho o rubocop não ter se ofendido com isso.
https://www.rubyguides.com/2015/10/ruby-case/ artigo maneiro sobre quando usar ou não.
Uma ideia pra melhorar isso seria:
filter =
case init_filter(type)
when 'CS'
fetch_contract_sum_with_ids(user_id, first.id)
when 'CP'
(calculate_contract_percentage * 100).round(1)
when 'CC'
fetch_contracts_by_user_report_id(user_id, first.id)
when 'FC'
fetch_deal_sum_with_ids(user_id, first.id)
end
[index, filter]Aliás, se tu perceber o index não atua dentro do método e sim, ele simplesmente entra e sai sem participar de nenhuma ação. Maybe ele nem precisaria entrar nesse método ;)
E first talvez não seja um nome de argumento tão bom, ele não me dá muito contexto quando vejo só o método ;D
| index += 1 | ||
| end | ||
|
|
||
| list << verify_filter_option(user.id, index, first, type) |
There was a problem hiding this comment.
Se no método de verificação não precisasse passar o index esse método ficaria:
list << [index, verify_filter_option(user.id, first, type)]
| @@ -82,11 +82,13 @@ def int_to_weekday(date) | |||
| return 'Tuesday' if date.tuesday? | |||
There was a problem hiding this comment.
Esse método pode ser melhorado, usando um hash, ou procurando outras alternativas no ActiveSupport ou no próprio ruby...
date.strftime('%A')
=> 'Monday'There was a problem hiding this comment.
No caso se esse for o objetivo do método mesmo, ele nem precisaria existir ;)
There was a problem hiding this comment.
https://github.com/trustvox/sales_up/pull/24/files#diff-809770723468cbce0793eda96affafcfR76
Tu poderia apenas usar:
(@first_date..@last_date).collect { |date| date.strftime('%A') }There was a problem hiding this comment.
E além disso, existe uma gem chamada https://github.com/bokmann/business_time que pode ser realmente útil se você precisa fazer mais do que apenas saber quais dias são dias úteis ou não!
| contract.day = Time.current.day | ||
| contract.report_id = fetch_last_report('am').id | ||
| def create_contract | ||
| create_contract_helper |
There was a problem hiding this comment.
Helper no rails tem outra finalidade, ele geralmente lida com recursos de view ex:
form_tag e text_input, t, l por exemplo são helpers. Seria bacana você dar um novo nome para estes métodos.
| @@ -0,0 +1,89 @@ | |||
| module IntegrationHelper | |||
There was a problem hiding this comment.
Evite usar nomes genéricos demais, pois isso dificulta o entendimento na medida que o sistema cresce!
| end | ||
|
|
||
| def fetch_contract_ids | ||
| @contract.report_id = fetch_last_report('am').id |
There was a problem hiding this comment.
vejo essas siglas por todo o canto, já pensou se fosse necessário alterá-la?
| area == 'sales' | ||
| end | ||
|
|
||
| def admin? |
There was a problem hiding this comment.
Bora mover esses métodos de uma linha para um concern?
| context 'instance methods' do | ||
| describe '#regular?' do | ||
| let(:priority) { 1 } | ||
| describe '#overall_manager?' do |
There was a problem hiding this comment.
Você concorda que faltam mais testes por aqui?
There was a problem hiding this comment.
Destes métodos de uma linha no caso ;)
| @@ -1,3 +1,3 @@ | |||
| ZapierRuby.configure do |c| | |||
| c.web_hooks = {example_zap: "xxxxxxx/yyyyyy" } | |||
| c.web_hooks = { example_zap: 'xxxxxxx/yyyyyy' } | |||
There was a problem hiding this comment.
Esse arquivo está sendo utilizado?
|
@Pedro-Pezoa só acho que tu misturou duas coisas nesse PR, a de alteração da prioridade dos usuários e a correção do Travis! Na próxima a gente divide cada um no seu quadrado! :D |
Travis alerted that the build of the application broke because of some mistakes inside gemfile like double instances of gems. The file were changed and submited to a PR evaluation.