$source Raw DB row (must contain status and meta keys). * @return array{ui_status:string,next_fetch_at:int|null} */ public static function compute( array $source ): array { $status = (string) ( $source['status'] ?? 'active' ); $meta = []; if ( ! empty( $source['meta'] ) ) { $decoded = json_decode( (string) $source['meta'], true ); $meta = is_array( $decoded ) ? $decoded : []; } if ( 'expired' === $status ) { return [ 'ui_status' => 'expired', 'next_fetch_at' => null, ]; } if ( 'error' === $status ) { $nextFetchAt = ! empty( $meta['next_fetch_at'] ) ? (int) $meta['next_fetch_at'] : null; if ( null !== $nextFetchAt && $nextFetchAt > time() ) { return [ 'ui_status' => 'retrying', 'next_fetch_at' => $nextFetchAt, ]; } return [ 'ui_status' => 'sync_issue', 'next_fetch_at' => null, ]; } return [ 'ui_status' => 'active', 'next_fetch_at' => null, ]; } }