Skip to content

Fbe.regularly ignores a configured p_since_days when p_every_days is not also set #633

Description

@morphqdd

What Happens

Fbe.regularly (lib/fbe/regularly.rb, lines 38-60) looks up the project's PMP fact for a given area with a query constrained to also require the interval property (p_every_days) to exist:

pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.first
interval = pmp.nil? ? 7 : pmp[p_every_days].first
...
days = pmp.nil? || pmp[p_since_days].nil? ? 28 : pmp[p_since_days].first
since = Time.now - (days * 24 * 60 * 60)

If a project configures only the since window (for example qos_days) and leaves the interval property (qos_interval) unset, pmp comes back nil because the exists clause in the query never matches, and days silently falls back to the hardcoded default of 28, even though the actual qos_days value is sitting on that same fact and Fbe.pmp reads it without any trouble. Adding the unrelated qos_interval property to the same fact is what makes the since lookup start working, which is the confusing part.

I confirmed this with two factbases:

  • A pmp fact for area quality carrying only qos_days = 99: Fbe.regularly used since = 28 days ago, while Fbe.pmp.quality.qos_days correctly returned 99.
  • The same fact with qos_interval = 3 added: Fbe.regularly then used since = 99 days ago, as expected.

Related, same root cause: when pmp is nil at all, regularly.rb and repeatedly.rb (line 41) fall back to hardcoded 7 days / 24 hours instead of consulting the defaults already declared in assets/pmp.xml. On an empty factbase, Fbe.regularly('integration', 'eva_interval') runs every 7 days while Fbe.pmp.integration.eva_interval (reading the same pmp.xml default) says 10.

Steps to Reproduce

fb = Factbase.new
f = fb.insert
f.what = 'pmp'
f.area = 'quality'
f.qos_days = 99
Fbe.regularly(fb: fb, area: 'quality', p_every_days: 'qos_interval', p_since_days: 'qos_days') { |f2| f2.since }
# => Time.now - 28*24*60*60, instead of Time.now - 99*24*60*60

What Should Happen

The PMP lookup should not require p_every_days to exist in order to read p_since_days (and vice versa) — each configured property should be honored independently of whether the other one is also set.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions