gestione risultati riferimenti, in progress

This commit is contained in:
cesare 2025-03-17 12:54:06 +01:00
parent 3d6dd39eb4
commit fad6685656
2 changed files with 47 additions and 26 deletions

View File

@ -1721,8 +1721,8 @@ $(document).ready(function() {
listaRisultatiCommenti = await queryRiferimentimul(jsonQuery, cantoDisplayed) listaRisultatiCommenti = await queryRiferimentimul(jsonQuery, cantoDisplayed)
} }
//carico i commenti risultato della query //carico i commenti risultato della query
var tmpresu=getRisultatiRiferimenti() //var tmpresu=getRisultatiRiferimenti()
commentsSQL = Object.groupBy(tmpresu, ({ VersoCitazione }) => VersoCitazione); //commentsSQL = Object.groupBy(tmpresu, ({ VersoCitazione }) => VersoCitazione);
showRisultatiCommenti(listaRisultatiCommenti) showRisultatiCommenti(listaRisultatiCommenti)
return return
} }

View File

@ -9,8 +9,9 @@ var rif_autori = [];
var rif_areetematiche = []; var rif_areetematiche = [];
var rif_fonti = []; var rif_fonti = [];
var listaidversi = [] var listaidversi = []
var listaversicommentati=[]
var listaidcommenti = [] var listaidcommenti = []
var listarisriferimenti=[] var listarisriferimenti = []
const cantobadgeclassBis = 'badge badge-outline-warning badge-pill' const cantobadgeclassBis = 'badge badge-outline-warning badge-pill'
const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles(); const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
@ -78,9 +79,25 @@ const result4 = table1.toArray().map((row) => row.toJSON());
//console.log(result4) //console.log(result4)
rif_fonti = result4.map((x) => x['TiFo']); rif_fonti = result4.map((x) => x['TiFo']);
//console.log(rif_fonti) var querytl = 'select IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti order by n1, n2, n3'
var tablerif = await conn.query(querytl);
const result5 = tablerif.toArray().map((row) => row.toJSON());
var allreferences = Object.groupBy(result5, ({ Cantica }) => Cantica);
for (var cantica in allreferences) {
var tmp = allreferences[cantica]
for (var el of tmp) {
var tmpc = el.Canto
if (tmpc.startsWith('0'))
tmpc = tmpc.replace('0', '')
let ordveid = el.Cantica + '_Canto_' + tmpc + '_' + el.Verso.split('-')[0] + '_sp'
listaversicommentati.push(ordveid)
}
}
listaversicommentati=[...new Set(listaversicommentati)]
/*var tableP = await conn.query(` /*var tableP = await conn.query(`
select * from commedia limit 10; select * from commedia limit 10;
`); `);
const result5 = tableP.toArray().map((row) => row.toJSON()); const result5 = tableP.toArray().map((row) => row.toJSON());
console.log(result5)*/ console.log(result5)*/
@ -91,7 +108,11 @@ console.log('done')
opzioniRiferimenti() opzioniRiferimenti()
export function getRisultatiRiferimenti(){ export function versoCommentato(rif) {
return listaversicommentati.includes(rif);
}
export function getRisultatiRiferimenti() {
return listarisriferimenti; return listarisriferimenti;
} }
export function getListaRis() { export function getListaRis() {
@ -103,7 +124,7 @@ export function getListaIdCommenti() {
export function cleanListaRis() { export function cleanListaRis() {
listaidversi = []; listaidversi = [];
listaidcommenti = []; listaidcommenti = [];
listarisriferimenti=[]; listarisriferimenti = [];
} }
export function getFontiS() { export function getFontiS() {
@ -276,14 +297,14 @@ export async function queryRiferimentimul(query, cid) {
var jsonclauses = JSON.parse(rifclauses) var jsonclauses = JSON.parse(rifclauses)
tmpc = '' tmpc = ''
for (var cls in jsonclauses) { for (var cls in jsonclauses) {
wherecl += '('+getWherePart(jsonclauses[cls], query, cls)+')' wherecl += '(' + getWherePart(jsonclauses[cls], query, cls) + ')'
} }
console.log(wherecl) console.log(wherecl)
const tconn = await db.connect(); const tconn = await db.connect();
var querytl = 'select IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti' var querytl = 'select DISTINCT IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti'
var rs = await tconn.query(querytl + wherecl+' order by n1, n2, n3') var rs = await tconn.query(querytl + wherecl + ' order by n1, n2, n3')
var result4 = rs.toArray().map((row) => row.toJSON()); var result4 = rs.toArray().map((row) => row.toJSON());
await tconn.close(); await tconn.close();
@ -325,16 +346,16 @@ function showResult(resxcantica, cid) {
spanbadgecantica.appendTo($('#cantica' + i + '-badge')) spanbadgecantica.appendTo($('#cantica' + i + '-badge'))
var tmp = resxcantica[cantica] var tmp = resxcantica[cantica]
for (var el of tmp){ for (var el of tmp) {
var tmpc=el.Canto var tmpc = el.Canto
if (tmpc.startsWith('0')) { if (tmpc.startsWith('0')) {
tmpc = tmpc.replace('0', '') tmpc = tmpc.replace('0', '')
} }
let ordveid = el.Cantica + '_Canto_' + tmpc + '_' + el.Verso.split('-')[0]+'_sp' let ordveid = el.Cantica + '_Canto_' + tmpc + '_' + el.Verso.split('-')[0] + '_sp'
listaidversi.push(ordveid) listaidversi.push(ordveid)
} }
var resxcanto = Object.groupBy(tmp, ({ Canto }) => Canto); var resxcanto = Object.groupBy(tmp, ({ Canto }) => Canto);
for (var canto in resxcanto) { for (var canto in resxcanto) {
var tmpv = resxcanto[canto] var tmpv = resxcanto[canto]
@ -346,7 +367,7 @@ function showResult(resxcantica, cid) {
} }
spanbadge.appendTo($nctags.filter('[name="' + cantica + 'Canto ' + canto + '"]')) spanbadge.appendTo($nctags.filter('[name="' + cantica + 'Canto ' + canto + '"]'))
for (const tmpvi of tmpv) { for (const tmpvi of tmpv) {
let myveid = cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0].replace('|','')+'_sp' let myveid = cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0].replace('|', '') + '_sp'
//listaidversi.push(myveid) //listaidversi.push(myveid)
listaidcommenti.push(tmpvi.IdRiferimento) //Nico listaidcommenti.push(tmpvi.IdRiferimento) //Nico
if (cid.includes(cantica) && numcid == canto) if (cid.includes(cantica) && numcid == canto)
@ -375,7 +396,7 @@ export async function queryRiferimenti(filtro, cid) {
} }
const tconn = await db.connect(); const tconn = await db.connect();
var tmpfiltro = '' var tmpfiltro = ''
var querytlcompl=`SELECT Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione, var querytlcompl = `SELECT Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione,
F as FonteCitazione, LF as LuogoFonteCitazione, NF as NotaFonteCitazione, F as FonteCitazione, LF as LuogoFonteCitazione, NF as NotaFonteCitazione,
TF as TestoFonteCitazione, UF as URLFonteCitazione, NaRi as NaturaRiferimento, TF as TestoFonteCitazione, UF as URLFonteCitazione, NaRi as NaturaRiferimento,
RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto, RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto,
@ -383,7 +404,7 @@ export async function queryRiferimenti(filtro, cid) {
TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie, TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie,
CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento, n1, n2, n3, CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento, n1, n2, n3,
Cantica, Canto, Verso FROM riferimenti` Cantica, Canto, Verso FROM riferimenti`
var querytl = 'select IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti' var querytl = 'select DISTINCT IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti'
var queryfi = ' where ' var queryfi = ' where '
if (filtro.Commentatore != null && filtro.Commentatore.trim() != 'all') { if (filtro.Commentatore != null && filtro.Commentatore.trim() != 'all') {
tmpfiltro = filtro.Commentatore.trim() tmpfiltro = filtro.Commentatore.trim()
@ -447,15 +468,15 @@ export async function queryRiferimenti(filtro, cid) {
queryfi += ")" queryfi += ")"
} }
//var rs = await tconn.query(querytl + queryfi+ ' order by n1, n2, n3;') var rs = await tconn.query(querytl + queryfi + ' order by n1, n2, n3;')
var rs = await tconn.query(querytlcompl + queryfi+ ' order by n1, n2, n3;') //var rs = await tconn.query(querytlcompl + queryfi+ ' order by n1, n2, n3;')
listarisriferimenti = rs.toArray().map((row) => row.toJSON()); listarisriferimenti = rs.toArray().map((row) => row.toJSON());
await tconn.close(); await tconn.close();
var resxcantica = Object.groupBy(listarisriferimenti, ({ Cantica }) => Cantica); var resxcantica = Object.groupBy(listarisriferimenti, ({ Cantica }) => Cantica);
return (showResult(resxcantica, cid)) return (showResult(resxcantica, cid))
} }
/*function sortRiferimenti(canticaArray,arrayValues){ /*function sortRiferimenti(canticaArray,arrayValues){
@ -540,7 +561,7 @@ function filtroContesto(marray, cantica, op) {
//Contesto per lista risultati //Contesto per lista risultati
export async function getFormaCntxtLastPosition(formaid, numversi = 3) { export async function getFormaCntxtLastPosition(formaid, numversi = 3) {
/*const tconn = await db.connect(); /*const tconn = await db.connect();
var querycnt = "select * from commedia where index>=((select index from commedia where Position='" + formaid + "')-25) order by index limit 50" var querycnt = "select * from commedia where index>=((select index from commedia where Position='" + formaid + "')-25) order by index limit 50"
console.log(" " + formaid) console.log(" " + formaid)
@ -554,6 +575,6 @@ export async function getFormaCntxtLastPosition(formaid, numversi = 3) {
await tconn.close(); await tconn.close();
return (result4.at(-1)['Position'])*/ return (result4.at(-1)['Position'])*/
return return
} }