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

only update profile is new timestamp is higher

prevents older data to modify newer data
parent 12963eb9
No related branches found
No related tags found
No related merge requests found
...@@ -71,23 +71,24 @@ export async function setLatestIndexedCID(cid: CID) { ...@@ -71,23 +71,24 @@ export async function setLatestIndexedCID(cid: CID) {
} }
// cesium plus profile query and param builder // cesium plus profile query and param builder
// completely overwrites previous data // completely overwrites previous data if new timestamp is higher
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
index_request_cid = EXCLUDED.index_request_cid, index_request_cid = EXCLUDED.index_request_cid,
time = EXCLUDED.time, time = EXCLUDED.time,
pubkey = EXCLUDED.pubkey, pubkey = EXCLUDED.pubkey,
data_cid = EXCLUDED.data_cid, data_cid = EXCLUDED.data_cid,
title = EXCLUDED.title, title = EXCLUDED.title,
description = EXCLUDED.description, description = EXCLUDED.description,
avatar = EXCLUDED.avatar, avatar = EXCLUDED.avatar,
geoloc = EXCLUDED.geoloc, geoloc = EXCLUDED.geoloc,
city = EXCLUDED.city, city = EXCLUDED.city,
socials = EXCLUDED.socials; socials = EXCLUDED.socials;
WHERE EXCLUDED.time > profiles.time;
`, `,
dataGetter: defaultDataGetter, dataGetter: defaultDataGetter,
dataTransform: defaultDataTransform, dataTransform: defaultDataTransform,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment