User:Nlangle/Migration Example

From Open Energy Information

Example code for using a categorization technique to migrate pages when Special:ReplaceText exceeds maximum (1000 pages). Add code to a template to help build a "glossary" that allows Special:ReplaceText to perform the operation on a smaller category. This was used on Companies and Utility Companies to help move them to the new Organization template. There were 12,000+ companies, so splitting them into categories based on the first letter in the page name helped to split up the work.

add this code to the template to set the category:

<!--building a set of temporary property values to classify companies by the first letter of the PAGENAME.  This will help in the migration of pages using the company template to the new organization template.-->
{{#set:CompanyGlossary=CompanyGlossary-{{#sub:{{PAGENAME}}|0|1}}]]}}


This is a test query to see results:

{{#ask:[[CompanyGlossary::+]]|?CompanyGlossary}}


if a newly created section is still too large, as was the case with companies beginning with the letter C, then build the glossary one step deeper. In this case, search for all pages that have the first 2 letters Co:

{{#ifeq:{{#sub:{{PAGENAME}}|0|2}}|Co|Do it!|try again}}