Last modified by Eleni Cojocariu on 2026/11/11 16:05

Show last authors
1 {{warning}}
2 WIP
3 {{/warning}}
4
5 How many pages of the old documentation were marked as done each month. [[New documentation pages per month>>XWikiOrg.documentation-scripts-queries.migration-progress.new-pages.WebHome]] counts the new tree growing; [[Migration progress>>XWikiOrg.documentation-scripts-queries.migration-progress.WebHome]] holds the totals these months add up to.
6
7 {{velocity}}
8 #*
9 The notes this page used to print, kept here rather than deleted - they are what the numbers mean,
10 and they are the answer to the first question anyone asks about them.
11
12 This page counts the old trees emptying and 'New documentation pages per month' counts the new
13 tree growing, so the two are the same story told from its two ends.
14
15 Main wiki scope: a legacy page counts as done when it carries the 'done' tag. The month it falls
16 in is the month that tag was added, read from the version comment the tag UI writes ('Added tag
17 [done]') and, when that is not there, found by bisecting the page's history for the oldest
18 revision already carrying it. The page used to report how many revisions that bisection had to
19 read - every other page was dated from its comment alone.
20
21 extensions.xwiki.org scope: an extension page needs no tag. It counts as converted once its
22 website field points at the generated documentation listing (DocApp/Code/ExtensionLD), and the
23 month is found by bisecting its history the same way - restricted to the revisions since the
24 series starts, because the repository's own migrations bulk-edit every extension page several
25 times a year.
26
27 The bar at the top of the main wiki scope drops unconvertable pages from both numbers, which is
28 what makes it read lower than the 'All three trees' bar on the summary page: that one counts
29 done plus unconvertable as resolved.
30 *#
31 ## Months are compared and bucketed as 'yyyy-MM' strings, which sort chronologically, so the same
32 ## formatted value decides the bucket and the comparison and no page can fall on the wrong side of
33 ## a boundary. Anything older than this is carried as a single baseline line rather than shown as
34 ## a row, exactly as the sibling 'new pages per month' page does.
35 #set ($startMonth = '2025-01')
36 #set ($Q = '"')
37 ## Scopes, in display order; the first one is the default, so the page has something to show when
38 ## it is opened without a parameter - same contract as the other detail pages of this space.
39 #set ($scopes = [])
40 #set ($discard = $scopes.add({'key': 'main-wiki', 'label': 'Main wiki'}))
41 #set ($discard = $scopes.add({'key': 'extensions', 'label': 'extensions.xwiki.org'}))
42 #set ($requested = "$!request.get('scope')")
43 #set ($scope = '')
44 #foreach ($candidate in $scopes)
45 #if ($candidate.key == $requested)
46 #set ($scope = $candidate)
47 #end
48 #end
49 #if ($scope == '')
50 #set ($scope = $scopes.get(0))
51 #end
52 #set ($links = [])
53 #foreach ($candidate in $scopes)
54 #if ($candidate.key == $scope.key)
55 #set ($discard = $links.add("**$candidate.label**"))
56 #else
57 #set ($url = $doc.getURL('view', "scope=$candidate.key"))
58 #set ($discard = $links.add("[[$candidate.label>>path:$url]]"))
59 #end
60 #end
61 Choose which pages to count:
62
63 $stringtool.join($links, ' | ')
64
65 ## One bar per month, scaled to the busiest month rather than to a fixed maximum, so the shape of
66 ## the series is visible whatever its scale. The classes are the skin's own, so the bars follow the
67 ## color theme rather than carrying colours of their own.
68 #macro (monthBar $label $count $peak $noun)
69 #if ($peak > 0)##
70 #set ($pct = (100 * $count) / $peak)##
71 ## Integer division, so a month worth less than a hundredth of the busiest one rounds to nothing
72 ## and would show an empty track as if no work had been done in it. Floored at a visible sliver.
73 #if ($count > 0 && $pct < 1)##
74 #set ($pct = 1)##
75 #end##
76 #else##
77 #set ($pct = 0)##
78 #end##
79 **$label** - $count $noun
80
81 {{html}}<div class="progress">##
82 #if ($pct > 0)<div class="progress-bar progress-bar-success" style="width: ${pct}%">$count</div>#end##
83 </div>{{/html}}
84
85 #end
86 ## The overall state the months below add up to, in the shape the summary page uses. Unconvertable
87 ## pages are left out of both numbers rather than counted as resolved: there is nothing to convert
88 ## in them, so counting them would read as progress nobody made. That is the one difference from
89 ## the 'All three trees' bar of the summary page, and it is why this one reads lower.
90 #macro (progressBar $label $total $converted $started)
91 #if ($total > 0)##
92 #set ($convertedPct = (100 * $converted) / $total)##
93 #set ($startedPct = (100 * $started) / $total)##
94 #else##
95 #set ($convertedPct = 0)##
96 #set ($startedPct = 0)##
97 #end##
98 #if ($started > 0)##
99 #set ($startedText = ", $started in progress")##
100 #else##
101 #set ($startedText = '')##
102 #end##
103 **$label** - $converted of $total converted ($convertedPct%)$startedText
104
105 {{html}}<div class="progress">##
106 #if ($convertedPct > 0)<div class="progress-bar progress-bar-success" style="width: ${convertedPct}%">$converted</div>#end##
107 #if ($startedPct > 0)<div class="progress-bar progress-bar-warning" style="width: ${startedPct}%">$started</div>#end##
108 </div>{{/html}}
109
110 #end
111 #if ($scope.key == 'main-wiki')
112 = Legacy pages of the three guides =
113
114 ## The same population and the same test as the Done column of the summary page, so a month of this
115 ## page can never disagree with the total over there.
116 #set ($trees = ['Documentation.UserGuide', 'Documentation.AdminGuide', 'Documentation.DevGuide'])
117 #set ($marker = 'done')
118 ## The same population as the Done column of the summary page, minus the unconvertable pages -
119 ## dropped from the denominator as well as from the numerator, so the percentage is the share of
120 ## the work that can be converted and has been. Counted with setLimit(0): only numFound comes back.
121 #set ($mappingClass = 'XWikiOrg.documentation-scripts-queries.MigratedPageClass')
122 #set ($overallTotal = 0)
123 #set ($overallConverted = 0)
124 #set ($overallStarted = 0)
125 #foreach ($tree in $trees)
126 #set ($convertibleBase = "type:DOCUMENT AND wiki:xwiki AND hidden:false AND space_prefix:${Q}${tree}${Q} AND -name:WebPreferences AND -property.XWiki.TagClass.tags:unconvertable")
127 #set ($treeTotal = $services.query.createQuery($convertibleBase, 'solr').setLimit(0).execute().get(0).results.numFound)
128 #set ($treeConverted = $services.query.createQuery("${convertibleBase} AND property.XWiki.TagClass.tags:$marker", 'solr').setLimit(0).execute().get(0).results.numFound)
129 #set ($treeStarted = $services.query.createQuery("${convertibleBase} AND class:${Q}${mappingClass}${Q} AND -property.XWiki.TagClass.tags:$marker", 'solr').setLimit(0).execute().get(0).results.numFound)
130 #set ($overallTotal = $overallTotal + $treeTotal)
131 #set ($overallConverted = $overallConverted + $treeConverted)
132 #set ($overallStarted = $overallStarted + $treeStarted)
133 #end
134 #progressBar('All three trees' $overallTotal $overallConverted $overallStarted)
135 #set ($doneByMonth = $collectiontool.sortedMap)
136 #set ($undated = [])
137 #set ($revisionReads = 0)
138 #set ($refs = [])
139 #foreach ($tree in $trees)
140 #set ($statement = "type:DOCUMENT AND wiki:xwiki AND hidden:false AND space_prefix:${Q}${tree}${Q} AND -name:WebPreferences AND property.XWiki.TagClass.tags:$marker")
141 #set ($query = $services.query.createQuery($statement, 'solr'))
142 #set ($discard = $query.setLimit(1000))
143 ## The five fields SolrQueryExecutor needs to resolve a result to a document reference and check
144 ## view rights, plus the reference itself: a result it cannot resolve is dropped, which would
145 ## thin the series out while the summary page still showed the full total.
146 #set ($discard = $query.bindValue('fl', 'wiki,spaces,name,type,doclocale,fullname'))
147 #foreach ($row in $query.execute().get(0).results)
148 #set ($discard = $refs.add($row.getFirstValue('fullname')))
149 #end
150 #end
151 #foreach ($ref in $refs)
152 #set ($markedDoc = $xwiki.getDocument($ref))
153 ## getRevisions() returns a Java array, which exposes neither size() nor get(): copied into a
154 ## list so the bisection below can index it. It comes oldest first, which is the order both
155 ## passes need. The dates are collected in the same pass, so the bisection costs no extra read
156 ## to date the revision it lands on - and a version whose metadata cannot be read is left out
157 ## of both lists rather than one, since a #set whose value is null is silently skipped and
158 ## would otherwise shift the dates one revision out of step with the versions.
159 #set ($versions = [])
160 #set ($dates = [])
161 #set ($found = false)
162 #set ($eventDate = '')
163 #foreach ($version in $markedDoc.getRevisions())
164 #set ($info = $markedDoc.getRevisionInfo("$version"))
165 #if ($info && $info.date)
166 #set ($discard = $versions.add("$version"))
167 #set ($discard = $dates.add($info.date))
168 ## The cheap pass: the tag UI writes 'Added tag [done]' or 'Added tags [a, b]' as the version
169 ## comment. Lower-cased on both sides because a tag is stored with the case it was typed in
170 ## ('Unconvertable') while the index matches it case-insensitively.
171 #if (!$found)
172 ## A method cannot be called on a string literal in Velocity, hence the two steps.
173 #set ($comment = "$!info.comment")
174 #set ($comment = $comment.toLowerCase())
175 #set ($open = $comment.indexOf('['))
176 #set ($close = $comment.lastIndexOf(']'))
177 #if ($comment.startsWith('added tag') && $open > 0 && $close > $open)
178 #set ($from = $open + 1)
179 #foreach ($tagName in $comment.substring($from, $close).split(','))
180 #if (!$found && $tagName.trim() == $marker)
181 #set ($found = true)
182 #set ($eventDate = $info.date)
183 #end
184 #end
185 #end
186 #end
187 #end
188 #end
189 ## The fallback: bisect for the oldest revision that already carries the tag. $lo is an index
190 ## known not to carry it (-1 standing for "before the first revision") and $hi one known to
191 ## carry it - the current version does, which is why the page is in this list at all. Velocity
192 ## has no while loop, so this is a bounded foreach with the real test inside: 20 steps cover a
193 ## million revisions and the guard makes the extra turns free.
194 #if (!$found && !$versions.isEmpty())
195 #set ($lo = -1)
196 #set ($hi = $versions.size() - 1)
197 #foreach ($step in [1..20])
198 #set ($gap = $hi - $lo)
199 #if ($gap > 1)
200 #set ($mid = ($lo + $hi) / 2)
201 #set ($revisionDoc = $markedDoc.getDocumentRevision($versions.get($mid)))
202 #set ($revisionReads = $revisionReads + 1)
203 #set ($carries = false)
204 #if ($revisionDoc)
205 #foreach ($tagName in $revisionDoc.getTagList())
206 #if ($tagName.toLowerCase() == $marker)
207 #set ($carries = true)
208 #end
209 #end
210 #end
211 #if ($carries)
212 #set ($hi = $mid)
213 #else
214 #set ($lo = $mid)
215 #end
216 #end
217 #end
218 #set ($found = true)
219 #set ($eventDate = $dates.get($hi))
220 #end
221 #if ($found)
222 #set ($month = $datetool.format('yyyy-MM', $eventDate))
223 #if (!$doneByMonth.containsKey($month))
224 #set ($discard = $doneByMonth.put($month, 0))
225 #end
226 #set ($discard = $doneByMonth.put($month, $doneByMonth.get($month) + 1))
227 #else
228 #set ($discard = $undated.add($ref))
229 #end
230 #end
231 #set ($baseline = 0)
232 #set ($peak = 0)
233 #foreach ($month in $doneByMonth.keySet())
234 #set ($monthTotal = $doneByMonth.get($month))
235 #if ($month.compareTo($startMonth) < 0)
236 #set ($baseline = $baseline + $monthTotal)
237 #elseif ($monthTotal > $peak)
238 #set ($peak = $monthTotal)
239 #end
240 #end
241 #set ($totalDone = 0)
242 #set ($bars = [])
243 (% class="table" %)
244 |=Month|=Pages marked done
245 #foreach ($month in $doneByMonth.keySet())
246 #if ($month.compareTo($startMonth) >= 0)
247 #set ($monthDone = $doneByMonth.get($month))
248 #set ($totalDone = $totalDone + $monthDone)
249 #set ($discard = $bars.add({'label': $month, 'count': $monthDone}))
250 |$month|$monthDone
251 #end
252 #end
253 |=**Total**|=**$totalDone**
254
255 #if ($baseline > 0)
256 **Before $startMonth** - $baseline pages were already marked done.
257
258 #end
259 #foreach ($bar in $bars)
260 #monthBar($bar.label $bar.count $peak 'pages marked done')
261 #end
262 #if (!$undated.isEmpty())
263 {{warning}}
264 $undated.size() pages carry a tag but have no readable history, so they are in no month: $stringtool.join($undated, ', ')
265 {{/warning}}
266
267 #end
268 #else
269 = Extension pages pointed at the new documentation =
270
271 ## An extension page needs no tag: it counts as converted once its website field points at the
272 ## generated documentation listing, which is the test the summary page's Done column makes too.
273 ## The substring is tested rather than the field merely being non-empty, because 9 extension pages
274 ## have carried a website of their own since long before this migration - github.com,
275 ## webviewers.org - and dating those would put the migration's first month in February 2012.
276 #set ($extensionClass = 'ExtensionCode.ExtensionClass')
277 #set ($websiteMarker = 'DocApp/Code/ExtensionLD')
278 ## The overall state the months below add up to. The denominator is the extension pages that
279 ## carry an id, not every page of the wiki: a page with an empty id is not a thing there is an
280 ## extension to document, so counting it would make the ratio answer a question nobody asked.
281 ## Both counts are queried rather than derived from the series: the series drops the pages whose
282 ## history cannot be read, and a bar that disagreed with its own table would be worse than none.
283 ## setLimit(0) returns numFound alone, so the two cost nothing next to the bisection below.
284 #set ($idField = 'property.ExtensionCode.ExtensionClass.id_string')
285 #set ($withIdBase = "type:DOCUMENT AND wiki:extensions AND hidden:false AND class:${Q}${extensionClass}${Q} AND ${idField}:?*")
286 #set ($withId = $services.query.createQuery($withIdBase, 'solr').setLimit(0).execute().get(0).results.numFound)
287 #set ($withIdDone = $services.query.createQuery("${withIdBase} AND property.ExtensionCode.ExtensionClass.website:ExtensionLD", 'solr').setLimit(0).execute().get(0).results.numFound)
288 #progressBar('Extension pages carrying an id' $withId $withIdDone 0)
289 #set ($statement = "type:DOCUMENT AND wiki:extensions AND hidden:false AND class:${Q}${extensionClass}${Q} AND property.ExtensionCode.ExtensionClass.website:ExtensionLD")
290 #set ($query = $services.query.createQuery($statement, 'solr'))
291 #set ($discard = $query.setLimit(1000))
292 #set ($discard = $query.bindValue('fl', 'wiki,spaces,name,type,doclocale,fullname'))
293 #set ($results = $query.execute().get(0).results)
294 #set ($byMonth = $collectiontool.sortedMap)
295 #set ($baseline = 0)
296 #set ($unreadable = 0)
297 #set ($revisionReads = 0)
298 #foreach ($solrDoc in $results)
299 ## Solr returns the reference as it is written on its own wiki, so the wiki has to be put back on
300 ## for the document to be loadable from here.
301 #set ($markedDoc = $xwiki.getDocument("extensions:$solrDoc.getFirstValue('fullname')"))
302 #set ($versions = [])
303 #set ($dates = [])
304 #foreach ($version in $markedDoc.getRevisions())
305 #set ($info = $markedDoc.getRevisionInfo("$version"))
306 #if ($info && $info.date)
307 #set ($discard = $versions.add("$version"))
308 #set ($discard = $dates.add($info.date))
309 #end
310 #end
311 #if ($versions.isEmpty())
312 #set ($unreadable = $unreadable + 1)
313 #else
314 ## No version-comment shortcut here: filling a field records whatever comment the editor typed,
315 ## which is nothing. The bisection is restricted to the revisions since $startMonth instead -
316 ## the repository's own migrations bulk-edit every extension page several times a year, so the
317 ## full history of one of them runs to a thousand revisions, and bisecting all of it would cost
318 ## three reads a page more than bisecting the part anyone is asking about. The dates come out
319 ## of the archive oldest first, so the scan can stop at the first one inside the window.
320 #set ($lo = -1)
321 #set ($hi = $versions.size() - 1)
322 #set ($beforeWindow = true)
323 #foreach ($index in [0..$hi])
324 #if ($beforeWindow)
325 #if ($datetool.format('yyyy-MM', $dates.get($index)).compareTo($startMonth) < 0)
326 #set ($lo = $index)
327 #else
328 #set ($beforeWindow = false)
329 #end
330 #end
331 #end
332 ## Was it already pointed at the new documentation before the series starts?
333 #set ($carries = false)
334 #if ($lo >= 0)
335 #set ($revisionDoc = $markedDoc.getDocumentRevision($versions.get($lo)))
336 #set ($revisionReads = $revisionReads + 1)
337 #if ($revisionDoc)
338 #foreach ($extensionObject in $revisionDoc.getObjects($extensionClass))
339 #set ($website = "$!extensionObject.getValue('website')")
340 #if ($website.contains($websiteMarker))
341 #set ($carries = true)
342 #end
343 #end
344 #end
345 #end
346 #if ($carries)
347 #set ($baseline = $baseline + 1)
348 #else
349 #foreach ($step in [1..20])
350 #set ($gap = $hi - $lo)
351 #if ($gap > 1)
352 #set ($mid = ($lo + $hi) / 2)
353 #set ($revisionDoc = $markedDoc.getDocumentRevision($versions.get($mid)))
354 #set ($revisionReads = $revisionReads + 1)
355 #set ($midCarries = false)
356 #if ($revisionDoc)
357 #foreach ($extensionObject in $revisionDoc.getObjects($extensionClass))
358 #set ($website = "$!extensionObject.getValue('website')")
359 #if ($website.contains($websiteMarker))
360 #set ($midCarries = true)
361 #end
362 #end
363 #end
364 #if ($midCarries)
365 #set ($hi = $mid)
366 #else
367 #set ($lo = $mid)
368 #end
369 #end
370 #end
371 #set ($month = $datetool.format('yyyy-MM', $dates.get($hi)))
372 #if (!$byMonth.containsKey($month))
373 #set ($discard = $byMonth.put($month, 0))
374 #end
375 #set ($discard = $byMonth.put($month, $byMonth.get($month) + 1))
376 #end
377 #end
378 #end
379 #set ($peak = 0)
380 #foreach ($month in $byMonth.keySet())
381 #if ($byMonth.get($month) > $peak)
382 #set ($peak = $byMonth.get($month))
383 #end
384 #end
385 #set ($total = 0)
386 #set ($bars = [])
387 (% class="table" %)
388 |=Month|=Pages converted
389 #foreach ($month in $byMonth.keySet())
390 #set ($monthTotal = $byMonth.get($month))
391 #set ($total = $total + $monthTotal)
392 #set ($discard = $bars.add({'label': $month, 'count': $monthTotal}))
393 |$month|$monthTotal
394 #end
395 |=**Total**|=**$total**
396
397 #if ($baseline > 0)
398 **Before $startMonth** - $baseline extension pages already pointed at the new documentation.
399
400 #end
401 #foreach ($bar in $bars)
402 #monthBar($bar.label $bar.count $peak 'pages converted')
403 #end
404 #if ($unreadable > 0)
405 {{warning}}
406 $unreadable extension pages have no readable history and are in no month.
407 {{/warning}}
408
409 #end
410 #end
411 {{/velocity}}
412
413

Get Connected