Skip to content
Snippets Groups Projects
Commit 6f599fdb authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

fix database update

parent 8fce1352
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ time npx tsx src/scripts/cesium-plus-import.ts ...@@ -37,6 +37,7 @@ time npx tsx src/scripts/cesium-plus-import.ts
To start pubsub collector to IPFS and database indexer To start pubsub collector to IPFS and database indexer
```sh ```sh
docker compose up -d
npx tsx src/indexer/start.ts npx tsx src/indexer/start.ts
``` ```
......
...@@ -54,18 +54,23 @@ export async function setLatestIndexedCID(cid: CID) { ...@@ -54,18 +54,23 @@ export async function setLatestIndexedCID(cid: CID) {
} }
// cesium plus profile query and param builder // cesium plus profile query and param builder
// completely overwrites previous data
const cesiumPlusProfile: QueryBuilder = { const cesiumPlusProfile: QueryBuilder = {
query: `INSERT INTO query: `INSERT INTO
profiles(index_request_cid, time, pubkey, data_cid, title, description, avatar, geoloc, city, socials) profiles(index_request_cid, time, pubkey, data_cid, title, description, avatar, geoloc, city, socials)
VALUES ($1, $2, $3, $4, $5, $6, $7, point($8, $9), $10, $11) VALUES ($1, $2, $3, $4, $5, $6, $7, point($8, $9), $10, $11)
ON CONFLICT (pubkey) ON CONFLICT (pubkey)
DO UPDATE SET DO UPDATE SET
title = COALESCE(EXCLUDED.title, profiles.title), index_request_cid = EXCLUDED.index_request_cid,
description = COALESCE(EXCLUDED.description, profiles.description), time = EXCLUDED.time,
avatar = COALESCE(EXCLUDED.avatar, profiles.avatar), pubkey = EXCLUDED.pubkey,
geoloc = COALESCE(EXCLUDED.geoloc, profiles.geoloc), data_cid = EXCLUDED.data_cid,
city = COALESCE(EXCLUDED.city, profiles.city), title = EXCLUDED.title,
socials = COALESCE(EXCLUDED.socials, profiles.socials); description = EXCLUDED.description,
avatar = EXCLUDED.avatar,
geoloc = EXCLUDED.geoloc,
city = EXCLUDED.city,
socials = EXCLUDED.socials;
`, `,
paramBuilder: (irCID: CID, ir: IndexRequest, dataCID: CID, data: CplusProfile) => [ paramBuilder: (irCID: CID, ir: IndexRequest, dataCID: CID, data: CplusProfile) => [
// $1 index_request_cid // $1 index_request_cid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment