Removes old SPT versions from search results

The global search results are now limited to mods tagged with the last three minor SPT versions, like the mod listing filters.

I'm not 100% sure about this change. Open to suggestions and revisiting this in the future.

Resolves #26
This commit is contained in:
Refringe 2024-09-08 22:06:52 -04:00
parent ffd5117028
commit 164a649cd4
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k

View File

@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Laravel\Scout\Searchable; use Laravel\Scout\Searchable;
@ -144,6 +145,14 @@ class Mod extends Model
return false; return false;
} }
// Ensure the latest SPT version is within the last three minor versions.
$activeSptVersions = Cache::remember('active-spt-versions', 60 * 60, function () {
return SptVersion::getVersionsForLastThreeMinors();
});
if (! in_array($latestVersion->latestSptVersion()->first()->version, $activeSptVersions->pluck('version')->toArray())) {
return false;
}
// All conditions are met; the mod should be searchable. // All conditions are met; the mod should be searchable.
return true; return true;
} }