forked from mirror/pixelfed
Update AutospamUpdateCachedDataPipeline
This commit is contained in:
parent
5abc2445a7
commit
a11e1ee3f8
1 changed files with 23 additions and 17 deletions
|
@ -52,9 +52,11 @@ class AutospamUpdateCachedDataPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$newSpamCount = count($spam['words']['spam']);
|
$newSpamCount = count($spam['words']['spam']);
|
||||||
|
if($newSpamCount) {
|
||||||
$spam['documents']['spam'] = $newSpamCount;
|
$spam['documents']['spam'] = $newSpamCount;
|
||||||
arsort($spam['words']['spam']);
|
arsort($spam['words']['spam']);
|
||||||
Storage::put(AutospamService::MODEL_SPAM_PATH, json_encode($spam, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
Storage::put(AutospamService::MODEL_SPAM_PATH, json_encode($spam, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
||||||
|
}
|
||||||
|
|
||||||
$hamExists = Storage::exists(AutospamService::MODEL_HAM_PATH);
|
$hamExists = Storage::exists(AutospamService::MODEL_HAM_PATH);
|
||||||
if($hamExists) {
|
if($hamExists) {
|
||||||
|
@ -80,11 +82,13 @@ class AutospamUpdateCachedDataPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
$newHamCount = count($ham['words']['ham']);
|
$newHamCount = count($ham['words']['ham']);
|
||||||
|
if($newHamCount) {
|
||||||
$ham['documents']['ham'] = $newHamCount;
|
$ham['documents']['ham'] = $newHamCount;
|
||||||
arsort($ham['words']['ham']);
|
arsort($ham['words']['ham']);
|
||||||
|
|
||||||
Storage::put(AutospamService::MODEL_HAM_PATH, json_encode($ham, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
Storage::put(AutospamService::MODEL_HAM_PATH, json_encode($ham, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($newSpamCount && $newHamCount) {
|
||||||
$combined = [
|
$combined = [
|
||||||
'documents' => [
|
'documents' => [
|
||||||
'spam' => $newSpamCount,
|
'spam' => $newSpamCount,
|
||||||
|
@ -97,6 +101,8 @@ class AutospamUpdateCachedDataPipeline implements ShouldQueue
|
||||||
];
|
];
|
||||||
|
|
||||||
Storage::put(AutospamService::MODEL_FILE_PATH, json_encode($combined, JSON_PRETTY_PRINT,JSON_UNESCAPED_SLASHES));
|
Storage::put(AutospamService::MODEL_FILE_PATH, json_encode($combined, JSON_PRETTY_PRINT,JSON_UNESCAPED_SLASHES));
|
||||||
|
}
|
||||||
|
|
||||||
Cache::forget(AutospamService::MODEL_CACHE_KEY);
|
Cache::forget(AutospamService::MODEL_CACHE_KEY);
|
||||||
Cache::forget(AutospamService::CHCKD_CACHE_KEY);
|
Cache::forget(AutospamService::CHCKD_CACHE_KEY);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue