I'm trying to get a template modified to pull data from essentially $span(week_delta=1). There's two sections in the template, one a valuesCard(), the other is chartCard(). The logic of the template goes like this:
<main>
<div class="container-fluid d-flex-xxl">
<div class="row my-4 temprow align-content-start">
#for $x in $Extras.Appearance.values_order
#if $x == "ET"
#if $span(week_delta=1).ET.has_data and $span(week_delta=1).ET.sum.raw is not None and $span(week_delta=1).ET.sum.raw > 0.0
$valuesCard('ET')
#end if
#else
$valuesCard($x)
#end if
#end for
</div>
<hr class="my-4 rowdivider">
<div class="row mt-5 mb-4 graphrow align-content-start">
#for $x in $Extras.Appearance.charts_order
#if $x == "ET"
#if $week.ET.has_data and $week.ET.sum.raw is not None and $week.ET.sum.raw > 0.0
$chartCard($x, $x + 'chart')
#end if
#else
$chartCard($x, $x + 'chart')
#end if
#end for
</div>
</div>
</main>
The charts code runs a for loop that uses
#for $record in $span($week_delta=1).spans(interval=current_interval)
But the valuesCard does not. Everything is referenced via some form of $getVar('week.' + name + '.aggregation'). Here's the code:
#def valuesCard($name)
#if $getVar('week.' + name + '.has_data')
#if $name == specific thing
...
#else
<div class="row">
<div class="col-3 text-muted font-small lo-text">
$getVar('week.' + name + '.min') <br>
($getVar('week.' + name + '.mintime').format($Extras.Formatting.datetime))
</div>
<div class="col-6">
<h4 class="h2-responsive">$getVar('week.' + name + '.avg')</h4>
</div>
<div class="col-3 text-muted font-small hi-text">
$getVar('week.' + name + '.max') <br>
($getVar('week.' + name + '.maxtime').format($Extras.Formatting.datetime))
</div>
</div>
for any of the 'specific thing' items, I can hardcode $span(week_delta=1).obs.aggregation. But the #else block will not evaluate using $span, or $timespan via a specific '#set timespan = $span(week_delta=1)' within the def block. $week(weeks_ago=1) doesn't do what I want in terms of trailing 7 days, but even that one wasn't getting it done when I went to just make a second template for lastweek.html.tmpl.... I've tried doing $getattr("$timespan", "$name").agg without success, as well as stripping the quotes to just be $getattr($timespan, $name).agg, stil without success.
Is there a simple enough way to run a template that will pull values from a $span() timeframe, without individually coding every observation?