Devographics / Devographics/Monorepo

Multiple normalized responses for same survey with same userId

Open
#465 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
178
Forks
55
Avg merge
1m
Merged PRs (30d)
2

Description

I noticed that for some older surveys we seem to have multiple copies of the same survey for the same user, which should in theory not be possible.

It's probably some bug due to importing those responses from a previous system, but I thought I'd make a note of it.

Screenshot 2024-11-28 at 11 26 21

Aggregation used:

```
[
{
// Filter documents where both userId and editionId exist
$match: {
userId: {
$exists: true,
$ne: null
},
editionId: {
$exists: true,
$ne: null
}
}
},
{
// Group by userId and editionId
$group: {
_id: {
userId: "$userId",
editionId: "$editionId"
},
count: {
$sum: 1
} // Count the documents in each group
}
},
{
// Optional: Sort by count in descending order
$sort: {
count: -1
}
},
{
// Optional: Project the fields for better readability
$project: {
_id: 0,
// Hide the _id field
userId: "$_id.userId",
editionId: "$_id.editionId",
count: 1
}
}
]
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the supplied aggregation, which identifies repeated normalized responses by userId and editionId. The issue names no files, tests, or desired remediation, so the affected import path and completion criteria would need to be established before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.