Fixed several bugs

This commit is contained in:
2026-06-29 19:24:35 +02:00
parent 73844b6db0
commit c76bf45904
8 changed files with 83 additions and 5 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
#[Signature('migrate:downloads-count')]
#[Description('Command description')]
class MigrateDownloadsCount extends Command
{
public function handle()
{
$rows = DB::table('migrations_logs')
->where('source_system', 'wp')
->where('source_table', 'wp_posts')
->where('target_table', 'entries' )
->get(['source_id', 'target_id'])
;
$updated = 0;
foreach ($rows as $row) {
$downloadCount = DB::connection('old_wp')
->table('postmeta')
->where('post_id', $row->source_id)
->where('meta_key', 'download_counter' )
->value('meta_value');
if( $downloadCount ) {
DB::table('entries')->where('id', $row->target_id)->update(['old_download_count' => intval($downloadCount)]);
$updated++;
}
}
$this->info('All done (' . $updated . '/' . count($rows) .')');
}
}

View File

@@ -175,6 +175,7 @@ class Database extends Component
public const array SORT_OPTIONS = [
'created_at' => 'Date added',
'release_date' => 'Release date',
'total_downloads' => 'Total downloads',
'title' => 'Title'
];
@@ -236,7 +237,7 @@ class Database extends Component
{
$query = Entry::query()->published()->with([
'game.platform', 'game.genre', 'status', 'authors', 'languages', 'level', 'systems', 'categories', 'modifications'
]);
])->withSum('files', 'download_count');
if( $this->search ) {
$query->where(function($q) {
@@ -328,7 +329,13 @@ class Database extends Component
$query->where('user_id', $this->userId);
}
return $query->orderBy($this->sortBy, $this->sortDir);
$sortColumn = $this->sortBy;
if ($sortColumn === 'total_downloads') {
$sortColumn = 'files_sum_download_count';
}
return $query->orderBy($sortColumn, $this->sortDir);
}
private function searchFilter( string $modelClass, string $search )

View File

@@ -21,6 +21,7 @@ class EntrySelector extends Component
if( $entry ) {
$this->selectedEntryId = $oldEntryId;
$this->entryName = $entry->complete_title ?? $entry->title;
$this->search = $entry->complete_title ?? $entry->title;
}
}
}

View File

@@ -255,7 +255,7 @@ class Entry extends Model
public function getTotalDownloadsAttribute(): int
{
return $this->files->sum('download_count');
return $this->files->sum('download_count') + $this->old_download_count;
}
public function parseStaffCredits(): ?array {

View File

@@ -213,6 +213,7 @@ class ActivityService
->join('post', 'thread.first_post_id', '=', 'post.post_id')
->where('thread.discussion_state', 'visible')
->where('thread.discussion_type', '!=', 'redirect' )
->where('thread.node_id', '!=', config('xenforo.comments_node_id') )
->orderByDesc('thread.post_date')
->limit(self::ITEMS_PER_TYPE)
->select([

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('entries', function (Blueprint $table) {
$table->unsignedBigInteger('old_download_count')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('entries', function (Blueprint $table) {
$table->dropColumn('old_download_count');
});
}
};

View File

@@ -2,7 +2,7 @@
<x-form-field-title name="Screenshots" helper="At least 1 Screenshot required, Maximum 20." required="{{ $required ? 'true' : 'false' }}" />
<div class="form-group main-image-grid">
<div class="form-upload" style="flex:1;" :class="{ 'disabled': isFull }">
<input type="file" id="gallery-field" accept="image/png, image/jpeg, image/webp" multiple :disabled="isFull" @change="handleSubmitFiles($event)">
<input type="file" id="gallery-field" accept="image/png, image/jpeg, image/webp, image/gif" multiple :disabled="isFull" @change="handleSubmitFiles($event)">
<div class="form-upload-placeholder level">
<i data-lucide="file-archive" size="36" style="margin-bottom:15px;color:var(--text2)"></i>
<div style="font-size: 1.1rem;color:var(--text);margin-bottom:5px;">

View File

@@ -3,7 +3,7 @@
<x-form-field-title name="Main image" helper="This will show up on the index and on top of the entry. A screenshot or custom cover is prefered else all entries of same game will look the same." required="{{ $required ? 'true' : 'false' }}" />
<div class="form-group main-image-grid">
<div class="form-upload" style="flex:4;">
<input type="file" id="main-image-field" accept="image/png, image/jpeg, image/webp" @change="handleSubmitFile($event)">
<input type="file" id="main-image-field" accept="image/png, image/jpeg, image/webp, image/gif" @change="handleSubmitFile($event)">
<div class="form-upload-placeholder level">
<i data-lucide="file-archive" size="36" style="margin-bottom:15px;color:var(--text2)"></i>
<div style="font-size: 1.1rem;color:var(--text);margin-bottom:5px;">