Would something like
SELECT page_namespace, page_title, COUNT(*) FROM templatelinks JOIN page
ON (tl_from = page_id) GROUP BY tl_from;
do it for you? That looks ok to me in MariaDB/MySQL but you may have to
"GROUP BY page_namespace, page_title" in other databases.
Nik
On Wed, Apr 2, 2014 at 10:30 AM, Daniel Barrett <danb(a)vistaprint.com> wrote:
Is there a way to calculate/query the number of
templates in a wiki
article?
The goal is to identify pages on our wiki that transclude excessive
numbers of templates, flag them as too complex,
and work with page authors to reduce their complexity.
For example, if page P transcludes {{foo}} ten times and {{bar}} two
times, the count would be 12.
(We don't care about recursive transclusions for now.)
Special:MostLinkedTemplates does the opposite (identifies highly linked
templates, not highly-templated pages).
I also queried the templatelinks table, but it seems to count each
template only once, not multiple transclusions of the same template.
SQL or PHP solutions would be fine. I suspect we could attach a callback
to the hook 'BeforeParserFetchTemplateAndTitle'
and count the fetches, but I'd prefer something that won't impact the
running wiki.
Another approach might be to reduce the $wgMax*PPNodeCount values, but
choosing appropriate values
would be trial and error.
Thank you!
DanB
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l