Skip to content

feature: add highscore military points built, destroyed, lost#1106

Open
rbardtke wants to merge 3 commits into
lanedirt:mainfrom
rbardtke:feature/highscore-military-view
Open

feature: add highscore military points built, destroyed, lost#1106
rbardtke wants to merge 3 commits into
lanedirt:mainfrom
rbardtke:feature/highscore-military-view

Conversation

@rbardtke

@rbardtke rbardtke commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Description

add highscore military points built, destroyed, lost

Type of Change:

  • Bug fix
  • Feature enhancement
  • Documentation update
  • Other (please describe):

Related Issues

Fixes #947

Checklist

Before submitting this pull request, ensure all following requirements as outlined in CONTRIBUTING.md are met:

  • Automated Refactoring: Rector has been run and no outstanding issues remain.
  • Code Standards: Code adheres to PSR-12 coding standards. Verified with Laravel Pint.
  • Static Analysis: Code passes PHPStan static code analysis.
  • Testing:
    • Relevant unit and feature tests are included or updated.
    • Tests successfully run locally.
  • CSS & JS Build: CSS and JS assets are compiled using Laravel Mix if any changes are made to JS/CSS files.
  • Documentation: Documentation has been updated to reflect any changes made.

Additional Information

Military Highscore Subcategories - Migration Guide

This guide covers the one-time migration process for existing game instances to populate military destroyed/lost statistics from historical battle reports.

Overview

The military highscore subcategories feature adds three separate highscore categories:

  • Military Points Built - Units the player has built (tracked automatically)
  • Military Points Destroyed - Military units destroyed in combat
  • Military Points Lost - Military units lost in combat

For new game instances, these statistics are tracked automatically. For existing instances with battle history, a one-time migration is needed.

Migration Steps

1. Run Database Migrations

First, apply the database schema changes:

docker compose exec ogamex-app php artisan migrate

This creates the necessary columns in the highscores and users tables.

2. Test Migration (Dry Run)

Before applying changes, test the migration to see what will happen:

docker compose exec ogamex-app php artisan ogamex:migrate:military-statistics --dry-run

This will:

  • Process all existing battle reports
  • Calculate destroyed/lost points for each player
  • Display a summary without saving changes

3. Run Migration

Once you've verified the dry run results, apply the migration:

docker compose exec ogamex-app php artisan ogamex:migrate:military-statistics

This will:

  • Reset all military statistics to 0
  • Process all battle reports in the database
  • Calculate and save destroyed/lost points for each player
  • Display a summary of processed data

4. Generate Highscores

After migration, update the highscore data:

docker compose exec ogamex-app php artisan ogamex:scheduler:generate-highscores

This populates the highscore table with the migrated statistics.

5. Generate Rankings

Finally, calculate the rankings for all subcategories:

docker compose exec ogamex-app php artisan ogamex:scheduler:generate-highscore-ranks

This creates the rankings for built, destroyed, and lost subcategories.

@github-actions

Copy link
Copy Markdown

Preview deployment

Preview environment for this PR is ready for functional testing. Use one of the test accounts below to log in.

Status URL Commit Last deployed
✅ Live https://pr-1106.preview.ogamex.dev 8e44b68 2026-01-16 10:33:49 UTC
Test accounts (click to expand)
Email (login) Password Role Class Planets Description
test1@ogamex.dev test admin Collector 2 Admin, high resources, mining focus
test2@ogamex.dev test player General 1 Military focus, ships & fleet
test3@ogamex.dev test player Discoverer 1 Exploration, probes & cargo ships
test4@ogamex.dev test player None 1 New player, no class selected yet
test5@ogamex.dev test moderator Collector 1 Moderator, balanced setup
test6@ogamex.dev test player General 1 Vacation mode enabled
test7@ogamex.dev test player General 3 Heavy defense across planets
test8@ogamex.dev test player Discoverer 1 Fleet focus, inactive (i) 8 days
test9@ogamex.dev test player Collector 1 Beginner, long inactive (I) 40 days
test10@ogamex.dev test player General 5 Endgame, 90 unread messages

This preview will be automatically destroyed when the PR is closed.

@lanedirt

Copy link
Copy Markdown
Owner

Hi @rbardtke, nice work on this! Quite an extensive feature!

I tested the migration on a local version of the database of main.ogamex.dev with 1k users + few test users. And this seems to work fine! I did however notice a small issue on my local version where the military subtabs are not showing up:

image

However on the PR preview environment this works fine, so not sure what causes this (?).


Another thing: the migration php artisan ogamex:migrate:military-statistics seems to perform pretty good, kudos! Processing 22k battle reports in my local environment only takes like a few seconds.

So to make it easier for existing installations, would you be willing to look into automatically running this migration as part of the database migrations? I prefer to keep the upgrade path for existing installations as smooth as possible without the need to run any manual commands (if not super necessary).

@rbardtke

rbardtke commented Jan 25, 2026

Copy link
Copy Markdown
Contributor Author

Hi @rbardtke, nice work on this! Quite an extensive feature!

I tested the migration on a local version of the database of main.ogamex.dev with 1k users + few test users. And this seems to work fine! I did however notice a small issue on my local version where the military subtabs are not showing up:
image

However on the PR preview environment this works fine, so not sure what causes this (?).

Another thing: the migration php artisan ogamex:migrate:military-statistics seems to perform pretty good, kudos! Processing 22k battle reports in my local environment only takes like a few seconds.

So to make it easier for existing installations, would you be willing to look into automatically running this migration as part of the database migrations? I prefer to keep the upgrade path for existing installations as smooth as possible without the need to run any manual commands (if not super necessary).

@lanedirt i tried to recreate this, i seeded my databases with 20k battle reports, the command as you said was pretty fast. The subcategories appear on my local instance, the only case i can imagine, the columns are missing, could you check this?

docker compose exec ogamex-app php artisan tinker --execute="
\$highscore = \OGame\Models\Highscore::first();
var_dump([
    'has_military_destroyed' => isset(\$highscore->military_destroyed),
    'has_military_lost' => isset(\$highscore->military_lost),
    'destroyed_rank' => \$highscore->military_destroyed_rank ?? 'NULL',
    'lost_rank' => \$highscore->military_lost_rank ?? 'NULL',
]);
"

@lanedirt

Copy link
Copy Markdown
Owner

@rbardtke here's the var_dump output. And as I just tested it again to confirm: the extra buttons are (again) not appearing.

$ docker compose exec ogamex-app php artisan tinker --execute="
\$highscore = \OGame\Models\Highscore::first();
var_dump([
    'has_military_destroyed' => isset(\$highscore->military_destroyed),
    'has_military_lost' => isset(\$highscore->military_lost),
    'destroyed_rank' => \$highscore->military_destroyed_rank ?? 'NULL',
    'lost_rank' => \$highscore->military_lost_rank ?? 'NULL',
]);
"
array(4) {
  ["has_military_destroyed"]=>
  bool(true)
  ["has_military_lost"]=>
  bool(true)
  ["destroyed_rank"]=>
  int(1)
  ["lost_rank"]=>
  int(30)
}

@Geda173

Geda173 commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

I just pulled this branch and everything seems to be working fine. I seeded the database with 500 users and 20000 combat reports and then ran the migration, followed by the highscore generation commands. Everything was processed in a couple seconds. For me all four subtabs are appearing with the appropriate data.

@Geda173
Geda173 requested review from Geda173 March 31, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expanding the highscore military view

3 participants