Wiki source code of Duncan Result

Version 15.11 by Alexandru Colesnicov on 2018/11/05 18:50

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
8 {{/velocity}}
9
10 {{python}}
11
12 import sys
13 print "Python version is ", sys.version
14 print
15
16 className = "Duncan1.Code.GDataClass"
17 template = "Duncan1.Code.GDataTemplate"
18 xwlquery = "from doc.object(\'" + className + "\') as obj where doc.fullName <> \'" + template + "\' order by doc.date desc"
19 list = services.query.xwql(xwlquery).execute()
20
21 totalF=0
22 totalM=0
23 nPos=list.size()
24 for item in list:
25 itemdoc = xwiki.getDocument(item)
26 nFInPos = itemdoc.getValue('QuaWoman')
27 nMInPos = itemdoc.getValue('QuaMan')
28 totalF += nFInPos
29 totalM += nMInPos
30 totalFM = totalF+totalM
31 print "%s records processed\n%s pers. incl. woman: %s; man: %s" % (nPos, totalFM, totalF, totalM)
32
33 iDunc = 0.0
34 for item in list:
35 itemdoc = xwiki.getDocument(item)
36 nFInPos = itemdoc.getValue("QuaWoman")
37 nMInPos = itemdoc.getValue("QuaMan")
38 iDunc += abs(nFInPos/float(totalF) - nMInPos/float(totalM))
39 iDunc *= 0.5
40 print "Duncan index = %s" % (iDunc)
41 {{/python}}