Skip to content

one_d4: add forceReindex param to skip cached indexed_periods #1075

@aaylward

Description

@aaylward

Summary

When a player+month combination has already been indexed and marked complete (is_complete = true in indexed_periods), the indexing worker skips it. There's no way to force a re-index — e.g. to pick up newly-added motifs, re-run analysis after a bug fix, or recover from a partial/corrupt run.

Add an optional forceReindex boolean to IndexRequest that bypasses the cached-period check.

Background

The skip logic lives in IndexWorker.java (lines 63–78):

Optional<IndexedPeriod> cached =
    periodStore.findCompletePeriod(message.player(), message.platform(), monthStr);
if (cached.isPresent()) {
    // ... skips fetch entirely
    continue;
}

A forceReindex flag would cause this guard to be skipped, so all months in the requested range are re-fetched and re-inserted regardless of is_complete.

Proposed Changes

IndexRequest — add optional field

// IndexRequest.java
@JsonProperty("forceReindex")
Boolean forceReindex  // defaults to false if absent

Pass forceReindex through the queue message (IndexMessage) to the worker.

IndexWorker — respect the flag

When forceReindex == true, skip the findCompletePeriod call (or ignore its result) and proceed to fetch and insert games for every month in the range.

Key files:

  • domains/games/apis/one_d4/src/main/java/com/muchq/games/one_d4/api/IndexController.java — constructs the queue message
  • domains/games/apis/one_d4/src/main/java/com/muchq/games/one_d4/worker/IndexWorker.java — contains the skip logic (lines 63–78)
  • The queue message type (IndexMessage) — needs the new field

IndexView.tsx / api.ts — UI checkbox

Add a checkbox to the index form:

[ ] Force re-index (ignore cached periods)  (default: unchecked)

Wire into form state and pass forceReindex in the POST body.

Key files:

  • domains/games/apps/1d4_web/src/views/IndexView.tsx
  • domains/games/apps/1d4_web/src/api.tscreateIndex() (lines 37–44)

Acceptance Criteria

  • IndexRequest accepts optional forceReindex; omitting it (or false) preserves current skip behavior
  • When forceReindex = true, the worker re-fetches and re-processes all months in the range, overwriting indexed_periods via upsert
  • IndexView has a "Force re-index" checkbox (default unchecked); value sent as forceReindex in the POST body
  • Existing skip-logic tests are updated; new tests cover the force-reindex path in IndexWorker

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions