I have daily totals being saved with persistence, I am looking for a clean way of totaling up values over a period such as last 7 days, last 30 days, so far this year, etc. Any pointers?
Have you tried PersistenceExtensions.sumSince?
No side I did not see it on the Wiki.
<item>.persist - Persists the current state
<item>.lastUpdate - Query for the last update timestamp of a given item.
<item>.historicState(AbstractInstant) - Retrieves the state of the item at a certain point in time
<item>.changedSince(AbstractInstant) - Checks if the state of the item has (ever) changed since a certain point in time
<item>.updatedSince(AbstractInstant) - Checks if the state of the item has been updated since a certain point in time
<item>.maximumSince(AbstractInstant) - Gets the maximum value of the state of the item since a certain point in time
<item>.minimumSince(AbstractInstant) - Gets the minimum value of the state of the item since a certain point in time
<item>.averageSince(AbstractInstant) - Gets the average value of the state of a given item since a certain point in time.
<item>.deltaSince(AbstractInstant) - Gets the difference value of the state of a given item since a certain point in time.
<item>.previousState(AbstractInstant) - Retrieves the previous state of the item.
<item>.previousState(AbstractInstant, true) - Retrieves the previous state of the item, skips equal state values and searches the first state not equal the current state
So is the wiki not up to date or is sumSince only part of 1.8 or 2? I don’t see it when I <ctrl><space>
in designer for 1.7.1.
I looked for this at one point and couldn’t find it.
@sipvoip, until sumSince is available (assuming it isn’t already), the best option may be to figure out how to directly query the DB from within your rules. The rrd4j site has an example which might be enough to get someone started.
Another yuckier solution would be to keep a running total in an Item but the amount of bookkeeping required will be massive.
It was committed on master before 1.7.1 was tagged, but it’s not merged into 1.7 branch. I’d think it would be available in the 1.8.0-SNAPSHOT persistence addon. I can’t answer the other questions. Maybe @teichsta can comment.
The commit…
Very cool!!! Works well, it looks like it was added June 28th. Just tested in 1.8-SNAP and it works great!!! Thanks @steve1
so we don’t have any further issue, right?
No issue, updated wiki.