mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
Imports User Follows
The import script will now import hub user follows.
This commit is contained in:
parent
2cd8e9fa86
commit
6bc02ca210
@ -49,6 +49,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
|
|||||||
|
|
||||||
// Begin to import the data into the permanent local database tables.
|
// Begin to import the data into the permanent local database tables.
|
||||||
$this->importUsers();
|
$this->importUsers();
|
||||||
|
$this->importUserFollows();
|
||||||
$this->importLicenses();
|
$this->importLicenses();
|
||||||
$this->importSptVersions();
|
$this->importSptVersions();
|
||||||
$this->importMods();
|
$this->importMods();
|
||||||
@ -608,6 +609,37 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function importUserFollows(): void
|
||||||
|
{
|
||||||
|
$followsGroupedByFollower = [];
|
||||||
|
|
||||||
|
DB::connection('mysql_hub')
|
||||||
|
->table('wcf1_user_follow')
|
||||||
|
->select(['followID', 'userID', 'followUserID', 'time'])
|
||||||
|
->chunkById(100, function (Collection $follows) use (&$followsGroupedByFollower) {
|
||||||
|
foreach ($follows as $follow) {
|
||||||
|
$followerId = User::whereHubId($follow->userID)->value('id');
|
||||||
|
$followingId = User::whereHubId($follow->followUserID)->value('id');
|
||||||
|
|
||||||
|
if (! $followerId || ! $followingId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$followsGroupedByFollower[$followerId][$followingId] = [
|
||||||
|
'created_at' => Carbon::parse($follow->time, 'UTC'),
|
||||||
|
'updated_at' => Carbon::parse($follow->time, 'UTC'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}, 'followID');
|
||||||
|
|
||||||
|
foreach ($followsGroupedByFollower as $followerId => $followings) {
|
||||||
|
$user = User::find($followerId);
|
||||||
|
if ($user) {
|
||||||
|
$user->following()->sync($followings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import the licenses from the Hub database to the local database.
|
* Import the licenses from the Hub database to the local database.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user