diff --git a/apps/backend/from_bkp.go b/apps/backend/from_bkp.go index ffa2191..9ddd500 100644 --- a/apps/backend/from_bkp.go +++ b/apps/backend/from_bkp.go @@ -9,6 +9,7 @@ import ( "io" "os" "slices" + "strconv" "strings" "sync" "time" @@ -120,7 +121,15 @@ func extractData_bkp(annuncio typesdefs.AnnuncioBKP, extractedData chan typesdef *tmp.Categorie = resultArray } - tmp.Mq = utils.CommaToDot(annuncio.Mq) + if annuncio.Mq != nil { + replaced := strings.ReplaceAll(*annuncio.Mq, ",", ".") + if s, err := strconv.ParseFloat(replaced, 64); err == nil { + fmt.Printf("%T, %v\n", s, s) + tmp.Mq = &s + } + + } + tmp.Piano = annuncio.Piano tmp.Piano_palazzo = annuncio.PianoPalazzo tmp.Unita_condominio = annuncio.UnitaImmobiliari diff --git a/apps/backend/miogest_handler.go b/apps/backend/miogest_handler.go index f62987b..9b53e1d 100644 --- a/apps/backend/miogest_handler.go +++ b/apps/backend/miogest_handler.go @@ -10,6 +10,7 @@ import ( "reflect" "regexp" "slices" + "strconv" "strings" "time" @@ -367,8 +368,12 @@ func processDatiImmobile(tmp *typesdefs.AnnuncioParsed, annuncio *typesdefs.Annu tmp.Prezzo = parser.ParsePrezzo(annuncio.Prezzo) tmp.Classe = annuncio.Classe if annuncio.Mq != nil { - replaced := strings.ReplaceAll(*annuncio.Mq, ",", "") - tmp.Mq = &replaced + replaced := strings.ReplaceAll(*annuncio.Mq, ",", ".") + if s, err := strconv.ParseFloat(replaced, 64); err == nil { + fmt.Printf("%T, %v\n", s, s) + tmp.Mq = &s + } + } tmp.Piano = annuncio.Piano tmp.Piano_palazzo = annuncio.PianiCondominio diff --git a/apps/backend/typesdefs/models.go b/apps/backend/typesdefs/models.go index e67f468..01b10fc 100644 --- a/apps/backend/typesdefs/models.go +++ b/apps/backend/typesdefs/models.go @@ -239,7 +239,7 @@ type AnnuncioParsed struct { Lon *string Lon_secondario *string Modificato_il *time.Time - Mq *string + Mq *float64 Piano_palazzo *string Piano *string Numero_postiauto *string @@ -288,7 +288,7 @@ type AnnunciDB struct { Anno *string Consegna *string Classe *string - Mq *string + Mq *float64 Piano *string Piano_palazzo *int Unita_condominio *int diff --git a/apps/infoalloggi/.kanelrc.js b/apps/infoalloggi/.kanelrc.js index dc0608f..a2ae8f9 100644 --- a/apps/infoalloggi/.kanelrc.js +++ b/apps/infoalloggi/.kanelrc.js @@ -11,6 +11,7 @@ module.exports = { password: "rootpost", port: 5433, }, + typeFilter: (pgType) => !ignoredTables.includes(pgType.name), preDeleteOutputFolder: true, outputPath: "./src/schemas", @@ -18,7 +19,9 @@ module.exports = { customTypeMap: { "pg_catalog.tsvector": "string", "pg_catalog.bpchar": "string", + 'pg_catalog.numeric': 'number', //"pg_catalog.json": "string", }, preRenderHooks: [makeKyselyHook()], + }; diff --git a/apps/infoalloggi/src/components/annuncio_card.tsx b/apps/infoalloggi/src/components/annuncio_card.tsx index 58d6281..c7e8239 100644 --- a/apps/infoalloggi/src/components/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/annuncio_card.tsx @@ -339,7 +339,7 @@ export const CardAnnuncio = ({
- {mq ? Number.parseFloat(mq) : 0}{" "}
+ {mq ? Number(mq).toLocaleString("it-IT") : "--"}{" "}
m2
diff --git a/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx b/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx
index f16eabb..e78261d 100644
--- a/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx
+++ b/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx
@@ -84,7 +84,7 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
locatore: z.string().nullable(),
lon: z.string().nullable(),
lon_secondario: z.string().nullable(),
- mq: z.string().nullable(),
+ mq: z.number().nullable(),
numero: z.string().nullable(),
numero_bagni: z.number().nullable(),
numero_balconi: z.number().nullable(),
@@ -1259,28 +1259,32 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {