mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-05-06 14:41:02 -05:00
added total actions count to DB, action count fix
Added a new field to the locations table for total actions which will be used to set the active state of location. this will result in data being parsed and sorted easier instead of doing those calculations on the back end, so DB queries will be simpler also fixed actions counts for csv imports
This commit is contained in:
parent
fe67927c24
commit
fdaf90b89f
@ -112,9 +112,9 @@ class LocationController extends Controller
|
|||||||
$silence = 0;
|
$silence = 0;
|
||||||
$suspend = 0;
|
$suspend = 0;
|
||||||
if ($item[1] == "suspend" || $item[1] == "defederate") {
|
if ($item[1] == "suspend" || $item[1] == "defederate") {
|
||||||
++$silence;
|
|
||||||
} else {
|
|
||||||
++$suspend;
|
++$suspend;
|
||||||
|
} else {
|
||||||
|
++$silence;
|
||||||
}
|
}
|
||||||
array_push($unified, [
|
array_push($unified, [
|
||||||
'name' => $item[0],
|
'name' => $item[0],
|
||||||
@ -164,6 +164,12 @@ class LocationController extends Controller
|
|||||||
$location->block_count = $item['block_count'];
|
$location->block_count = $item['block_count'];
|
||||||
$location->silence_count = $item['silence_count'];
|
$location->silence_count = $item['silence_count'];
|
||||||
|
|
||||||
|
$location->actions_count = $item['block_count'] + $item['silence_count'];
|
||||||
|
|
||||||
|
if (($item['block_count'] + $item['silence_count']) < 2) {
|
||||||
|
$location->active = false;
|
||||||
|
}
|
||||||
|
|
||||||
//replace null with empty array
|
//replace null with empty array
|
||||||
if ($location->images == null) {
|
if ($location->images == null) {
|
||||||
$location->images = [];
|
$location->images = [];
|
||||||
@ -174,18 +180,25 @@ class LocationController extends Controller
|
|||||||
++$fresh;
|
++$fresh;
|
||||||
$images = [];
|
$images = [];
|
||||||
$rating = ($item['rating'] == 'defederate') ? 'suspend' : $item['rating'];
|
$rating = ($item['rating'] == 'defederate') ? 'suspend' : $item['rating'];
|
||||||
|
|
||||||
|
$status = true;
|
||||||
|
if (($item['block_count'] + $item['silence_count']) < 2) {
|
||||||
|
$status = false;
|
||||||
|
}
|
||||||
|
|
||||||
$new = Location::create([
|
$new = Location::create([
|
||||||
'uuid' => Uuid::uuid4(),
|
'uuid' => Uuid::uuid4(),
|
||||||
'name' => $item['url'],
|
'name' => $item['url'],
|
||||||
'url' => $item['url'],
|
'url' => $item['url'],
|
||||||
'description' => ($item['comment'] != null) ? $item['comment'] : "no description",
|
'description' => ($item['comment'] != null) ? $item['comment'] : "no description",
|
||||||
'active' => true,
|
'active' => $status,
|
||||||
'rating' => $rating,
|
'rating' => $rating,
|
||||||
'added_by' => 1,
|
'added_by' => 1,
|
||||||
'tags' => 'poor moderation, hate speech',
|
'tags' => 'poor moderation, hate speech',
|
||||||
'images' => json_encode($images),
|
'images' => json_encode($images),
|
||||||
'block_count' => $item['block_count'],
|
'block_count' => $item['block_count'],
|
||||||
'silence_count' => $item['silence_count'],
|
'silence_count' => $item['silence_count'],
|
||||||
|
'actions_cont' => $item['block_count'] + $item['silence_count']
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class Location extends Model
|
|||||||
"block_count",
|
"block_count",
|
||||||
"silence_count",
|
"silence_count",
|
||||||
"created_at",
|
"created_at",
|
||||||
"updated_at"
|
"updated_at",
|
||||||
|
"actions_count"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user