Wiki source code of Duncan Result

Version 15.3 by Alexandru Colesnicov on 2018/11/05 18:04

Show last authors
1 {{velocity}}
2
3 #set($class="Duncan1.Code.GDataClass")
4 #set($template="Duncan1.Code.GDataTemplate")
5 #set($xwlquery="from doc.object($class) as obj where doc.fullName <> '$template' order by doc.date desc")
6 #set($list=$services.query.xwql($xwlquery).execute())
7 #set($totalF=0)
8 #set($totalM=0)
9 #set($nPos=$list.size())
10 #foreach($item in $list)
11 #set($itemdoc = $xwiki.getDocument($item))
12 ###$itemdoc.getName()
13 ###$itemdoc.get('Profession')
14 #set($nFInPos = $itemdoc.getValue('QuaWoman'))
15 #set($nMInPos = $itemdoc.getValue('QuaMan'))
16 #set($totalF = $totalF+$nFInPos)
17 #set($totalM = $totalM+$nMInPos)
18 #end
19 #set($totalFM=$totalF+$totalM)
20 $nPos records processed
21 $totalFM pers. incl. woman: $totalF; man: $totalM
22
23 {{/velocity}}
24
25 {{python}}
26
27 import sys
28 print "Python version is ", sys.version
29 print
30 iDunc = 0.0
31 for item in list:
32 itemdoc = xwiki.getDocument(item)
33 nFInPos = itemdoc.getValue("QuaWoman")
34 nMInPos = itemdoc.getValue("QuaMan")
35 iDunc += abs(nFInPos/float(totalF) - nMInPos/float(totalM))
36 iDunc *= 0.5
37 print "Duncan index = %s" % (iDunc)
38 {{/python}}