This question about Using an extension: Asked

Filter metadata according to time criteria

I'm trying to render metadata filtering the records according to date and time, namely I would like to show only the current "valid" ones, i.e. t_start <= t_now <= t_end.

The time window are stored in following fields:
  • StartDatum
  • StartZeit
  • EndDatum
  • EndZeit

It looks an easy task, but I don't come up with the right syntax.

Inspired by https://foswiki.org/Support/Question1283 I tried this:

%RENDERMETADATA{
  "..."
  topic="%BASEWEB%.%BASETOPIC%"
  header="..."
  format="Start: $StartDatum $StartZeit Ende: $EndDatum $EndZeit"
  separator="..."
  footer=".."
  filter="$percntCALC{\"$TIME("StartDatum StartZeit")\"}$percnt <= %CALC{$TIME("%SERVERTIME{$Year $Month $Day $Hour $Minute}%")}% and $percntCALC{\"$TIME("EndDatum EndZeit")\"}$percnt >= %CALC{$TIME("%SERVERTIME{$Year $Month $Day $Hour $Minute}%")}%" 
}%

It doesn't filter anything, probably because it too early evaluates $TIME("StartDatum StartZeit"), i.e. = 0 I tried many variations for delay the evaluation, through $dollar, $$dollar or "\". It would be nice to have compressed syntax like d2n for IF or DBQUERY (I also tried the latter BTW).

Thank you very much in advance.

-- IgorGiunta - 15 Dec 2016

Can you provide the form definition for this specific meta data?

-- MichaelDaum - 15 Dec 2016

Of course:
| *Name*  | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* |
| ThurgisChange | label | | VirtuelleServerWartung | | H |
| ID | id | 4 | | | H |
| <nop>Kennzeichnung | text | 40 | | | M |
| <nop>TopicTitle | autofill | 1  | header="VirtuelleServerWartungItem" source="ID, Kennzeichnung" separator=":" | | H |
| <nop>StartDatum  | date | 20  | %SERVERTIME{"$day $Mon $year"}%  | | |
| <nop>StartZeit  | time | 20  | %SERVERTIME{"$hour $minute"}%  | | |
| <nop>EndDatum  | date  | 20  | %SERVERTIME{"$day $Mon $year"}%  | | |
| <nop>EndZeit  | time | 20  | %SERVERTIME{"$hour $minute"}%  | | |
| <nop>Auswirkungen | textarea | 80x4 | - | | |
| <nop>ReferenzAnChange | select2+multi | 40 | , %SEARCH{ "ThurgisChange~'InfrastrukturChange'" nosearch="on" type="query" nototal="on" separator=", " format="[[$web.$topic][$percntTOPICTITLE{$topic}$percnt]]"}% | |
| <nop>AuswirkungsReichweite | radio | 10 | -, lokal, TGZ, AGI, extern | - | |
| <nop>Status | label | 1 |  $percntQUERY{META:WORKFLOW.name}$percnt | automatisch vom Ablauf übernommen |
| <nop>Erfassungsdatum  | date  | 20  | %SERVERTIME{"$day $Mon $year"}%  | | |
| <nop>Verantwortliche | select2 | 15  | , %SEARCH{"TopicType~'ThurgisZustaendige'" nosearch="on" type="query" nototal="on" separator=", " format="$topic"}%  | Verantwortliche  | |

PS: just tried without "\<nop\>" in the parameter name -> same result

-- IgorGiunta - 21 Dec 2016

any idea how to go on? Thank you and happy new year - by the way

-- IgorGiunta - 03 Jan 2017

Did you try this:
filter="d2n(StartDatum StartZeit) <= d2n('%SERVERTIME{$Year $Month $Day $Hour $Minute}%') AND d2n(EndDatum EndZeit) >= d2n('%SERVERTIME{$Year $Month $Day $Hour $Minute}%')"
From my reading of MetaDataPlugin documentation, since it states that the filter parameter performs a QuerySearch, it would seem that this should work.

-- LynnwoodBrown - 03 Jan 2017

It returns
Error: Missing operator in ''TGZ.VirtuellesServerItem0052'/META:VIRTUELLESERVERWARTUNG[d2n(StartDatum StartZeit) <= d2n('2017 Jan 03 17 46') AND d2n(EndDatum EndZeit) >= d2n('2017 Jan 03 17 46')].name' at ' <= d2n('2017 Jan 03 17 46') AND d2n(EndDatum EndZeit) >= d2n('2017 Jan 03 17 46')].name'

the RENDERMETADATA is within a ViewTemplate. May be this the cause?

-- IgorGiunta - 03 Jan 2017

I wish I had some sample data to play with to help you figure this out. I doubt that the issue is that the RENDERMETA macro is in ViewTemplate. Did you try placing macro inside of <noautolink> tag? It kind of looks to me like it's not properly interpreting the filter.

-- LynnwoodBrown - 03 Jan 2017

see Email

-- IgorGiunta - 04 Jan 2017
 

QuestionForm edit

Subject Using an extension
Extension MetaDataPlugin
Version Foswiki 2.0.3
Status Asked
Related Topics
Topic revision: r8 - 04 Jan 2017, IgorGiunta
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy