Template:Component Search: Difference between revisions

From Deez Nuts' Sword Coast Campaign
Jump to navigation Jump to search
Harvest DB: add the RunQuery results template — builds a Cargo query from the search form's filters
 
Harvest DB: FLOOR the summed quantity so Banked renders as an integer
 
Line 1: Line 1:
<includeonly>{{#cargo_query:tables=HarvestComponents=C,HarvestLog=L
<includeonly>{{#cargo_query:tables=HarvestComponents=C,HarvestLog=L
|join on=C.component=L.component
|join on=C.component=L.component
|fields=C.component=Component,SUM(L.quantity)=Banked,C.creature=Source,C.rarity=Rarity,C.cv=CV,C.effects=Effect tags,C.effect=Description,C.primary_for=Primary for,C.contributor_to=Contributor to
|fields=C.component=Component,FLOOR(SUM(L.quantity))=Banked,C.creature=Source,C.rarity=Rarity,C.cv=CV,C.effects=Effect tags,C.effect=Description,C.primary_for=Primary for,C.contributor_to=Contributor to
|where=(L.outcome IN ('Recovered','Spent') OR L.quantity=0){{#if:{{{effects|}}}| AND ({{#ifeq:{{{match|Any}}}|All|{{#arraymap:{{{effects|}}}|,|@@@@|(C.effects HOLDS '@@@@')|AND}}|{{#arraymap:{{{effects|}}}|,|@@@@|(C.effects HOLDS '@@@@')|OR}}}})|}}{{#if:{{{rarity|}}}| AND C.rarity IN ({{#arraymap:{{{rarity|}}}|,|@@@@|'@@@@'|,}})|}}{{#if:{{{usable_for|}}}| AND ((C.primary_for HOLDS '{{{usable_for}}}') OR (C.contributor_to HOLDS '{{{usable_for}}}'))|}}
|where=(L.outcome IN ('Recovered','Spent') OR L.quantity=0){{#if:{{{effects|}}}| AND ({{#ifeq:{{{match|Any}}}|All|{{#arraymap:{{{effects|}}}|,|@@@@|(C.effects HOLDS '@@@@')|AND}}|{{#arraymap:{{{effects|}}}|,|@@@@|(C.effects HOLDS '@@@@')|OR}}}})|}}{{#if:{{{rarity|}}}| AND C.rarity IN ({{#arraymap:{{{rarity|}}}|,|@@@@|'@@@@'|,}})|}}{{#if:{{{usable_for|}}}| AND ((C.primary_for HOLDS '{{{usable_for}}}') OR (C.contributor_to HOLDS '{{{usable_for}}}'))|}}
|group by=C.component
|group by=C.component

Latest revision as of 02:39, 13 September 2026

Results template for the Component Search form (via Special:RunQuery, embedded on Find Components). Builds a Cargo query over HarvestComponents joined to HarvestLog from the form's filters:

  • effects — comma list of tags; match = Any (default) or All, assembled into HOLDS clauses with #arraymap. The connectives are unspaced between parenthesized clauses on purpose — parser-function arguments are whitespace-trimmed.
  • rarity — comma list, becomes an IN (…).
  • usable_for — one item type, matched against both primary_for and contributor_to.
  • bankedYes limits to components with net banked quantity > 0; otherwise every known component shows with its quantity (0 = known but not held).