query riferimenti,contesti
This commit is contained in:
parent
0c331d4228
commit
15e8377e48
|
@ -175,40 +175,20 @@ export async function queryRiferimenti(filtro, cid) {
|
|||
|
||||
if (filtro.Testo_Nota != null && filtro.Testo_Nota.trim() != '')
|
||||
queryfi += " and Ann like '%" + filtro.Testo_Nota.trim() + "%'"
|
||||
if (filtro.contesto!=null){
|
||||
if (filtro.contesto != null) {
|
||||
var marray = JSON.parse(filtro.contesto);
|
||||
console.log(marray[0].every( (val, i, arr) => val === 1 ))
|
||||
if (marray[0].every( (val, i, arr) => val === 1)){
|
||||
queryfi+=" and Cantica='Inferno'"
|
||||
}
|
||||
else{
|
||||
if (marray[0].some( (val, i, arr) => val === 1)){
|
||||
var tearr=marray[0].reduce(function(tearr, n, i) { if (n===1) tearr.push(i); return tearr; },[] );
|
||||
for (const ic in tearr){
|
||||
var canto=tearr[ic].toString()
|
||||
if (tearr[ic] <10)
|
||||
canto='0'+canto
|
||||
if (ic==0)
|
||||
queryfi+="and Cantica='Inferno' and (Canto='"+canto+"'"
|
||||
else
|
||||
queryfi+=" or Canto='"+canto+"'"
|
||||
|
||||
}
|
||||
if (tearr.length)
|
||||
queryfi+=")"
|
||||
console.log(queryfi)
|
||||
}
|
||||
}
|
||||
// var array = [1, 2, 3, 4, 3].reduce(function(array, n, i) { if (n===3) array.push(i); return array; },[] );
|
||||
|
||||
if (marray[1].every( (val, i, arr) => val === 1)){
|
||||
|
||||
queryfi+=" and Cantica='Purgatorio'"
|
||||
}
|
||||
if (marray[2].every( (val, i, arr) => val === 1)){
|
||||
|
||||
queryfi+=" and Cantica='Paradiso'"
|
||||
}
|
||||
var oplog=' and '
|
||||
var tfi=filtroContesto(marray[0], 'Inferno', oplog)
|
||||
queryfi+=tfi
|
||||
if (tfi.trim()!='')
|
||||
oplog=' or '
|
||||
tfi=''
|
||||
tfi=filtroContesto(marray[1], 'Purgatorio', oplog)
|
||||
if (tfi!=''){
|
||||
queryfi += tfi
|
||||
oplog=' or '
|
||||
}
|
||||
queryfi += filtroContesto(marray[2], 'Paradiso', oplog)
|
||||
}
|
||||
|
||||
var rs = await tconn.query(querytl + queryfi)
|
||||
|
@ -221,7 +201,7 @@ export async function queryRiferimenti(filtro, cid) {
|
|||
var numcid = cid.split('_')[1]
|
||||
for (var cantica in resxcantica) {
|
||||
var $nctags = $(' .navig-canto')
|
||||
|
||||
|
||||
console.log(resxcantica[cantica].length)
|
||||
var i = 1;
|
||||
if (cantica == 'Purgatorio')
|
||||
|
@ -232,8 +212,8 @@ export async function queryRiferimenti(filtro, cid) {
|
|||
spanbadgecantica.attr('class', 'badge badge-warning badge-pill mx-2');
|
||||
spanbadgecantica.append(resxcantica[cantica].length)
|
||||
spanbadgecantica.appendTo($('#cantica' + i + '-badge'))
|
||||
|
||||
|
||||
|
||||
|
||||
var tmp = resxcantica[cantica]
|
||||
var resxcanto = Object.groupBy(tmp, ({ Canto }) => Canto);
|
||||
for (var canto in resxcanto) {
|
||||
|
@ -288,4 +268,28 @@ function opzioniRiferimenti() {
|
|||
};
|
||||
});
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
function filtroContesto(marray, cantica, op) {
|
||||
var filtrost = ''
|
||||
if (marray.every((val, i, arr) => val === 1)) {
|
||||
return " and Cantica='"+cantica+"'"
|
||||
}
|
||||
if (marray.some((val, i, arr) => val === 1)) {
|
||||
var tearr = marray.reduce(function(tearr, n, i) { if (n === 1) tearr.push(i); return tearr; }, []);
|
||||
for (const ic in tearr) {
|
||||
var canto = (tearr[ic]+1).toString()
|
||||
if ((tearr[ic]+1) < 10)
|
||||
canto = '0' + canto
|
||||
if (ic == 0)
|
||||
filtrost += op+" (Cantica='"+cantica+"' and (Canto='" + canto + "'"
|
||||
else
|
||||
filtrost += " or Canto='" + canto + "'"
|
||||
|
||||
}
|
||||
if (tearr.length)
|
||||
filtrost += "))"
|
||||
console.log(filtrost)
|
||||
}
|
||||
return filtrost
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue