Repository navigation
Fix campaign collection bug: extract planet_index from nested structure - #13
Merged
Merged
Conversation
- Fix collector.py: Extract planet_index from nested campaign.planet.index instead of non-existent campaign.planet_index - Fix database.py: Set campaign status to 'active' since API only returns active campaigns - Now 45 active campaigns are properly collected and stored - /api/campaigns/active endpoint now returns data instead of 404
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical bug where campaigns were never being saved to the database due to incorrect planet_index extraction from the nested API response structure.
Key Changes:
- Fixed planet_index extraction in collector to access nested
planet.indexfield - Updated campaign status to hardcode "active" since API only returns active campaigns
- Refactored database.py with schema improvements and simplified methods
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/collector.py | Fixed campaign collection logic to properly extract planet_index from nested structure |
| src/database.py | Updated save_campaign to use hardcoded "active" status and simplified schema/queries |
…stics, and events
…ealwolf/high-command-api into fix/campaign-collection-bug
…abase schema, and code quality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes critical bug in campaign data collection where campaigns were never being saved to the database.
Root Cause
The collector was trying to extract
planet_indexfrom a top-level field that doesn't exist in the Hell Divers 2 API response. The actual structure has planet data nested inside aplanetobject with the index inside it.Changes Made
1. src/collector.py (line 73)
planet_index = campaign.get('planet_index')→ always returnsNoneplanet_index = campaign.get('planet', {}).get('index')→ correctly extracts nested value2. src/database.py (line 201)
status = data.get("status", "Unknown")→ campaigns saved withstatus='Unknown'status = "active"→ campaigns correctly marked as active since API only returns active campaignsResults
planet_indexvalues (no moreNonevalues)/api/campaigns/activeendpoint now returns campaign data (was returning 404)Testing
/api/campaignsreturns 45 live campaigns/api/campaigns/activereturns 45 active campaigns from databaseFixes #[issue-number] (if applicable)