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