* fix: deduplicate postgres sorted set bulk ops to prevent pkey violation
sortedSetIncrByBulk and sortedSetAddBulk did not deduplicate (key, value)
pairs before INSERT, causing "duplicate key value violates unique constraint
legacy_zset_pkey" errors since PostgreSQL ON CONFLICT only resolves against
existing table rows, not within-statement duplicates.
Also adds missing pageviews:ap metrics to analyticsKeys sorted set.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use upsert with RETURNING to prevent postgres analytics write failures
Replace the INSERT ON CONFLICT DO NOTHING + separate SELECT verification
pattern with INSERT ON CONFLICT DO UPDATE RETURNING. The old pattern had
an unreliable gap between INSERT and SELECT causing random "failed to
insert keys for objects" errors that blocked all analytics writes.
The no-op upsert (DO UPDATE SET type = existing type) guarantees every
row is returned via RETURNING, eliminating the need for a separate SELECT
and the "missing keys" check entirely. Also deduplicates the keys array
to prevent "cannot affect row a second time" errors with DO UPDATE.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: start tracking which cids a user has posted to, update account pages' topics/posts view to call this new sorted set
re: #14113
* feat: upgrade script for #14113
* fix: cids unavailable in getPostsFields, duh
* fix: update sortedSetIncrByBulk in mongo/psql to return early on empty data
* fix: remove unused lodash require
* test: sortedSetIncrBy and sortedSetIncrByBulk tests
* test: who needs null checks anyway
* fix: sortedSetIncrByBulk null response
* test: aggregate zincrbulk data
if there are alot of identical key/value pairs they will be combined into a single row
* fix: key name
* test: fix test name
* lint: fix lint issues
* test: negative values should work too
* fix: add e11000 handler for incrByBulk
* refactor: fix variable name
* merge tests with existing zset test, remove dupes
* test: return topicData for failing test
* delete uid:<uid>:cids on user delete
---------
Co-authored-by: Barış Soner Uşaklı <barisusakli@gmail.com>
* refactor: start migrating to node-redis
* few more zset fixes
* fix: db.scan
* fix: list methods
* fix set methods
* fix: hash methods
* use hasOwn, remove cloning
* sorted set fixes
* fix: so data is converted to strings before saving
otherwise node-redis throws below error
TypeError: "arguments[2]" must be of type "string | Buffer", got number instead.
* chore: remove comments
* fix: zrank string param
* use new close
* chore: up dbsearch
* test: add log
* test: more log
* test: log failing test
* test: catch errors in formatApiResponse
add await so exception goes to catch
* tetst: add log
* fix: dont set null/undefined values
* test: more fixes
* list remove all
* one more test
* sortedSetIncrByBulk
* remove name
* incrObjectFieldByBulk
* test: disable api tests
* try merge
* another test
* give upon bulk incr
* update so answer
* one more try
* fix: name
* chore: up dbsearch
commit 4e0e792232
Merge: 24d0999fb570b4a0e2ae
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date: Fri Jun 7 19:26:49 2024 -0400
Merge branch 'master' into develop
commit 70b4a0e2ae
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date: Fri Jun 7 19:14:13 2024 -0400
feat: allow passing min,max to sortedSetsCardSum
to get rid of multiple db calls in profile page
commit 6bbe3d1c4c
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date: Fri Jun 7 14:08:48 2024 -0400
fix: dont show error alert when user user mouse overs votes
if they dont have permission to view votes
commit 24d0999fb5
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu Jun 6 13:49:14 2024 -0400
fix(deps): update dependency pg-cursor to v2.11.0 (#12617)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
commit bee05fe212
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu Jun 6 13:28:59 2024 -0400
fix(deps): update dependency pg to v8.12.0 (#12616)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>