fetchNextTask static method

String fetchNextTask(
  1. String tableName
)

Returns a query that fetches the highest-priority pending task using FIFO ordering when priorities match.

Implementation

static String fetchNextTask(String tableName) {
  return '''
    SELECT * FROM $tableName
    WHERE state = 'pending'
    ORDER BY priority DESC, created_at ASC
    LIMIT 1
  ''';
}