-
-
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
fix: move achievement migration tool to Filament, update achievement_sets #2728
base: master
Are you sure you want to change the base?
fix: move achievement migration tool to Filament, update achievement_sets #2728
Conversation
return [$achievement->id => "ID: {$achievement->id} - Title: {$achievement->title} - Game: {$achievement->game->title}"]; | ||
}) | ||
->toArray(); | ||
}) |
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 don't know that this feature gets used all that often, but I imagine that when it is used, people just paste in a CSV of achievements to move. CSVs don't seem to work with the new component. You have to enter each ID individually, and select the matching result.
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.
Updated in latest to use a CSV input field.
'Server', | ||
ArticleType::GameModification, | ||
$gameId, | ||
"$user migrated " . Str::plural('achievement', count($achievementIds)) . ' ' . |
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.
Should be {$user->display_name}
:
{"ID":...} migrated achievements 458393,458394,458392 from games 29978,4068.
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.
But wouldn't it be better to put the GameID modifications in the audit logs for the individual achievements?
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.
Applied both in latest. GameID changes are now correctly recorded in the audit log.
dispatch(new UpdateGameMetricsJob($gameId))->onQueue('game-metrics'); | ||
foreach ($oldGameIds as $oldGameId) { | ||
dispatch(new UpdateGameMetricsJob($oldGameId))->onQueue('game-metrics'); | ||
} |
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.
There's an AchievementMoved
event that notifies the DispatchUpdateGameMetricsJob
that seems like it should be used here. The trade-off is that it has to be raised for each achievement, and relies on the queue to de-dup the old/new game updates.
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 didn't know about this event. I believe with my fix for the audit log, AchievementMoved
is now being correctly automatically dispatched.
if (!PlayerGame::where('game_id', $gameId)->where('user_id', $userId)->exists()) { | ||
$playerGame = new PlayerGame(['user_id' => $userId, 'game_id' => $gameId]); | ||
$playerGame->save(); | ||
dispatch(new UpdatePlayerGameMetricsJob($userId, $gameId)); |
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.
The PlayerGameMetrics
should be updated for the user whether or not they've previously played the game. The player metrics for the old game(s) should also be updated.
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.
Updated in latest:
// Update all affected player game metrics.
$affectedUserIds = PlayerAchievement::whereIn('achievement_id', $achievementIds)
->select(['user_id'])
->distinct()
->pluck('user_id');
foreach ($affectedUserIds as $userId) {
// Ensure player_game entries exist for the new game for all affected users.
if (!PlayerGame::where('game_id', $gameId)->where('user_id', $userId)->exists()) {
$playerGame = new PlayerGame(['user_id' => $userId, 'game_id' => $gameId]);
$playerGame->save();
}
dispatch(new UpdatePlayerGameMetricsJob($userId, $gameId));
foreach ($oldGameIds as $oldGameId) {
dispatch(new UpdatePlayerGameMetricsJob($userId, $oldGameId));
}
}
This PR moves the admin achievement migration tool to the "Admin Tools" page in Filament. Additionally, migrating an achievement now also updates
achievement_sets
.