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() != '')
|
if (filtro.Testo_Nota != null && filtro.Testo_Nota.trim() != '')
|
||||||
queryfi += " and Ann like '%" + 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);
|
var marray = JSON.parse(filtro.contesto);
|
||||||
console.log(marray[0].every( (val, i, arr) => val === 1 ))
|
var oplog=' and '
|
||||||
if (marray[0].every( (val, i, arr) => val === 1)){
|
var tfi=filtroContesto(marray[0], 'Inferno', oplog)
|
||||||
queryfi+=" and Cantica='Inferno'"
|
queryfi+=tfi
|
||||||
}
|
if (tfi.trim()!='')
|
||||||
else{
|
oplog=' or '
|
||||||
if (marray[0].some( (val, i, arr) => val === 1)){
|
tfi=''
|
||||||
var tearr=marray[0].reduce(function(tearr, n, i) { if (n===1) tearr.push(i); return tearr; },[] );
|
tfi=filtroContesto(marray[1], 'Purgatorio', oplog)
|
||||||
for (const ic in tearr){
|
if (tfi!=''){
|
||||||
var canto=tearr[ic].toString()
|
queryfi += tfi
|
||||||
if (tearr[ic] <10)
|
oplog=' or '
|
||||||
canto='0'+canto
|
}
|
||||||
if (ic==0)
|
queryfi += filtroContesto(marray[2], 'Paradiso', oplog)
|
||||||
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 rs = await tconn.query(querytl + queryfi)
|
var rs = await tconn.query(querytl + queryfi)
|
||||||
|
@ -221,7 +201,7 @@ export async function queryRiferimenti(filtro, cid) {
|
||||||
var numcid = cid.split('_')[1]
|
var numcid = cid.split('_')[1]
|
||||||
for (var cantica in resxcantica) {
|
for (var cantica in resxcantica) {
|
||||||
var $nctags = $(' .navig-canto')
|
var $nctags = $(' .navig-canto')
|
||||||
|
|
||||||
console.log(resxcantica[cantica].length)
|
console.log(resxcantica[cantica].length)
|
||||||
var i = 1;
|
var i = 1;
|
||||||
if (cantica == 'Purgatorio')
|
if (cantica == 'Purgatorio')
|
||||||
|
@ -232,8 +212,8 @@ export async function queryRiferimenti(filtro, cid) {
|
||||||
spanbadgecantica.attr('class', 'badge badge-warning badge-pill mx-2');
|
spanbadgecantica.attr('class', 'badge badge-warning badge-pill mx-2');
|
||||||
spanbadgecantica.append(resxcantica[cantica].length)
|
spanbadgecantica.append(resxcantica[cantica].length)
|
||||||
spanbadgecantica.appendTo($('#cantica' + i + '-badge'))
|
spanbadgecantica.appendTo($('#cantica' + i + '-badge'))
|
||||||
|
|
||||||
|
|
||||||
var tmp = resxcantica[cantica]
|
var tmp = resxcantica[cantica]
|
||||||
var resxcanto = Object.groupBy(tmp, ({ Canto }) => Canto);
|
var resxcanto = Object.groupBy(tmp, ({ Canto }) => Canto);
|
||||||
for (var canto in resxcanto) {
|
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