<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }

class Falcify_History {
    public static function init() {}
    public static function recent( $limit = 20 ) {
        // phpcs:disable WordPress.DB.SlowDBQuery -- Admin-only history list, limited to recent items.
        $q = new WP_Query( array(
            'post_type'      => 'any',
            'posts_per_page' => $limit,
            'meta_key'       => '_falcify_last_generated_at',
            'orderby'        => 'meta_value',
            'order'          => 'DESC',
            'meta_query'     => array( array( 'key' => '_falcify_content', 'compare' => 'EXISTS' ) ),
        ) );
        // phpcs:enable WordPress.DB.SlowDBQuery
        return $q->posts;
    }
}
