Difference between revisions of "Template:Card query"

From Yugipedia
Jump to: navigation, search
(fix transclusions that don't use {{{type}}} but have a query that can only return nonmonsters (e.g. the query includes `Card type::Spell Card`))
(allow using `extra_column` to force display of otherwise-hidden columns (currently only for Secondary type and Property, since these are the only two such cases at this time, though more can be added in the future))
Line 142: Line 142:
 
}}{{ #ifeq: {{ #var: $cq_card_type }} | monster
 
}}{{ #ifeq: {{ #var: $cq_card_type }} | monster
 
| {{ #vardefine: $cq_col_primary_type | ?Primary type
 
| {{ #vardefine: $cq_col_primary_type | ?Primary type
   }}{{ #vardefine: $cq_col_secondary_type | {{ #ifeq: {{ #ask: {{ #var: $cq_full_query }} [[Secondary type::+]] | format=count }} | 0 || {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}secondary type:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}secondary type::^ }} | ?Secondary type }} | ?Secondary type }} }}
+
   }}{{ #vardefine: $cq_col_secondary_type | {{ #ifeq: {{ #ask: {{ #var: $cq_full_query }} [[Secondary type::+]] | format=count }} | 0 || {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}secondary type:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}secondary type::^ }} | ?Secondary type | {{ #ifeq: {{{extra_column}}} | Secondary type | ?Secondary type }} }} | ?Secondary type }} }}
 
   }}{{ #vardefine: $cq_col_attribute | {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}attribute:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}attribute::^ }} | ?Attribute = [[Attribute]] }} | ?Attribute = [[Attribute]] }}
 
   }}{{ #vardefine: $cq_col_attribute | {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}attribute:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}attribute::^ }} | ?Attribute = [[Attribute]] }} | ?Attribute = [[Attribute]] }}
 
   }}{{ #vardefine: $cq_col_type | {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}type:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}type::^ }} | ?Type = [[Type]] }} | ?Type = [[Type]] }}
 
   }}{{ #vardefine: $cq_col_type | {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}type:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}type::^ }} | ?Type = [[Type]] }} | ?Type = [[Type]] }}
Line 215: Line 215:
 
   }}{{ #vardefine: $cq_col_maximum_atk | {{ #ifeq: {{ #var: $cq_medium }} | rush duel | {{ #ifeq: {{ #ask: {{ #var: $cq_full_query }} [[MAXIMUM ATK::+]] | format=count }} | 0 || ?MAXIMUM ATK#- = [[MAXIMUM ATK]] }} }}
 
   }}{{ #vardefine: $cq_col_maximum_atk | {{ #ifeq: {{ #var: $cq_medium }} | rush duel | {{ #ifeq: {{ #ask: {{ #var: $cq_full_query }} [[MAXIMUM ATK::+]] | format=count }} | 0 || ?MAXIMUM ATK#- = [[MAXIMUM ATK]] }} }}
 
   }}
 
   }}
| {{ #vardefine: $cq_col_property | {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}property:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}property::^ }} | ?Property = [[Property]] }} | ?Property = [[Property]] }}
+
| {{ #vardefine: $cq_col_property | {{ #if: {{ #pos: {{ #var: $cq_query_lc }} | {{!((}}property:: }} | {{ #if: {{ #pos: {{ #var: $cq_query_normalized }} | {{!((}}property::^ }} | ?Property = [[Property]] | {{ #ifeq: {{{extra_column}}} | Property | ?Property = [[Property]] }} }} | ?Property = [[Property]] }}
 
   }}{{ #ifeq: {{ #var: $cq_card_type }} | skill
 
   }}{{ #ifeq: {{ #var: $cq_card_type }} | skill
 
   || {{ #vardefine: $cq_col_card_type_st | {{ #if: {{ #var: $cq_col_card_type }} | {{ #switch: {{ #var: $cq_card_type }} | non-monster | <!-- empty --> = {{ #var: $cq_col_card_type }} [[Card type]] }} }}
 
   || {{ #vardefine: $cq_col_card_type_st | {{ #if: {{ #var: $cq_col_card_type }} | {{ #switch: {{ #var: $cq_card_type }} | non-monster | <!-- empty --> = {{ #var: $cq_col_card_type }} [[Card type]] }} }}
Line 221: Line 221:
 
     }}
 
     }}
 
   }}
 
   }}
}}{{ #vardefine: $cq_col_extra | {{ #if: {{{extra_column|}}} | ?{{{extra_column}}} }}
+
}}{{ #vardefine: $cq_col_extra | {{ #if: {{{extra_column|}}} | {{ #switch: {{{extra_column}}} | Secondary type | Property = | #default= ?{{{extra_column}}} }} }}
 
}}{{ #vardefine: $cq_col_extra_2 | {{ #if: {{{extra_column2|}}} | ?{{{extra_column2}}} }}
 
}}{{ #vardefine: $cq_col_extra_2 | {{ #if: {{{extra_column2|}}} | ?{{{extra_column2}}} }}
 
}}<!--
 
}}<!--

