Add og_url handling in InsertAnnunciInDB and extractData_update for improved Open Graph support

This commit is contained in:
Marco Pedone 2025-08-08 11:25:55 +02:00
parent c0bf6f5156
commit 3c63aa0eb8
2 changed files with 13 additions and 11 deletions

View file

@ -135,7 +135,8 @@ func (h *DbHandler) InsertAnnunciInDB(annunci AnnunciParsed) {
web = $43, web = $43,
homepage = $44, homepage = $44,
url_immagini = $45, url_immagini = $45,
url_video = $46 url_video = $46,
og_url = $48
WHERE codice = $47 WHERE codice = $47
`, annuncio.Locatore, annuncio.Numero, annuncio.Idlocatore, `, annuncio.Locatore, annuncio.Numero, annuncio.Idlocatore,
annuncio.Email, annuncio.Creato_il, annuncio.Modificato_il, annuncio.Email, annuncio.Creato_il, annuncio.Modificato_il,
@ -148,7 +149,7 @@ func (h *DbHandler) InsertAnnunciInDB(annunci AnnunciParsed) {
annuncio.Numero_balconi, annuncio.Numero_terrazzi, annuncio.Numero_box, annuncio.Numero_postiauto, annuncio.Numero_balconi, annuncio.Numero_terrazzi, annuncio.Numero_box, annuncio.Numero_postiauto,
annuncio.Caratteristiche, annuncio.Accessori, annuncio.Titolo_it, annuncio.Desc_it, annuncio.Titolo_en, annuncio.Caratteristiche, annuncio.Accessori, annuncio.Titolo_it, annuncio.Desc_it, annuncio.Titolo_en,
annuncio.Desc_en, annuncio.Stato, annuncio.Web, annuncio.Homepage, annuncio.Url_foto, annuncio.Desc_en, annuncio.Stato, annuncio.Web, annuncio.Homepage, annuncio.Url_foto,
annuncio.Url_video, annuncio.Codice) annuncio.Url_video, annuncio.Codice, annuncio.Og_url)
} else { } else {
batch.Queue(` batch.Queue(`
@ -199,9 +200,10 @@ func (h *DbHandler) InsertAnnunciInDB(annunci AnnunciParsed) {
homepage, homepage,
url_immagini, url_immagini,
url_video, url_video,
codice codice,
og_url
) )
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46, $47, $48)
`, annuncio.Locatore, annuncio.Numero, annuncio.Idlocatore, `, annuncio.Locatore, annuncio.Numero, annuncio.Idlocatore,
annuncio.Email, annuncio.Creato_il, annuncio.Modificato_il, annuncio.Email, annuncio.Creato_il, annuncio.Modificato_il,
annuncio.Indirizzo, annuncio.Civico, annuncio.Comune, annuncio.Cap, annuncio.Indirizzo, annuncio.Civico, annuncio.Comune, annuncio.Cap,
@ -213,7 +215,7 @@ func (h *DbHandler) InsertAnnunciInDB(annunci AnnunciParsed) {
annuncio.Numero_balconi, annuncio.Numero_terrazzi, annuncio.Numero_box, annuncio.Numero_postiauto, annuncio.Numero_balconi, annuncio.Numero_terrazzi, annuncio.Numero_box, annuncio.Numero_postiauto,
annuncio.Caratteristiche, annuncio.Accessori, annuncio.Titolo_it, annuncio.Desc_it, annuncio.Titolo_en, annuncio.Caratteristiche, annuncio.Accessori, annuncio.Titolo_it, annuncio.Desc_it, annuncio.Titolo_en,
annuncio.Desc_en, annuncio.Stato, annuncio.Web, annuncio.Homepage, annuncio.Url_foto, annuncio.Desc_en, annuncio.Stato, annuncio.Web, annuncio.Homepage, annuncio.Url_foto,
annuncio.Url_video, annuncio.Codice) annuncio.Url_video, annuncio.Codice, annuncio.Og_url)
} }
} }

View file

@ -214,7 +214,12 @@ func extractData_update(annuncio *AnnuncioXML, updateImages bool) AnnuncioParsed
} }
tmpcaratt := parseCaratteristiche(annuncio) tmpcaratt := parseCaratteristiche(annuncio)
tmp.Caratteristiche = &tmpcaratt tmp.Caratteristiche = &tmpcaratt
tmp.Og_url = nil
if len(*annuncio.Foto) != 0 {
fotos := *annuncio.Foto
first := fotos[0]
tmp.Og_url = &first
}
if updateImages { if updateImages {
processImages(&tmp, annuncio) processImages(&tmp, annuncio)
} }
@ -373,11 +378,6 @@ func processImages(tmp *AnnuncioParsed, annuncio *AnnuncioXML) {
if annuncio.Foto != nil { if annuncio.Foto != nil {
fotos = *annuncio.Foto fotos = *annuncio.Foto
} }
tmp.Og_url = nil
if len(fotos) != 0 {
first := fotos[0]
tmp.Og_url = &first
}
for _, url := range fotos { for _, url := range fotos {
fmt.Println("Processing image", url) fmt.Println("Processing image", url)
imgpath := filepath.Join(path, fmt.Sprintf("%d", nfoto)) imgpath := filepath.Join(path, fmt.Sprintf("%d", nfoto))