-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(game): add sort_title
field and backfill command
#2690
feat(game): add sort_title
field and backfill command
#2690
Conversation
$action = new WriteGameSortTitleFromGameTitleAction(); | ||
Game::query()->chunk(100, function ($games) use ($progressBar, $action) { | ||
foreach ($games as $game) { | ||
$action->execute($game, $game->title, shouldRespectCustomSortTitle: false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be overly ambitious to re-normalize articles?
Legend of Zelda, The: A Link to the Past
=> The Legend of Zelda: A Link to the Past
with a sort title of just legend of zelda: a link to the past
Bug's Life, A
=> A Bug's Life
with a sort title of bug's life
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tricky, but I think I got it in latest. Added a few tests which seem to verify the new behavior is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, would you like to also see the game titles themselves readjust the placement of the articles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the goal state. Per #1062:
Ignore definite and indefinite articles at the start of titles so we don't have to rename them to force the correct sorting order.
Doing so now would break the sort order until the queries were updated to use the new sort column.
database/migrations/platform/2024_09_12_000000_update_gamedata_table.php
Outdated
Show resolved
Hide resolved
tests/Feature/Platform/Action/WriteGameSortTitleFromGameTitleActionTest.php
Show resolved
Hide resolved
$action = new WriteGameSortTitleFromGameTitleAction(); | ||
Game::query()->chunk(100, function ($games) use ($progressBar, $action) { | ||
foreach ($games as $game) { | ||
$action->execute($game, $game->title, shouldRespectCustomSortTitle: false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the goal state. Per #1062:
Ignore definite and indefinite articles at the start of titles so we don't have to rename them to force the correct sorting order.
Doing so now would break the sort order until the queries were updated to use the new sort column.
Implements #1062.
Developed to resolve the performance issue mentioned in #2686 (comment).
sail artisan ra:platform:write-game-sort-titles 1 # write by ID
sail artisan ra:platform:write-game-sort-titles # write them all
This PR adds a
sort_title
field to theGameData
table.We are actually already using this field on most game lists. However, it is computed on the fly in memory by PHP.
This PR's changeset simply moves that logic to a database column, ensures it's written to when the game title changes, and allows moderators/admins to override the field in the management app.
If a custom
sort_title
is provided, the new action is smart enough to detect this and not override it.