Skip to content

Change gemfile for travis pipeline#24

Open
Pedro-Pezoa wants to merge 6 commits intomasterfrom
spec_tests
Open

Change gemfile for travis pipeline#24
Pedro-Pezoa wants to merge 6 commits intomasterfrom
spec_tests

Conversation

@Pedro-Pezoa
Copy link
Copy Markdown
Collaborator

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.

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.
@Pedro-Pezoa Pedro-Pezoa self-assigned this Mar 8, 2019
@Pedro-Pezoa Pedro-Pezoa requested a review from brunoocasali March 8, 2019 14:46
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.
Copy link
Copy Markdown
Contributor

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

@Pedro-Pezoa valeuu man pelo fix! Fiz algumas sugestões pra ti, confere elas aí!

end

def month_finished?(day)
def month_finished?(_day)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Esse método pode ser melhorado, usando um hash, ou procurando outras alternativas no ActiveSupport ou no próprio ruby...

date.strftime('%A')
=> 'Monday'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No caso se esse for o objetivo do método mesmo, ele nem precisaria existir ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

https://github.com/trustvox/sales_up/pull/24/files#diff-809770723468cbce0793eda96affafcfR76

Tu poderia apenas usar:

(@first_date..@last_date).collect { |date| date.strftime('%A') }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

vejo essas siglas por todo o canto, já pensou se fosse necessário alterá-la?

area == 'sales'
end

def admin?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Você concorda que faltam mais testes por aqui?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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' }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Esse arquivo está sendo utilizado?

@brunoocasali
Copy link
Copy Markdown
Contributor

@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

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.

2 participants