Skip to content

[Split Tracking] Update Redis layer to support split-credit increments and force-update rebuilds #32

@joelhalen

Description

@joelhalen

Overview

Part of #28 — Split GP Tracking feature.

Two changes to services/redis_updates.py (RedisLootTracker class):

  1. A new helper to increment (or decrement) a single player's score in a specific group leaderboard.
  2. Ensuring force_update_player() re-applies split credits from the drop_splits table so that rebuilds don't erase earned GP for split participants.

Work Required

1. New method: add_split_credit()

def add_split_credit(self, player_id: int, split_value: int,
                     partition: int, group_id: int, world_type: str = "main") -> None:
    prefix = "seasonal:" if world_type == "seasonal" else ""
    key = f"{prefix}leaderboard:{partition}:group:{group_id}"
    redis_client.client.zincrby(key, split_value, player_id)
  • Called with a positive delta to credit a split participant.
  • Called with a negative delta (e.g. split_value - full_value) to reduce the receiver's group leaderboard score from full_value to split_value.
  • Does not touch player:*:total_loot keys or the global leaderboard.

2. Modify force_update_player()

After the existing per-partition rebuild loop (~line 384-399), add a step:

  • Query drop_splits where player_id = <player_being_rebuilt>.
  • For each row, call ZINCRBY leaderboard:{partition}:group:{group_id} +split_value <player_id> (only for groups with split_gp_tracking = 1, to avoid stale rows from before the flag was enabled).
  • This ensures that when a split participant's Redis data is wiped and rebuilt, their earned group leaderboard credit is restored.

Notes

  • The force_update_player() function already accepts a DB session; pass it through to the new query.
  • Only the group leaderboard sorted sets are touched — individual total_loot keys remain receiver-only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions