Jump to content

Rosetta Code/List authors of task descriptions: Difference between revisions

→‎{{header|Wren}}: Updated Wren script following site change - largely rewritten in fact.
(→‎{{header|Wren}}: Updated Wren script following site change - largely rewritten in fact.)
Line 678:
 
=={{header|Wren}}==
{{trans|Go}}
{{libheader|libcurl}}
{{libheader|Wren-pattern}}
Line 684 ⟶ 683:
An embedded program so we can use libcurl.
 
Takes a littleupwards overof an80 hourminutes to run as the history page(s) for each task need to be downloaded and parsed to find the author. Worse still, given we are pounding a busy server pretty hard, there are lots of 'bad gateway' and other errors (94 on this particular run!) which necessitate adding tasks back to the task list until they are eventually downloaded and parsed successfully which can add several minutes to the overall time.
<syntaxhighlight lang="ecmascript">/* rc_list_authors_of_task_descriptions.wren */
 
Line 723 ⟶ 722:
}
 
var p1 = Pattern.new("<li><a hreftitle/=\"//wiki//[+1^\"]\"")
var ip2 = Pattern.new("cmcontinue/=\"[+1^\"]\"&")
var urlspi = ["\"&"
var p2p3 = Pattern.new("a href/=\"//[wiki//User:|mww//index.php?title/=User:|wiki//Special:Contributions//][+1/I]\"", 0, ipi)
var tasks = []
 
var urls = [
var findTasks = Fn.new { |category|
"http://rosettacode.org/wiki/Category:Programming_Tasks",
var url = "httphttps://www.rosettacode.org/wikiw/api.php?action=query&list=categorymembers&cmtitle=Category:Draft_Programming_Tasks%(category)&cmlimit=500&format=xml"
var cmcontinue = ""
]
var tasks = []
for (url in urls) {
while (true) {
var content = getContent.call(url)
var matchescontent = p1getContent.findAllcall(contenturl + cmcontinue)
var matchesmatches1 = p2p1.findAll(content)
for (m in matches) {
varfor task(m =in m.capsText[0]matches1) {
var title = m.capsText[0].replace("&#039;", "'").replace("&quot;", "\"")
// exclude any 'category' references
if (!task.startsWith("Category:")) tasks.add(tasktitle)
}
var m2 = p2.find(content)
if (m2) cmcontinue = "&cmcontinue=%(m2.capsText[0])" else break
}
return tasks
}
 
var tasks = findTasks.call("Programming_Tasks") // 'full' tasks only
tasks.addAll(findTasks.call("Draft_Programming_Tasks"))
var tc = tasks.count
var authors = {}
forwhile (tasktasks.count in> tasks0) {
var task = tasks[0].replace(" ", "_").replace("+", "\%2B")
// check the last or only history page for each task
var url = "httphttps://rosettacode.org/mww/index.php?title=%(task)&dir=prev&action=history"
tasks.removeAt(0)
var content = getContent.call(url)
content = content.replace("http://www.rosettacode.org", "")
var matches = p2.findAll(content)
var matches = p3.findAll(content)
// if there are no matches there must have been a 'bad gateway' or other error
if (matches.count == 0) {
// add back a failed task until it eventually succeeds
tasks.add(task)
continue
}
// the task author should be the final user on that page
var author = matches[-1].capsText[1].replace("_", " ")
Line 759 ⟶ 775:
var authorNumbers = authors.toList
authorNumbers.sort { |a, b| a.value > b.value }
// print thethose topwho've thirtycompleted sayat least 9 tasks
System.print("TotalAs tasksat 10th September 2022: %(tasks.count)\n")
System.print("Total tasks : 1492%(tc)")
System.print("Total authors : %(authors.count)")
System.print("\nThe topauthors 30who authorshave bycreated numberat ofleast tasks9 createdtasks are:\n")
System.print("Pos Tasks Author")
System.print("==== ===== ======")
var lastNumber = 0
var lastIndex = -1
var i = 0
for (authorNumber in authorNumbers.take(30)where { |me| me.value >= 9 }) {
var j = i
var eq = " "
Line 977 ⟶ 994:
 
{{out}}
Position as at 6th January, 2022.
<pre>
As at 10th September 2022:
Total tasks : 1492
Total authors : 307
 
Total tasks : 1569
The top 30 authors by number of tasks created are:
Total authors : 307315
 
The authors who have created at least 9 tasks are:
 
Pos Tasks Author
==== ===== ======
1 199 Paddy3118
2 128135 CalmoSoft
3 7174 MarkhobleyThundergnat
4 6671 Gerard SchildbergerMarkhobley
5 5566 Mwn3dGerard Schildberger
6 4455 ThundergnatMwn3d
7 39 NevilleDNZ
87= 3639 Nigel Galloway
9 33 Short CircuitMikeMol
10 2327 GrondiluPureFox
11 2123 Blue PrawnGrondilu
12 2021 FwendBlue Prawn
12=13 20 DkfFwend
1413= 20 18 KernighDkf
15 1719 Dmitry-kazakovWherrera
15=16 17 18 Wherrera Kernigh
15=17 17 ShinTakezouDmitry-kazakov
1517= 17 LedrugShinTakezou
1917= 17 16 PureFoxLedrug
20 13 Paulo Jorente
20= 13 Waldorf
20= 13 Abu
20= 13 Waldorf
23 12 Ce
23= 12 Kevin Reid
2523= 12 10 Tinku99Puppydrum64
25=26 10 Bearophile
2726= 10 9 TimSCTinku99
27=28 9 Puppydrum64TimSC
2728= 9 TrizenPetelomax
2728= 9 EMBee
28= 9 Trizen
</pre>
9,484

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.