diff --git a/wikis/xwiki/src/main/resources/Avis/Admin/Statistiques/Comptages/ComputeAvisFormAnswers.xml b/wikis/xwiki/src/main/resources/Avis/Admin/Statistiques/Comptages/ComputeAvisFormAnswers.xml deleted file mode 100644 index 58a17a17..00000000 --- a/wikis/xwiki/src/main/resources/Avis/Admin/Statistiques/Comptages/ComputeAvisFormAnswers.xml +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - Avis.Admin.Statistiques.Comptages - ComputeAvisFormAnswers - - - 0 - xwiki:XWiki.Admin - 1544396400000 - xwiki:Avis.Admin.Statistiques.Comptages.WebHome - xwiki:XWiki.Admin - xwiki:XWiki.Admin - 1544396400000 - 1544396400000 - 1.1 - Compter les réponses aux questions du formulaire d'avis pour une année - - false - xwiki/2.1 - false - {{velocity output='false'}} -#macro(fillDataForSmileyProperty $smileyQuestionHQL $spName) - #foreach($spValue in $services.query.hql($smileyQuestionHQL).bindValue('top250Demarches', $top250DemarchesNames).bindValue('minDate', $minDate).bindValue('maxDate', $maxDate).bindValue('smileyQuestionPropName', $spName).execute()) - #set($demarcheData = $top250FormResults.get($spValue[0])) - #if ("$!demarcheData" == '') - #set($demarcheData = {}) - #end - #set($spData = $demarcheData.get($spName)) - #if ("$!spData" == '') - #set($spData = {}) - #end - #set($discard = $spData.put("$!spValue[1]", $spValue[2])) - #set($discard = $demarcheData.put($spName, $spData)) - #set($discard = $top250FormResults.put($spValue[0], $demarcheData)) - #end -#end - -#macro(fillDataForMultiValueProperty $multivalueQuestionHQL $mvName) - #foreach($mvValue in $services.query.hql($multivalueQuestionHQL).bindValue('top250Demarches', $top250DemarchesNames).bindValue('minDate', $minDate).bindValue('maxDate', $maxDate).bindValue('multivalueQuestionPropName', $mvName).execute()) - #set($demarcheData = $top250FormResults.get($mvValue[0])) - #if ("$!demarcheData" == '') - #set($demarcheData = {}) - #end - #set($mvData = $demarcheData.get($mvName)) - #if ("$!mvData" == '') - #set($mvData = {}) - #end - #set($discard = $mvData.put("$!mvValue[1]", $mvValue[2])) - #set($discard = $demarcheData.put($mvName, $mvData)) - #set($discard = $top250FormResults.put($mvValue[0], $demarcheData)) - #end -#end -{{/velocity}} - -{{velocity}} -#set ($LOGGER = $services.logging.getLogger($doc.fullName)) -#if ("$!request.confirm" == 'true') - #set ($maxDateString = "18/05/2021") - #set ($formatter = $xwiki.jodatime.getDateTimeFormatterForPattern('dd/MM/yyyy')) - #set ($maxDateTime = $formatter.parseDateTime($maxDateString).withHourOfDay(23).withMinuteOfHour(59).withSecondOfMinute(59)) - #set ($minDateTime = $maxDateTime.minusYears(1).plusDays(1).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0)) - #set ($minDate = $minDateTime.toDate()) - #set ($maxDate = $maxDateTime.toDate()) - #set ($resultsSetName = "$maxDateTime.toDate().time") - #set ($discard = $LOGGER.debug("Starting to produce results set $resultsSetName")) - #set ($discard = $LOGGER.debug("Querying data for demarches form results for one year from date $minDateTime to $maxDateTime")) - #set ($top250DemarchesNames = []) - #set ($top250FormResults = {}) - ## get all top 250 demarches with their title and put them in the results map - #set ($top250WithTitlesHQL = "select doc.fullName, doc.title from XWikiDocument doc, BaseObject obj, IntegerProperty top where doc.fullName = obj.name AND obj.className = 'Demarches.Code.DemarchesClass' and top.id.id = obj.id and top.id.name = 'top' and top.value = 1") - #foreach ($t in $services.query.hql($top250WithTitlesHQL).execute()) - #set($discard = $top250DemarchesNames.add($t[0])) - #set($demarcheId = $t[0].substring(10)) - #set($discard = $top250FormResults.put($t[0], {'id' : $demarcheId, 'title' : $t[1]})) - #end - #set ($discard = $LOGGER.debug("Done fetching top 250 demarches, starting querying the indicators...")) - #set ($discard = $LOGGER.debug("Top 250 demarches is $top250DemarchesNames")) - ## - ## count the number of total avis - ## - #set ($discard = $LOGGER.debug("Fetching avis number...")) - #set ($totalAvisHQL = "SELECT demarche.value, avis.value, count(*) FROM XWikiDocument avisDoc, BaseObject avisObj, StringProperty demarche, IntegerProperty avis WHERE avisDoc.fullName = avisObj.name AND avisObj.className = 'Avis.Code.AvisClass' AND demarche.id.id = avisObj.id AND demarche.id.name = 'demarche' AND demarche.value in :top250Demarches AND avis.id.id = avisObj.id AND avis.id.name = 'score' AND avisDoc.creationDate <= :maxDate AND avisDoc.creationDate >= :minDate GROUP BY demarche.value, avis.value") - #foreach($a in $services.query.hql($totalAvisHQL).bindValue('top250Demarches', $top250DemarchesNames).bindValue('minDate', $minDate).bindValue('maxDate', $maxDate).execute()) - #set($demarcheData = $top250FormResults.get($a[0])) - #if ("$!demarcheData" == '') - #set($demarcheData = {}) - #end - #set($avisData = $demarcheData.get('avis')) - #if ("$!avisData" == '') - #set($avisData = {}) - #end - #set($discard = $avisData.put("$!a[1]", $a[2])) - #set($discard = $demarcheData.put('avis', $avisData)) - #set($discard = $top250FormResults.put($a[0], $demarcheData)) - #end - #set ($discard = $LOGGER.debug("Done fetching and storing avis number...")) - ## - #set ($smileyQuestionHQL = "SELECT demarche.value, smileyQuestionProp.value, count(*) FROM XWikiDocument avisDoc, BaseObject avisObj, StringProperty demarche, IntegerProperty smileyQuestionProp WHERE avisDoc.fullName = avisObj.name AND avisObj.className = 'Avis.Code.AvisClass' AND demarche.id.id = avisObj.id AND demarche.id.name = 'demarche' AND demarche.value in :top250Demarches AND smileyQuestionProp.id.id = avisObj.id AND smileyQuestionProp.id.name = :smileyQuestionPropName AND avisDoc.creationDate <= :maxDate AND avisDoc.creationDate >= :minDate GROUP BY demarche.value, smileyQuestionProp.value") - #set ($discard = $LOGGER.debug("Fetching the answers for easy to use question...")) - #fillDataForSmileyProperty($smileyQuestionHQL, 'facile') - #set ($discard = $LOGGER.debug("Done fetching the answers for easy to use question...")) - #set ($discard = $LOGGER.debug("Fetching the answers for language question...")) - #fillDataForSmileyProperty($smileyQuestionHQL, 'comprehensible') - #set ($discard = $LOGGER.debug("Done fetching the answers for language question...")) - ## - #set ($multivalueQuestionHQL = "SELECT demarche.value, multivalueQuestionPropVal, count(*) FROM XWikiDocument avisDoc, BaseObject avisObj, StringProperty demarche, DBStringListProperty multivalueQuestionProp join multivalueQuestionProp.list multivalueQuestionPropVal WHERE avisDoc.fullName = avisObj.name AND avisObj.className = 'Avis.Code.AvisClass' AND demarche.id.id = avisObj.id AND demarche.id.name = 'demarche' AND demarche.value in :top250Demarches AND multivalueQuestionProp.id.id = avisObj.id AND multivalueQuestionProp.id.name = :multivalueQuestionPropName AND avisDoc.creationDate <= :maxDate AND avisDoc.creationDate >= :minDate GROUP BY demarche.value, multivalueQuestionPropVal") - #set ($discard = $LOGGER.debug("Fetching the answers for difficulties question...")) - #fillDataForMultiValueProperty($multivalueQuestionHQL, 'difficultes') - #set ($discard = $LOGGER.debug("Done the answers for difficulties question...")) - #set ($discard = $LOGGER.debug("Fetching the answers for help question...")) - #fillDataForMultiValueProperty($multivalueQuestionHQL, 'aide') - #set ($discard = $LOGGER.debug("Done the answers for help question...")) - ## - ## - ## #set($results = $services.query.hql("select demarche.value, avg(score.value), count(*), concat(year(doc.creationDate), month(doc.creationDate)) from XWikiDocument as doc, BaseObject as avis, IntegerProperty as score, StringProperty as demarche where avis.name = doc.fullName and avis.className = 'Avis.Code.AvisClass' and avis.id = score.id.id and score.id.name = 'score' and demarche.id.id = avis.id and demarche.id.name = 'demarche' and score.value > 0 and doc.creationDate >= :minDate and doc.creationDate <= :maxDate group by demarche.value, concat(year(doc.creationDate), month(doc.creationDate))").bindValue('minDate', $minDate).bindValue('maxDate', $maxDate).execute()) - ## - #set($discard = $LOGGER.debug("Results fetched, starting post-processing...")) - #set($discard = $LOGGER.debug("Querying done, starting display...")) - #set($avisClass = $xwiki.getDocument("Avis.Code.AvisClass").getxWikiClass()) - #set($avisDifficultiesProperty = $avisClass.get('difficultes')) - #set($avisAideProperty = $avisClass.get('aide')) - #set($multiValuedProperties = {'difficultes' : $avisDifficultiesProperty.listValues, 'aide' : $avisAideProperty.listValues}) - #set($ssxInclusion = "{{velocity}}${escapetool.hash}set(${escapetool.dollar}discard = ${escapetool.dollar}xwiki.ssx.use('Demarches.WebHome')){{/velocity}}") - #set($resultsAsString = "${ssxInclusion}${escapetool.newline}${escapetool.newline}") - #set ($resultsAsString = "${resultsAsString}|=(%width='30%'%)Demarche|=Id|=Satisfaction - Mauvais|=Satisfaction - Moyen|=Satisfaction - Bon|=Nb. total avis|=Facile à utiliser – Mauvais|=Facile à utiliser – Moyen|=Facile à utiliser – Bon|=Facile à comprendre - Mauvais|=Facile à comprendre - Moyen|=Facile à comprendre - Bon") - #foreach($mvProp in ['difficultes', 'aide']) - #set($mvPropPrettyName = "Difficulté") - #if ($mvProp == 'aide') - #set($mvPropPrettyName = "Aide") - #end - #foreach($v in $multiValuedProperties.get($mvProp)) - #set($resultsAsString = "${resultsAsString}|=${mvPropPrettyName} - ") - #set($resultsAsString = $resultsAsString + $services.localization.render("Avis.Code.AvisClass_${mvProp}_${v}")) - #end - #end - #set($resultsAsString = "${resultsAsString}${escapetool.newline}") - #foreach($d in $top250DemarchesNames) - #set($demarcheData = $top250FormResults.get($d)) - #set($discard = $LOGGER.debug("Preparing data for demarche $d : $demarcheData.title")) - #set($demarcheRow = "|${demarcheData.title}|${demarcheData.id}") - #set($avisData = $demarcheData.get('avis')) - #set($dTotalAvis = 0) - #foreach($v in ['1', '2', '3']) - #set($vAvis = $NULL) - #set($vAvis = $avisData.get($v)) - #if ($vAvis == $NULL) - #set($vAvis = 0) - #end - #set($demarcheRow = "${demarcheRow}|${vAvis}") - #set($dTotalAvis = $dTotalAvis + $vAvis) - #end - #set($demarcheRow = "${demarcheRow}|${dTotalAvis}") - #foreach($spName in ['facile', 'comprehensible']) - #set($spData = $NULL) - #set($spData = $demarcheData.get($spName)) - #foreach($v in ['1', '2', '3']) - #set($spValue = $NULL) - #set($spValue = $spData.get($v)) - #if ($spValue == $NULL) - #set($spValue = 0) - #end - #set($demarcheRow = "${demarcheRow}|${spValue}") - #end - #end - #foreach($mvName in ['difficultes', 'aide']) - #set($mvData = $NULL) - #set($mvData = $demarcheData.get($mvName)) - #foreach($v in $multiValuedProperties.get($mvName)) - #set($mvValue = $NULL) - #set($mvValue = $mvData.get($v)) - #if ($mvValue == $NULL) - #set($mvValue = 0) - #end - #set($demarcheRow = "${demarcheRow}|${mvValue}") - #end - #end - ## - ## - ## - #set($resultsAsString = "${resultsAsString}${demarcheRow}${escapetool.newline}") - #set($discard = $LOGGER.debug("Added data for demarche $d in the results table to display")) - #end - #set($discard = $LOGGER.debug("Displaying d one, starting saving in document...")) - #set($resultsDocument = $xwiki.getDocument("Avis.Admin.Statistiques.Comptages.AvisFormAnswers.${resultsSetName}")) - #set($discard = $resultsDocument.setTitle("Comptages des réponses du formulaire d'avis pour une année avant $datetool.format('dd/MM/yyyy HH:mm:ss', $maxDateTime.toDate())")) - #set($discard = $resultsDocument.setContent($resultsAsString)) - #set($discard = $resultsDocument.save()) - #set($discard = $LOGGER.debug("Document saved at $resultsDocument.fullName")) - [[Voir les résultats>>$resultsDocument.fullName]] -#else - [[Calculer les résultats>>${doc.fullName}||queryString='confirm=true' class='btn btn-default']] - - Si la calculation prend trop de temps et le lien vers les résultats ne s'affiche pas, **ne relancez pas le calcul en refraichissant cette page!**. Les résultats seront présents dans la liste de la page [[Réponses Formulaire Avis>>Avis.Admin.Statistiques.Comptages.AvisFormAnswers]] lors de la finalisation du calcul (le calcul peut prendre ~40min). -#end -{{/velocity}} -