* 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>