mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-22 15:55:14 +00:00
Update StatusTagsPipeline, deduplicate hashtags on postgres
This commit is contained in:
parent
055aa6b39f
commit
867cbc757c
1 changed files with 18 additions and 5 deletions
|
@ -71,11 +71,24 @@ class StatusTagsPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$hashtag = Hashtag::firstOrCreate([
|
if(config('database.default') === 'pgsql') {
|
||||||
'slug' => str_slug($name)
|
$hashtag = Hashtag::where('name', 'ilike', $name)
|
||||||
], [
|
->orWhere('slug', 'ilike', str_slug($name))
|
||||||
'name' => $name
|
->first();
|
||||||
]);
|
|
||||||
|
if(!$hashtag) {
|
||||||
|
$hashtag = new Hashtag;
|
||||||
|
$hashtag->name = $name;
|
||||||
|
$hashtag->slug = str_slug($name);
|
||||||
|
$hashtag->save();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$hashtag = Hashtag::firstOrCreate([
|
||||||
|
'slug' => str_slug($name)
|
||||||
|
], [
|
||||||
|
'name' => $name
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
StatusHashtag::firstOrCreate([
|
StatusHashtag::firstOrCreate([
|
||||||
'status_id' => $status->id,
|
'status_id' => $status->id,
|
||||||
|
|
Loading…
Reference in a new issue