Skip to content
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

Fixes #27331 - Fix pagination on policy dashboard #401

Merged
merged 2 commits into from
Jul 29, 2019

Conversation

xprazak2
Copy link
Contributor

No description provided.

@ares
Copy link
Member

ares commented Jul 23, 2019

rubocop needs some updates, feel free to add additional commit to this PR, I'll merge at once

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • f071d6c must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@ares
Copy link
Member

ares commented Jul 23, 2019

There are still some rubocop failures :-(

Inspecting 109 files
......................C.C..CC............................................C...................................

Offenses:

/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/arf_reports_helper.rb:8:15: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    return if @arf_report.logs.empty?
              ^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/arf_reports_helper.rb:9:30: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    form_tag arf_report_path(@arf_report), :id => 'level_filter', :method => :get, :class => "form form-horizontal" do
                             ^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/arf_reports_helper.rb:17:8: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    if @arf_report && @arf_report.host
       ^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/arf_reports_helper.rb:17:23: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    if @arf_report && @arf_report.host
                      ^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/arf_reports_helper.rb:23:35: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
                    { :caption => @arf_report.host.name,
                                  ^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/arf_reports_helper.rb:24:48: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
                      :url => (arf_report_path(@arf_report) if authorized_for(hash_for_arf_report_path(@arf_report))) }
                                               ^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/arf_reports_helper.rb:24:104: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
                      :url => (arf_report_path(@arf_report) if authorized_for(hash_for_arf_report_path(@arf_report))) }
                                                                                                       ^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/compliance_hosts_helper.rb:16:5: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    @host.arf_reports.of_policy(policy_id).each do |report|
    ^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:3:12: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    return @scap_content.scap_content_profiles if @scap_content.present?
           ^^^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:3:51: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    return @scap_content.scap_content_profiles if @scap_content.present?
                                                  ^^^^^^^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:4:12: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    return @policy.scap_content.scap_content_profiles if @policy.scap_content.present?
           ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:4:58: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    return @policy.scap_content.scap_content_profiles if @policy.scap_content.present?
                                                         ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:71:31: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
               { :selected => @policy.scap_content_profile_id },
                              ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:77:31: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
               { :selected => @policy.scap_content_profile_id,
                              ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:122:5: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    @policy.current_step == step ? 'show-pane' : 'hide-pane'
    ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:128:99: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
      link_to(previous.html_safe, '#', :class => 'btn btn-default', :onclick => "previous_step('#{@policy.previous_step}')")
                                                                                                  ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:141:8: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
    if @policy
       ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:147:35: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
                    { :caption => @policy.name,
                                  ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:148:49: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
                      :url => (edit_policy_path(@policy) if authorized_for(hash_for_edit_policy_path(@policy))) }
                                                ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policies_helper.rb:148:102: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
                      :url => (edit_policy_path(@policy) if authorized_for(hash_for_edit_policy_path(@policy))) }
                                                                                                     ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policy_dashboard_helper.rb:25:24: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
      content_tag(:h4, @report[label])
                       ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policy_dashboard_helper.rb:52:45: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
        _("Hosts no longer assigned: %s") % @report[:unassigned_hosts],
                                            ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/app/helpers/policy_dashboard_helper.rb:53:58: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
        hosts_path(:search => "removed_from_policy = \"#{@policy.name}\"")
                                                         ^^^^^^^
/home/jenkins/workspace/foreman_openscap-pull-request/database/postgresql/label/fast/ruby/2.6/plugin/lib/foreman_openscap/helper.rb:14:8: C: Performance/InefficientHashSearch: Use #key? instead of #keys.include?.
    if Facets.registered_facets.keys.include?(:subscription_facet)RuboCop failed!

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 639e816 must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@@ -11,7 +11,7 @@
<th><%= _("Other") %></th>
<th><%= _('Actions') %></th>
</tr>
<% @policy.arf_reports.latest.each do |arf_report| %>
<% @latest_reports.each do |arf_report| %>
Copy link
Member

Choose a reason for hiding this comment

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

doesn't this reintroduce the behavior changed by #377 ?

Copy link
Contributor Author

@xprazak2 xprazak2 Jul 29, 2019

Choose a reason for hiding this comment

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

It does revert this particular line, but I cannot remember why it was changed in the first place. It should return the same results though as it calls latest scope for the reports belonging to a policy, I added a test. The only difference is @policy.arf_reports.latest gives me undefined method 'total_entries' for #<ForemanOpenscap::ArfReport::ActiveRecord_AssociationRelation:0x007efd8d475b58> so I cannot paginate on that.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 0a49de1 must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@ares
Copy link
Member

ares commented Jul 29, 2019

Thanks make sense, fixes the issue. Merging!

@ares ares merged commit b2a83d0 into theforeman:master Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants