Commit dca40325 authored by Clément Damiens's avatar Clément Damiens
Browse files

gosht answer script analyses

parent 87ed810f
......@@ -65,7 +65,45 @@ class DatamigrationController extends CommunecterController {
public function beforeAction($action) {
return parent::beforeAction($action);
}
public function actionAnswerWithGhostCter(){
$output="";
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$answersCter=PHDB::find(Answer::COLLECTION, array("cterSlug"=>array('$exists'=>true), "source.key"=>"ctenat"), array("cterSlug", "context", "_id"));
$output.="<h1>".count($answersCter)." réponses sont du ctenational</h1>";
$c=0; $arrayIds=[];
foreach($answersCter as $k => $v){
// var_dump($answersCter);
foreach($v["context"] as $cter=>$d){
if($d["type"] == Project::COLLECTION && !array_key_exists($cter, $arrayIds))
$arrayIds[$cter]= array("slug"=>$v["cterSlug"]);
}
$c++;
//if($c==30) break;
}
$output .= "<h1>Les réponses sont réparties sur ".count($arrayIds)." dispositifs";
$countOrph=0;
foreach($arrayIds as $id=> $slug){
$cter=PHDB::findOne(Project::COLLECTION,array("_id"=>new MongoId($id)), array("_id", "slug"));
if(empty($cter)){
$output.= "<h3>Le dispositifs ".$slug["slug"]." ".$id." n'existe plus</h3>";
//$orphAnswer=array_key_exists($id, $answersCter);
$orphAnswer=PHDB::find(Answer::COLLECTION, array("context.".$id=>array('$exists'=>true), "source.key"=>"ctenat"), array("cterSlug", "context", "_id","answers"));
$output.= "<span>Ce dispositif comporte ".count($orphAnswer)." réponses</span>";
$output.="<ul>";
$countOrph+=count($orphAnswer);
foreach($orphAnswer as $k => $v){
$output.="<li>".$k." : ".@$v["answers"]["project"]["name"]."</li>";
}
$output.="</ul>";
}
}
$output.='<h1>Au total, '.$countOrph.' réponses sont des gosthers</h1>';
return $output;
}else
return "the OulaOup: take auth bad robot";
}
public function actionAddLevel5ToCities(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment