Http://projects.theforeman.org/issues/8402 - Reports from the last xx days not appearing

Hey All,

I'm trying to resolve this problem as its directly affecting me, but I
can't work out what's causing it.

The summary from the bug report says "When looking at any host, there is
the option to limit the days or reports seen - from the install this has
not been visible. There were issues with certain config setting set to 0,
so this may be related to that (Bug #8294: Warning! Infinity - Foreman)

Reports from the last <blank> days - 199 reports found"

So, what I've tried is moving the database and deleting /etc/foreman &
/etc/foreman-proxy folders. Removing the following RPM packages

foreman-proxy-1.7.1-1.el6.noarch
foreman-cli-1.7.1-1.el6.noarch
foreman-selinux-1.7.1-1.el6.noarch
foreman-release-scl-1-1.el6.x86_64
foreman-1.7.1-1.el6.noarch
rubygem-hammer_cli_foreman-0.1.3-1.el6.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2-1.el6.noarch
foreman-installer-1.7.1-1.el6.noarch
foreman-postgresql-1.7.1-1.el6.noarch
ruby193-rubygem-foreman_setup-2.1.1-1.el6.noarch

and running the foreman-installer again so it sets up everything again.

Even once it did this and fresh reports start to come in, the same issue
still exists - so this tells me #1 its not in the database, #2 the issues
were were experience in issue 8294 were not present on the initial install.

So my questions is where does it get the value for the Reports
(/usr/share/foreman/app/helpers/hosts_helper.rb ?) and how does it actually
calculate the value %{days}… does not value not exist in the database?
host.reports.first.reported_a? I'm using foreman as reporting only.

def reports_show
> return unless @host.reports.size > 0
> form_tag @host, :id => 'days_filter', :method => :get, :class => "form
> form-inline" do
> content_tag(:span, (_("Reports from the last %{days} days - %{count}
> reports found") %
> { :days => select(nil, 'range',
> 1…days_ago(@host.reports.first.reported_at),
> {:selected => @range}, {:class=>"col-md-1
> form-control", :style=>"float:none;", :onchange
> =>"$('#days_filter').submit();$(this).disabled();"}),
> :count => @host.reports.recent(@range.days.ago).count
> }).html_safe)
> end
> end

I'm not a Ruby person, but can learn so if someone can give me some
assistance perhaps I can troubleshoot/resolve this myself?

Cheers
David

> Hey All,
>
> I'm trying to resolve this problem as its directly affecting me, but I
> can't work out what's causing it.
>
> The summary from the bug report says "When looking at any host, there is
> the option to limit the days or reports seen - from the install this has
> not been visible. There were issues with certain config setting set to
> 0, so this may be related to that
> (Bug #8294: Warning! Infinity - Foreman)
>
> Reports from the last <blank> days - 199 reports found"
>
>
> So, what I've tried is moving the database and deleting /etc/foreman &
> /etc/foreman-proxy folders. Removing the following RPM packages
>
> foreman-proxy-1.7.1-1.el6.noarch
> foreman-cli-1.7.1-1.el6.noarch
> foreman-selinux-1.7.1-1.el6.noarch
> foreman-release-scl-1-1.el6.x86_64
> foreman-1.7.1-1.el6.noarch
> rubygem-hammer_cli_foreman-0.1.3-1.el6.noarch
> ruby193-rubygem-foreman_bootdisk-4.0.2-1.el6.noarch
> foreman-installer-1.7.1-1.el6.noarch
> foreman-postgresql-1.7.1-1.el6.noarch
> ruby193-rubygem-foreman_setup-2.1.1-1.el6.noarch
>
> and running the foreman-installer again so it sets up everything again.
>
> Even once it did this and fresh reports start to come in, the same issue
> still exists - so this tells me #1 its not in the database, #2 the
> issues were were experience in issue 8294 were not present on the
> initial install.

#8294 and #7579 are interesting ones. We merged a change into
foreman-installer 1.7.1 that I am hoping was the fix for them, but I'm
still listening out for any more recent reports to disprove the theory.

> So my questions is where does it get the value for the Reports
> (/usr/share/foreman/app/helpers/hosts_helper.rb ?) and how does it
> actually calculate the value %{days}… does not value not exist in the
> database? host.reports.first.reported_a? I'm using foreman as reporting
> only.
>
> def reports_show
> return unless @host.reports.size > 0
> form_tag @host, :id => 'days_filter', :method => :get, :class =>
> "form form-inline" do
> content_tag(:span, (_("Reports from the last %{days} days -
> %{count} reports found") %
> { :days => select(nil, 'range',
> 1…days_ago(@host.reports.first.reported_at),
> {:selected => @range}, {:class=>"col-md-1
> form-control", :style=>"float:none;", :onchange
> =>"$('#days_filter').submit();$(this).disabled();"}),
> :count => @host.reports.recent(@range.days.ago).count
> }).html_safe)
> end
> end
>
>
>
> I'm not a Ruby person, but can learn so if someone can give me some
> assistance perhaps I can troubleshoot/resolve this myself?

Debugging this from the console might be easiest. If you "yum install
foreman-console" and then run "foreman-rake console" you get an
interactive Rails/Ruby shell.

First look up your test host:

@host = Host.find_by_name("foo.example.com")

And then try the statement above:

@host.reports.first.reported_at

This should report the date/time of the earliest report, although
looking at it, I'm surprised there's no sorting of reports by date, e.g.
@host.reports.order(:reported_at). It's possible that's the issue.

The code should be working out the number of days since that first
reported_at date, then generating dropdown menu options for each one.

Incidentally, I notice when I only have one day of reports in the
database that the dropdown menu is empty. It sounded like you had more
reports than that in your original bug report though.

Cheers,

··· On 08/01/15 05:17, David LeVene wrote:


Dominic Cleal
Red Hat Engineering

Hi Dominic,

Thanks for the assistance, and you were correct it wasn't ordering what it
was searching for - I've just pushed through my first bug fix
(Bug #8402: Reports from the last xx Days not displaying day filter option - Foreman)

Hopefully its all OK - I've tested it on my live instance and its working
as expected.

I do have a further question about how its generating the SQL statements…

Where are the definitions of "Host.find_by_name" , and the various other
SQL statements found or "generated"?

Cheers
David

··· On Friday, 16 January 2015 02:25:14 UTC+10:30, Dominic Cleal wrote: > > On 08/01/15 05:17, David LeVene wrote: > > Hey All, > > > > I'm trying to resolve this problem as its directly affecting me, but I > > can't work out what's causing it. > > > > The summary from the bug report says "When looking at any host, there is > > the option to limit the days or reports seen - from the install this has > > not been visible. There were issues with certain config setting set to > > 0, so this may be related to that > > (http://projects.theforeman.org/issues/8294) > > > > Reports from the last days - 199 reports found" > > > > > > So, what I've tried is moving the database and deleting /etc/foreman & > > /etc/foreman-proxy folders. Removing the following RPM packages > > > > foreman-proxy-1.7.1-1.el6.noarch > > foreman-cli-1.7.1-1.el6.noarch > > foreman-selinux-1.7.1-1.el6.noarch > > foreman-release-scl-1-1.el6.x86_64 > > foreman-1.7.1-1.el6.noarch > > rubygem-hammer_cli_foreman-0.1.3-1.el6.noarch > > ruby193-rubygem-foreman_bootdisk-4.0.2-1.el6.noarch > > foreman-installer-1.7.1-1.el6.noarch > > foreman-postgresql-1.7.1-1.el6.noarch > > ruby193-rubygem-foreman_setup-2.1.1-1.el6.noarch > > > > and running the foreman-installer again so it sets up everything again. > > > > Even once it did this and fresh reports start to come in, the same issue > > still exists - so this tells me #1 its not in the database, #2 the > > issues were were experience in issue 8294 were not present on the > > initial install. > > #8294 and #7579 are interesting ones. We merged a change into > foreman-installer 1.7.1 that I am hoping was the fix for them, but I'm > still listening out for any more recent reports to disprove the theory. > > > So my questions is where does it get the value for the Reports > > (/usr/share/foreman/app/helpers/hosts_helper.rb ?) and how does it > > actually calculate the value %{days}... does not value not exist in the > > database? host.reports.first.reported_a? I'm using foreman as reporting > > only. > > > > def reports_show > > return unless @host.reports.size > 0 > > form_tag @host, :id => 'days_filter', :method => :get, :class => > > "form form-inline" do > > content_tag(:span, (_("Reports from the last %{days} days - > > %{count} reports found") % > > { :days => select(nil, 'range', > > 1..days_ago(@host.reports.first.reported_at), > > {:selected => @range}, {:class=>"col-md-1 > > form-control", :style=>"float:none;", :onchange > > =>"$('#days_filter').submit();$(this).disabled();"}), > > :count => @host.reports.recent(@range.days.ago).count > > }).html_safe) > > end > > end > > > > > > > > I'm not a Ruby person, but can learn so if someone can give me some > > assistance perhaps I can troubleshoot/resolve this myself? > > Debugging this from the console might be easiest. If you "yum install > foreman-console" and then run "foreman-rake console" you get an > interactive Rails/Ruby shell. > > First look up your test host: > > @host = Host.find_by_name("foo.example.com") > > And then try the statement above: > > @host.reports.first.reported_at > > This should report the date/time of the earliest report, although > looking at it, I'm surprised there's no sorting of reports by date, e.g. > @host.reports.order(:reported_at). It's possible that's the issue. > > The code should be working out the number of days since that first > reported_at date, then generating dropdown menu options for each one. > > Incidentally, I notice when I only have one day of reports in the > database that the dropdown menu is empty. It sounded like you had more > reports than that in your original bug report though. > > Cheers, > > -- > Dominic Cleal > Red Hat Engineering >

Hi David,

Great, thank you!

Those methods are all defined by Ruby on Rails for each model in our
application (a model maps to a table). This is a pretty good guide to
the available methods:
http://guides.rubyonrails.org/active_record_querying.html#retrieving-a-single-object

Cheers,

··· -- Dominic Cleal Red Hat Engineering

On 16/01/15 01:48, David LeVene wrote:

Hi Dominic,

Thanks for the assistance, and you were correct it wasn’t ordering what
it was searching for - I’ve just pushed through my first bug fix
(Bug #8402: Reports from the last xx Days not displaying day filter option - Foreman)

Hopefully its all OK - I’ve tested it on my live instance and its
working as expected.

I do have a further question about how its generating the SQL statements…

Where are the definitions of “Host.find_by_name” , and the various other
SQL statements found or “generated”?

Cheers
David

On Friday, 16 January 2015 02:25:14 UTC+10:30, Dominic Cleal wrote:

On 08/01/15 05:17, David LeVene wrote:
> Hey All,
>
> I'm trying to resolve this problem as its directly affecting me,
but I
> can't work out what's causing it.
>
> The summary from the bug report says "When looking at any host,
there is
> the option to limit the days or reports seen - from the install
this has
> not been visible. There were issues with certain config setting
set to
> 0, so this may be related to that
> (http://projects.theforeman.org/issues/8294
<http://projects.theforeman.org/issues/8294>)
>
> Reports from the last <blank> days - 199 reports found"
>
>
> So, what I've tried is moving the database and deleting
/etc/foreman &
> /etc/foreman-proxy folders. Removing the following RPM packages
>
> foreman-proxy-1.7.1-1.el6.noarch
> foreman-cli-1.7.1-1.el6.noarch
> foreman-selinux-1.7.1-1.el6.noarch
> foreman-release-scl-1-1.el6.x86_64
> foreman-1.7.1-1.el6.noarch
> rubygem-hammer_cli_foreman-0.1.3-1.el6.noarch
> ruby193-rubygem-foreman_bootdisk-4.0.2-1.el6.noarch
> foreman-installer-1.7.1-1.el6.noarch
> foreman-postgresql-1.7.1-1.el6.noarch
> ruby193-rubygem-foreman_setup-2.1.1-1.el6.noarch
>
> and running the foreman-installer again so it sets up everything
again.
>
> Even once it did this and fresh reports start to come in, the same
issue
> still exists - so this tells me #1 its not in the database, #2 the
> issues were were experience in issue 8294 were not present on the
> initial install.

#8294 and #7579 are interesting ones.  We merged a change into
foreman-installer 1.7.1 that I am hoping was the fix for them, but I'm
still listening out for any more recent reports to disprove the theory.

> So my questions is where does it get the value for the Reports
> (/usr/share/foreman/app/helpers/hosts_helper.rb ?) and how does it
> actually calculate the value %{days}... does not value not exist
in the
> database? host.reports.first.reported_a? I'm using foreman as
reporting
> only.
>
>       def reports_show
>         return unless @host.reports.size > 0
>         form_tag @host, :id => 'days_filter', :method => :get,
:class =>
>     "form form-inline" do
>           content_tag(:span, (_("Reports from the last %{days} days -
>     %{count} reports found") %
>             { :days  => select(nil, 'range',
>     1..days_ago(@host.reports.first.reported_at),
>                         {:selected => @range}, {:class=>"col-md-1
>     form-control", :style=>"float:none;", :onchange
>     =>"$('#days_filter').submit();$(this).disabled();"}),
>               :count => @host.reports.recent(@range.days.ago).count
>     }).html_safe)
>         end
>       end
>
>
>
> I'm not a Ruby person, but can learn so if someone can give me some
> assistance perhaps I can troubleshoot/resolve this myself?

Debugging this from the console might be easiest.  If you "yum install
foreman-console" and then run "foreman-rake console" you get an
interactive Rails/Ruby shell.

First look up your test host:

  @host = Host.find_by_name("foo.example.com <http://foo.example.com>")

And then try the statement above:

  @host.reports.first.reported_at

This should report the date/time of the earliest report, although
looking at it, I'm surprised there's no sorting of reports by date,
e.g.
@host.reports.order(:reported_at).  It's possible that's the issue.

The code should be working out the number of days since that first
reported_at date, then generating dropdown menu options for each one.

Incidentally, I notice when I only have one day of reports in the
database that the dropdown menu is empty.  It sounded like you had more
reports than that in your original bug report though.

Cheers,

-- 
Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-users+unsubscribe@googlegroups.com
mailto:foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com
mailto:foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Hi Dominic,

Great - thankyou - you have been very helpful.

Regards
David

··· On Friday, 16 January 2015 18:52:04 UTC+10:30, Dominic Cleal wrote: > > Hi David, > > Great, thank you! > > Those methods are all defined by Ruby on Rails for each model in our > application (a model maps to a table). This is a pretty good guide to > the available methods: > > http://guides.rubyonrails.org/active_record_querying.html#retrieving-a-single-object > > Cheers, > > -- > Dominic Cleal > Red Hat Engineering > >