forked from projects/thebadspace
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
2 changed files with 19 additions and 5 deletions
|
@ -112,9 +112,9 @@ class LocationController extends Controller
|
|||
$silence = 0;
|
||||
$suspend = 0;
|
||||
if ($item[1] == "suspend" || $item[1] == "defederate") {
|
||||
++$silence;
|
||||
} else {
|
||||
++$suspend;
|
||||
} else {
|
||||
++$silence;
|
||||
}
|
||||
array_push($unified, [
|
||||
'name' => $item[0],
|
||||
|
@ -164,6 +164,12 @@ class LocationController extends Controller
|
|||
$location->block_count = $item['block_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
|
||||
if ($location->images == null) {
|
||||
$location->images = [];
|
||||
|
@ -174,18 +180,25 @@ class LocationController extends Controller
|
|||
++$fresh;
|
||||
$images = [];
|
||||
$rating = ($item['rating'] == 'defederate') ? 'suspend' : $item['rating'];
|
||||
|
||||
$status = true;
|
||||
if (($item['block_count'] + $item['silence_count']) < 2) {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
$new = Location::create([
|
||||
'uuid' => Uuid::uuid4(),
|
||||
'name' => $item['url'],
|
||||
'url' => $item['url'],
|
||||
'description' => ($item['comment'] != null) ? $item['comment'] : "no description",
|
||||
'active' => true,
|
||||
'active' => $status,
|
||||
'rating' => $rating,
|
||||
'added_by' => 1,
|
||||
'tags' => 'poor moderation, hate speech',
|
||||
'images' => json_encode($images),
|
||||
'block_count' => $item['block_count'],
|
||||
'silence_count' => $item['silence_count'],
|
||||
'actions_cont' => $item['block_count'] + $item['silence_count']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ class Location extends Model
|
|||
"block_count",
|
||||
"silence_count",
|
||||
"created_at",
|
||||
"updated_at"
|
||||
"updated_at",
|
||||
"actions_count"
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue