Plugin Directory

Changeset 3372770


Ignore:
Timestamp:
10/04/2025 09:20:51 AM (6 months ago)
Author:
muchatai
Message:

Update to version 2.0.46 from GitHub

Location:
muchat-ai
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • muchat-ai/tags/2.0.46/includes/Models/Product.php

    r3357955 r3372770  
    6262        // Add date filters if provided
    6363        if (!empty($params['modified_after'])) {
    64             $modified_after_timestamp = strtotime($params['modified_after']);
    65             if ($modified_after_timestamp) {
     64            try {
     65                // Parse the date as UTC to ensure consistency
     66                $date = new \DateTime($params['modified_after'], new \DateTimeZone('UTC'));
    6667                $args['date_query'][] = [
    6768                    'column' => 'post_modified_gmt',
    68                     'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     69                    'after' => $date->format('Y-m-d H:i:s'),
    6970                    'inclusive' => false
    7071                ];
     72            } catch (\Exception $e) {
     73                // If date parsing fails, try with strtotime as fallback
     74                $modified_after_timestamp = strtotime($params['modified_after']);
     75                if ($modified_after_timestamp) {
     76                    $args['date_query'][] = [
     77                        'column' => 'post_modified_gmt',
     78                        'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     79                        'inclusive' => false
     80                    ];
     81                }
    7182            }
    7283        }
     
    142153            'post_status' => 'publish',
    143154            'posts_per_page' => -1,
    144             'fields' => 'ids',
    145             'orderby' => 'ID',
    146             'order' => 'ASC'
     155            'orderby' => ['modified' => 'ASC', 'ID' => 'ASC'],
    147156        ];
    148157
    149158        if ($modified_after) {
    150             $modified_after_timestamp = strtotime($modified_after);
    151             if ($modified_after_timestamp) {
     159            try {
     160                // Parse the date as UTC to ensure consistency
     161                $date = new \DateTime($modified_after, new \DateTimeZone('UTC'));
    152162                $args['date_query'] = [
    153163                    [
    154164                        'column' => 'post_modified_gmt',
    155                         'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     165                        'after' => $date->format('Y-m-d H:i:s'),
    156166                        'inclusive' => false
    157167                    ]
    158168                ];
    159             }
    160         }
     169            } catch (\Exception $e) {
     170                // If date parsing fails, try with strtotime as fallback
     171                $modified_after_timestamp = strtotime($modified_after);
     172                if ($modified_after_timestamp) {
     173                    $args['date_query'] = [
     174                        [
     175                            'column' => 'post_modified_gmt',
     176                            'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     177                            'inclusive' => false
     178                        ]
     179                    ];
     180                }
     181            }
     182        }
     183
     184        // Filter to select only ID and post_modified_gmt for performance
     185        $fields_filter = function ($fields) {
     186            global $wpdb;
     187            return "{$wpdb->posts}.ID, {$wpdb->posts}.post_modified_gmt";
     188        };
     189        add_filter('posts_fields', $fields_filter);
    161190
    162191        $query = new \WP_Query($args);
     192
     193        // Clean up the filter
     194        remove_filter('posts_fields', $fields_filter);
     195
     196        $products = array_map(function ($post) {
     197            return [
     198                'id' => $post->ID,
     199                'date_modified' => $post->post_modified_gmt
     200            ];
     201        }, $query->posts);
    163202
    164203        return [
    165204            'total_count' => (int) $query->found_posts,
    166             'ids' => $query->posts
     205            'items' => $products
    167206        ];
    168207    }
  • muchat-ai/tags/2.0.46/muchat-ai.php

    r3357955 r3372770  
    55 * Plugin URI: https://mu.chat
    66 * Description: Muchat, a powerful tool for customer support using artificial intelligence
    7  * Version: 2.0.45
     7 * Version: 2.0.46
    88 * Author: Muchat
    99 * Text Domain: muchat-ai
     
    2727
    2828// Define plugin constants with unique prefix
    29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.45');
     29define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.46');
    3030// define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS);
    3131define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__);
  • muchat-ai/tags/2.0.46/readme.txt

    r3357955 r3372770  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.45
     6Stable tag: 2.0.46
    77Requires PHP: 7.3
    88License: GPLv2 or later
     
    7575
    7676== Changelog ==
     77
     78= 2.0.46 =
     79* Feature: Return `date_modified` along with `id` in the `product-ids` endpoint.
     80* Fix: Corrected sorting for the `product-ids` endpoint to use `date_modified` and then `id`.
     81* Tweak: Optimized the performance of the `product-ids` endpoint for a large number of products.
    7782
    7883= 2.0.45 =
  • muchat-ai/trunk/includes/Models/Product.php

    r3357955 r3372770  
    6262        // Add date filters if provided
    6363        if (!empty($params['modified_after'])) {
    64             $modified_after_timestamp = strtotime($params['modified_after']);
    65             if ($modified_after_timestamp) {
     64            try {
     65                // Parse the date as UTC to ensure consistency
     66                $date = new \DateTime($params['modified_after'], new \DateTimeZone('UTC'));
    6667                $args['date_query'][] = [
    6768                    'column' => 'post_modified_gmt',
    68                     'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     69                    'after' => $date->format('Y-m-d H:i:s'),
    6970                    'inclusive' => false
    7071                ];
     72            } catch (\Exception $e) {
     73                // If date parsing fails, try with strtotime as fallback
     74                $modified_after_timestamp = strtotime($params['modified_after']);
     75                if ($modified_after_timestamp) {
     76                    $args['date_query'][] = [
     77                        'column' => 'post_modified_gmt',
     78                        'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     79                        'inclusive' => false
     80                    ];
     81                }
    7182            }
    7283        }
     
    142153            'post_status' => 'publish',
    143154            'posts_per_page' => -1,
    144             'fields' => 'ids',
    145             'orderby' => 'ID',
    146             'order' => 'ASC'
     155            'orderby' => ['modified' => 'ASC', 'ID' => 'ASC'],
    147156        ];
    148157
    149158        if ($modified_after) {
    150             $modified_after_timestamp = strtotime($modified_after);
    151             if ($modified_after_timestamp) {
     159            try {
     160                // Parse the date as UTC to ensure consistency
     161                $date = new \DateTime($modified_after, new \DateTimeZone('UTC'));
    152162                $args['date_query'] = [
    153163                    [
    154164                        'column' => 'post_modified_gmt',
    155                         'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     165                        'after' => $date->format('Y-m-d H:i:s'),
    156166                        'inclusive' => false
    157167                    ]
    158168                ];
    159             }
    160         }
     169            } catch (\Exception $e) {
     170                // If date parsing fails, try with strtotime as fallback
     171                $modified_after_timestamp = strtotime($modified_after);
     172                if ($modified_after_timestamp) {
     173                    $args['date_query'] = [
     174                        [
     175                            'column' => 'post_modified_gmt',
     176                            'after' => gmdate('Y-m-d H:i:s', $modified_after_timestamp),
     177                            'inclusive' => false
     178                        ]
     179                    ];
     180                }
     181            }
     182        }
     183
     184        // Filter to select only ID and post_modified_gmt for performance
     185        $fields_filter = function ($fields) {
     186            global $wpdb;
     187            return "{$wpdb->posts}.ID, {$wpdb->posts}.post_modified_gmt";
     188        };
     189        add_filter('posts_fields', $fields_filter);
    161190
    162191        $query = new \WP_Query($args);
     192
     193        // Clean up the filter
     194        remove_filter('posts_fields', $fields_filter);
     195
     196        $products = array_map(function ($post) {
     197            return [
     198                'id' => $post->ID,
     199                'date_modified' => $post->post_modified_gmt
     200            ];
     201        }, $query->posts);
    163202
    164203        return [
    165204            'total_count' => (int) $query->found_posts,
    166             'ids' => $query->posts
     205            'items' => $products
    167206        ];
    168207    }
  • muchat-ai/trunk/muchat-ai.php

    r3357955 r3372770  
    55 * Plugin URI: https://mu.chat
    66 * Description: Muchat, a powerful tool for customer support using artificial intelligence
    7  * Version: 2.0.45
     7 * Version: 2.0.46
    88 * Author: Muchat
    99 * Text Domain: muchat-ai
     
    2727
    2828// Define plugin constants with unique prefix
    29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.45');
     29define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.46');
    3030// define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS);
    3131define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__);
  • muchat-ai/trunk/readme.txt

    r3357955 r3372770  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.45
     6Stable tag: 2.0.46
    77Requires PHP: 7.3
    88License: GPLv2 or later
     
    7575
    7676== Changelog ==
     77
     78= 2.0.46 =
     79* Feature: Return `date_modified` along with `id` in the `product-ids` endpoint.
     80* Fix: Corrected sorting for the `product-ids` endpoint to use `date_modified` and then `id`.
     81* Tweak: Optimized the performance of the `product-ids` endpoint for a large number of products.
    7782
    7883= 2.0.45 =
Note: See TracChangeset for help on using the changeset viewer.