mc-cms-namelessmc/dev/scripts/seeder/UserProfilePostSeeder.php

57 lines
2.1 KiB
PHP
Raw Permalink Normal View History

2022-04-23 11:32:04 -07:00
<?php
class UserProfilePostSeeder extends Seeder
{
2022-04-23 11:32:04 -07:00
public array $tables = [
'nl2_user_profile_wall_posts',
'nl2_user_profile_wall_posts_replies',
'nl2_user_profile_wall_posts_reactions',
];
protected function run(DB $db, \Faker\Generator $faker): void
{
2022-04-23 11:32:04 -07:00
$users = $db->get('users', ['id', '<>', 0])->results();
$this->times(PROFILE_POST_COUNT, function () use ($db, $faker, $users) {
2022-04-23 11:32:04 -07:00
$user = $faker->randomElement($users);
$author = $faker->randomElement($users);
while ($user->id == $author->id) {
$author = $faker->randomElement($users);
}
$db->insert('user_profile_wall_posts', [
'user_id' => $user->id,
'author_id' => $author->id,
'time' => $this->since($author->joined, $faker)->format('U'),
'content' => $faker->text,
]);
});
$profile_posts = $db->get('user_profile_wall_posts', ['id', '<>', 0])->results();
$this->times(PROFILE_POST_REPLY_COUNT, function () use ($db, $faker, $profile_posts) {
2022-04-23 11:32:04 -07:00
$post = $faker->randomElement($profile_posts);
$author_id = $faker->randomElement($profile_posts)->author_id;
$db->insert('user_profile_wall_posts_replies', [
'post_id' => $post->id,
'author_id' => $author_id,
'time' => $this->since($post->time, $faker)->format('U'),
'content' => $faker->text,
]);
});
Reactions revamp & profile widgets (#3272) * Initial work on reactions revamp and profile widgets * Remove unneeded changes * Remove unneeded change * fix style * Render emojis in reaction list StaffCP * wip minecraft account profile widget, sticky widgets on profile page * Add server name and IP to last seen * remove * rename to reaction score to match member list * align reactions table contents center * fix * wip - nicer abstraction, widgets never query db, skin 3d viewer (undecided) * wip - make reaction modals ajax, copy new reaction bar to profile posts * wip reaction modals * wip proper sorting * wip modals * wip get reaction submission working on profile wall posts * add back helpful and creative default reactions * reduce query amount on view topic * remove debug statement * wip * wip * simplify ProfileWidget pages * Revert forum dropdown * fix css syntax * fix emoji title and alt being strange * add back order input * sort widgets by order in list * fix settings link always showing * phpdoc * add widget name to exception * insert default widget data if not found * missing end if * properly cache forum news per-group * fix * fix cache key, news permission check * fix styling * wip * respect reaction ordering * wip * wip * support custom reaction scores, update member list to properly calculate * don't hardcode words * wip * allow multiple reactions * redirect to post * code style * phpstan * wip * remove hardcoded terms + fix copy * use npm for skinview3d * create ReactionContext and refactor * fix cache * docblocks * fix spelling * pr amendments
2023-06-21 10:19:46 -07:00
$reactions = $db->get('reactions', ['id', '<>', 0])->results();
$this->times(PROFILE_POST_REACTION_COUNT, function () use ($db, $faker, $profile_posts, $reactions) {
2022-04-23 11:32:04 -07:00
$post = $faker->randomElement($profile_posts);
$user_id = $faker->randomElement($profile_posts)->user_id;
$db->insert('user_profile_wall_posts_reactions', [
'user_id' => $user_id,
Reactions revamp & profile widgets (#3272) * Initial work on reactions revamp and profile widgets * Remove unneeded changes * Remove unneeded change * fix style * Render emojis in reaction list StaffCP * wip minecraft account profile widget, sticky widgets on profile page * Add server name and IP to last seen * remove * rename to reaction score to match member list * align reactions table contents center * fix * wip - nicer abstraction, widgets never query db, skin 3d viewer (undecided) * wip - make reaction modals ajax, copy new reaction bar to profile posts * wip reaction modals * wip proper sorting * wip modals * wip get reaction submission working on profile wall posts * add back helpful and creative default reactions * reduce query amount on view topic * remove debug statement * wip * wip * simplify ProfileWidget pages * Revert forum dropdown * fix css syntax * fix emoji title and alt being strange * add back order input * sort widgets by order in list * fix settings link always showing * phpdoc * add widget name to exception * insert default widget data if not found * missing end if * properly cache forum news per-group * fix * fix cache key, news permission check * fix styling * wip * respect reaction ordering * wip * wip * support custom reaction scores, update member list to properly calculate * don't hardcode words * wip * allow multiple reactions * redirect to post * code style * phpstan * wip * remove hardcoded terms + fix copy * use npm for skinview3d * create ReactionContext and refactor * fix cache * docblocks * fix spelling * pr amendments
2023-06-21 10:19:46 -07:00
'post_id' => $post->id,
'reaction_id' => $faker->randomElement($reactions)->id,
2022-04-23 11:32:04 -07:00
'time' => $this->since($post->time, $faker)->format('U'),
]);
});
}
}