Skip to content

fix: Duplicate user data is appearing in the user table at /user/admin#10940

Merged
yuki-takei merged 1 commit intomasterfrom
fix/180705-duplicate-user-data-is-appearing-in-the-user-table
Mar 27, 2026
Merged

fix: Duplicate user data is appearing in the user table at /user/admin#10940
yuki-takei merged 1 commit intomasterfrom
fix/180705-duplicate-user-data-is-appearing-in-the-user-table

Conversation

@miya
Copy link
Copy Markdown
Member

@miya miya commented Mar 27, 2026

@miya miya requested a review from yuki-takei March 27, 2026 06:24
@miya miya self-assigned this Mar 27, 2026

async resetAllChanges() {
await this.setState({
sort: 'id',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

バグの原因

デフォルトのソートキーが id でしたが、MongoDB のフィールドは _id で実質ソートなしの状態だった

sort: 'id',
sortOrder: 'asc',
sort: 'createdAt',
sortOrder: 'desc',
Copy link
Copy Markdown
Member Author

@miya miya Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正方針

MongoDB の ObjectId でソートする意味はないと思うので作成日降順でソートする (恣意的かもしれない...)

補足

初回レンダリング時のデフォルトのソートキーが id になっていたが、UI 上からリセット以外で id でソートすることはできない

const sortOutput = {
[sort]: sortOrder === 'desc' ? -1 : 1,
// tiebreaker: ensure stable pagination when the primary sort key has duplicate values
_id: 1,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user.status なのユニーク制約がないものでソートする場合の副次的なキー

@yuki-takei yuki-takei merged commit 85a160c into master Mar 27, 2026
21 checks passed
@yuki-takei yuki-takei deleted the fix/180705-duplicate-user-data-is-appearing-in-the-user-table branch March 27, 2026 10:40
@github-actions github-actions Bot mentioned this pull request Mar 27, 2026
This was referenced Apr 15, 2026
@github-actions github-actions Bot mentioned this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants