-
-
Notifications
You must be signed in to change notification settings - Fork 103
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): sync tags to the taggables table #2963
feat(game): sync tags to the taggables table #2963
Conversation
What does the |
|
Yea, I figured that out. Couldn't get that query to return any results no matter how much I changed the name of a different game. |
app/Models/Game.php
Outdated
@@ -157,6 +160,17 @@ public static function boot() | |||
} | |||
} | |||
} | |||
|
|||
// Double write to taggables for both new and updated games. | |||
if ($originalTitle !== $freshGame->title || $game->wasRecentlyCreated) { |
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.
Why isn't the wasRecentlyCreated
logic required for the WriteGameSortTitleFromGameTitleAction
call? Shouldn't both dependencies always be updated at the same time?
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.
In createNewGame()
, we have this line:
$game->sort_title = (new ComputeGameSortTitleAction())->execute($title);
It's being optimistically written on create rather than written as the product of an event.
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.
This does seem like a bit of an inconsistency. It seems like we have three possible paths to choose from:
- Do nothing, keep things as-is.
- Remove that line from
createNewGame()
, handle it inboot()
. - Keep that line in
createNewGame()
, and also handle tag syncing in that function too.
After weighing the pros & cons of each, I lean towards moving everything into boot()
. What do you think?
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.
I went with option 2. I've removed the optimistic write in createNewGame()
so everything is now being handled in boot()
.
This PR begins the initial work of migrating tags (
~Hack~
,~Homebrew~
,~Prototype~
, etc) out of game titles and into structured data powered byspatie/laravel-tags
.There are two new behaviors included in this PR:
GameData
.How to test this PR
After running the command, you should observe in your database that the
tags
andtaggables
tables are populated.This should return 0 results.
Now, go change game ID 1's title to something like
"~Hack~ Sonic the Hedgehog"
and run the query again. You should get 1 result.Later down the road, having tags as structured data will unlock several behaviors:
This is also a precursor to migrating the beaten games leaderboard to React.
NOTE: A single game in your local snapshot probably has a tag of
~Multi~
. This game does not have a set. In the production database, I have removed this tag. It is not handled by the command or action.Another thing to keep in mind is

spatie/laravel-tags
localizes tags, and there is no way to disable this behavior:We should probably only store "en" values in the database, and let the React UI do the presentation/localization work.