Revision as of 12:57, 11 June 2023

SQLStore debug output
ASK Query
[[Card type::Monster Card]]
SQL Query
SELECT DISTINCT
  t0.smw_id AS id,
  t0.smw_title AS t,
  t0.smw_namespace AS ns,
  t0.smw_iw AS iw,
  t0.smw_subobject AS so,
  t0.smw_sortkey AS sortkey, t0.smw_sort,
  t0.smw_title,
  t0.smw_subobject
FROM
  `smw_object_ids` AS t0
INNER JOIN
  `smw_di_wikipage` AS t1 ON t0.smw_id=t1.s_id
WHERE
  (t1.p_id='596' AND t1.o_id='1389')
  AND t0.smw_iw!=':smw'
  AND t0.smw_iw!=':smw-delete'
  AND t0.smw_iw!=':smw-redi'
ORDER BY
  t0.smw_sort ASC,
  t0.smw_title ASC,
  t0.smw_subobject ASC
LIMIT
  55
OFFSET
  0
SQL Explain
IDselect_typetabletypepossible_keyskeykey_lenrefrowsExtra
1SIMPLEt1refs_id,o_id,p_id,s_id_2,s_id_3,o_id_2,o_id_3o_id_25const71526Using where; Using temporary; Using filesort
1SIMPLEt0eq_refPRIMARY,smw_id,smw_iw,smw_iw_2PRIMARY4ygowiki.t1.s_id1Using where
Auxilliary Tables
No auxilliary tables used.
Query Metrics
Query-Size:2
Query-Depth:1
Errors and Warnings
None
  • #ask query: [[Card type::Monster Card]]
  • $cq_query:
  • $cq_query_lc:
  • $cq_query_normalized:
  • $cq_medium:
  • $cq_medium_query:
  • $cq_query_medium:
  • $cq_card_type: monster
  • $cq_card_type_query: [[Card type::Monster Card]]
  • $cq_concept_query:
  • $cq_col_card_type: ?Card type =
  • $cq_col_primary_type: ?Primary type
  • $cq_col_secondary_type: ?Secondary type
  • $cq_col_attribute: ?Attribute = [[Attribute]]
  • $cq_col_type: ?Type = [[Type]]
  • $cq_col_level/rank/link: ?Stars string = [[Level]]/<br />[[Rank]]
  • $cq_col_scale: ?Pendulum Scale = [[Pendulum Scale|Scale]]
  • $cq_col_link_rating:
  • $cq_col_atk: ?ATK string = [[ATK]]
  • $cq_col_def: ?DEF string = [[DEF]]
  • $cq_col_maximum_atk:
  • $cq_col_card_type_st:
  • $cq_col_property:
  • {{{extra_column}}}:
  • {{{extra_column2}}}:
  • $cq_col_extra:
  • $cq_col_extra_2:
  • limit: 50
  • $cq_sort: #
  • $cq_order:
  • $cq_default:
  • $cq_count: 44962