Devographics / Devographics/Monorepo
Multiple normalized responses for same survey with same userId
- 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.
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