Skip to content

Add sliding time window support for non-stationary content #2

@jjroelofs

Description

@jjroelofs

Problem Statement

Content marketers need AI recommendations to favor recently active content for time-sensitive scenarios (news, campaigns, seasonal products) while maintaining optimal Thompson Sampling for evergreen content.

Solution Overview

Implement sliding time window functionality that filters Thompson Sampling data by activity timestamps, enabling content marketers to focus recommendations on recently active content.

Technical Implementation

Backend API Enhancement (this repo):

  • ✅ Add getAllArmsDataWithWindow($experiment_uuid, $time_window_seconds) to storage layer
  • ✅ Add getThompsonScoresWithWindow($experiment_uuid, $time_window_seconds) to manager layer
  • ✅ Implement seconds-based time filtering for technical precision
  • ✅ Add optimized composite database indexes for performance
  • ✅ Maintain backward compatibility with existing methods

Frontend Integration (ai_sorting repo):

  • Add "Favor recent content" checkbox (opt-in design)
  • Add time window dropdown (Last month, 3 months, 6 months, year)
  • Integrate with new RL module API methods

Use Cases

Enable time windows for:

  • News websites (Last month)
  • Blog content (Last 3 months)
  • Seasonal products (Last 6 months)
  • Campaign-driven content (Custom timeframes)

Leave disabled for:

  • Documentation sites
  • Tutorial content
  • Evergreen resources

Database Changes

New optimized indexes:

  • rl_experiment_totals: Composite index on (experiment_uuid, updated)
  • rl_arm_data: Covering index on (experiment_uuid, updated, arm_id, turns, rewards, created)

Related Issues

Testing

  • PHP syntax validation
  • Database migration testing
  • Performance benchmarking
  • Integration testing with ai_sorting module

Requires fresh installation - new indexes are created via schema definition.

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