Hide last authors
Alexandru Colesnicov 20.1 1 {{velocity}}
Alexandru Colesnicov 6.2 2
Alexandru Colesnicov 20.1 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")
Alexandru Colesnicov 25.1 6 ### "$xwlquery"
Alexandru Colesnicov 20.1 7 #set($list=$services.query.xwql($xwlquery).execute())
Alexandru Colesnicov 6.2 8
Alexandru Colesnicov 20.1 9 {{/velocity}}
10
11 {{python}}
12
Alexandru Colesnicov 13.1 13 import sys
Alexandru Colesnicov 15.3 14 print "Python version is ", sys.version
Alexandru Colesnicov 14.1 15 print
Alexandru Colesnicov 15.4 16
Alexandru Colesnicov 15.13 17 className = "Duncan1.Code.GDataClass"
18 template = "Duncan1.Code.GDataTemplate"
Alexandru Colesnicov 15.15 19 xwlquery = "from doc.object(" + className + ") as obj where doc.fullName <> \'" + template + "\' order by doc.date desc"
Alexandru Colesnicov 15.14 20 # print "\"%s\"" % xwlquery
Alexandru Colesnicov 18.1 21 # import xwiki
Alexandru Colesnicov 19.1 22 # list = services.query.xwql(xwlquery).execute()
Alexandru Colesnicov 15.5 23
Alexandru Colesnicov 15.4 24 totalF=0
25 totalM=0
26 nPos=list.size()
27 for item in list:
28 itemdoc = xwiki.getDocument(item)
29 nFInPos = itemdoc.getValue('QuaWoman')
30 nMInPos = itemdoc.getValue('QuaMan')
31 totalF += nFInPos
32 totalM += nMInPos
33 totalFM = totalF+totalM
34 print "%s records processed\n%s pers. incl. woman: %s; man: %s" % (nPos, totalFM, totalF, totalM)
35
Alexandru Colesnicov 6.1 36 iDunc = 0.0
Alexandru Colesnicov 9.5 37 for item in list:
Alexandru Colesnicov 5.1 38 itemdoc = xwiki.getDocument(item)
Alexandru Colesnicov 9.4 39 nFInPos = itemdoc.getValue("QuaWoman")
40 nMInPos = itemdoc.getValue("QuaMan")
Alexandru Colesnicov 12.1 41 iDunc += abs(nFInPos/float(totalF) - nMInPos/float(totalM))
Alexandru Colesnicov 9.2 42 iDunc *= 0.5
Alexandru Colesnicov 20.1 43 print "Duncan index = %s" % (iDunc)
44 {{/python}}

Need help?

If you need help with XWiki you can contact: