Optimisation de la recherche + simplification

This commit is contained in:
xdrm-brackets 2016-05-27 10:51:05 +02:00
parent 66564f87db
commit 7378dc106a
7 changed files with 44 additions and 67 deletions

View File

@ -169,53 +169,7 @@
return $A == $B;
}
/* [1] On récupére la liste des sujets pour PHONE
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On récupère tous les sujets */
foreach($ids as $id){
$sub = $db->fetch($id)['subject'];
if( compareSearch($name, $sub['name']) ){
if( !isset($subjects[$id]) )
$subjects[$id] = $sub;
$subjects[$id]['phone'] = true;
}
}
/* (3) On ferme la bd */
$db->close();
/* [2] On récupére la liste des sujets pour FACEBOOK
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On récupère tous les sujets */
foreach($ids as $id){
$sub = $db->fetch($id)['subject'];
if( compareSearch($name, $sub['name']) ){
if( !isset($subjects[$id]) )
$subjects[$id] = $sub;
$subjects[$id]['facebook'] = true;
}
}
/* (3) On ferme la bd */
$db->close();
/* [3] On récupére la liste des sujets pour SURVEYS
/* [1] On récupére la liste des sujets
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
@ -226,18 +180,44 @@
$sub = $db->fetch($id)['subject'];
if( compareSearch($name, $sub['name']) ){
if( !isset($subjects[$id]) )
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
$subjects[$id] = $sub;
$subjects[$id]['survey'] = true;
$subjects[$id]['name'] = $sub['name'];
$subjects[$id]['creation'] = date('d/m/Y H:i:s', $sub['creation']);
}
}
/* (3) On ferme la bd */
/* [1] On récupére la liste des sujets pour PHONE
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On ferme la bd */
$db->close();
/* (3) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
foreach($subjects as $id=>$data)
if( in_array($id, $ids) ) // Si dans phone
$subjects[$id]['phone'] = true;
/* [2] On récupére la liste des sujets pour FACEBOOK
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On ferme la bd */
$db->close();
/* (3) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
foreach($subjects as $id=>$data)
if( in_array($id, $ids) ) // Si dans facebook
$subjects[$id]['facebook'] = true;
/* [4] Retour des données

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
[]
{"1":{"line":0,"hash":"af7f39edaef1c7c03ab4a2368ee37f62a8ba09e8"}}

View File

@ -1 +1 @@
1
283

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
var sField=$("#search-field"),sSubmit=$("#search-subject"),sList=$('section[data-sublink="survey"] ul[data-list]');
sSubmit.addEventListener("click",function(b){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c="",b;for(b in a.results)c+="<li data-element data-id='"+b+"'>",c+="<div data-user><span>SUJET</span></div>",c+="<div> <span><input type='text' readonly style='text-align: center' class='flag' value='"+b+"'></span> </div>",c+="<div> <span data-prefix='Nom'>"+a.results[b].name+"</span> </div>",
c+="<div> <span data-prefix='Cr\u00e9ation'>"+a.results[b].creation+"</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+b+"' "+(null!=a.results[b].survey?"checked":"")+" disabled><label for='s_"+b+"'>ResTIC</label>",c+="</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+b+"' "+(null!=a.results[b].facebook?"checked":"")+" disabled><label for='s_"+b+"'>Facebook</label>",c+="</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+b+"' "+(null!=a.results[b].phone?"checked":
"")+" disabled><label for='s_"+b+"'>Cellulaire</label>",c+="</span> </div>",c+="</li>";sList.innerHTML=c})},!1);var pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager;
sSubmit.addEventListener("click",function(b){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c="",b;for(b in a.results)c+="<li data-element data-id='"+b+"'>",c+="<div data-user><span>SUJET</span></div>",c+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+b+"'></span> </div>",c+="<div> <span data-prefix='Nom'>"+
a.results[b].name+"</span> </div>",c+="<div> <span data-prefix='Cr\u00e9ation'>"+a.results[b].creation+"</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+b+"' "+(null!=a.results[b].phone?"checked":"")+" disabled><label for='s_"+b+"'>Cellulaire</label>",c+="</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+b+"' "+(null!=a.results[b].facebook?"checked":"")+" disabled><label for='s_"+b+"'>Facebook</label>",c+="</span> </div>",c+="</li>";sList.innerHTML=c})},!1);
var pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager;
function pDynamicUpdate(b){var a=b instanceof Element,c=a&&"INPUT"==b.tagName&&"submit"==b.type,g=a&&"SPAN"==b.tagName&&("p_nav-mini"==b.parentNode.id||"p_nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"p_nav-contact"==b.parentNode.id;if(!c&&!g&&!a&&!0!==b)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();pMiniManager.storageToFields();
pFicheManager.storageToFields();pMatriceManager.storageToFields();(c||a)&&pContactManager.storageToFields()}
include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact-min.js",function(){include("/js/includes/input-phone-mini-min.js",function(){include("/js/includes/input-phone-fiche-min.js",function(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),

View File

@ -33,21 +33,18 @@ sSubmit.addEventListener('click', function(e){
htmlContent += "<div data-user><span>SUJET</span></div>";
htmlContent += "<div> <span><input type='text' readonly style='text-align: center' class='flag' value='"+id+"'></span> </div>";
htmlContent += "<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+id+"'></span> </div>";
htmlContent += "<div> <span data-prefix='Nom'>"+response.results[id].name+"</span> </div>";
htmlContent += "<div> <span data-prefix='Création'>"+response.results[id].creation+"</span> </div>";
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].survey!=null)?'checked':'')+" disabled><label for='s_"+id+"'>ResTIC</label>";
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].phone!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Cellulaire</label>";
htmlContent += "</span> </div>";
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].facebook!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Facebook</label>";
htmlContent += "</span> </div>";
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].phone!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Cellulaire</label>";
htmlContent += "</span> </div>";
htmlContent += "</li>";
}