Making WordPress.org

Changeset 7841


Ignore:
Timestamp:
11/13/2018 03:18:20 PM (6 years ago)
Author:
vedjain
Message:

WordCamp: Use `_status_change_log_%' to filter WordCamp Applications.

On WordCamp Application Status report page, we were fetching 300 WordCamp posts, iterating over them one by one and figuring out if we should show in the report.
Changed this to directly filter in database for the posts that we want to show. This allows us to limit the 300 limit as we are already querying in the Database.

Fixes #3911

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/tracker.php

    r7607 r7841  
    2424 */
    2525function get_active_wordcamps() {
     26    global $wpdb;
    2627    $wordcamps          = array();
    2728    $statuses           = WordCamp_Loader::get_post_statuses();
     
    3233    unset( $shown_statuses[ WCPT_FINAL_STATUS ] );
    3334    $shown_statuses = array_keys( $shown_statuses );
     35    $wordcamp_post_type = WCPT_POST_TYPE_ID;
     36
     37    $wordcamp_post_objs = $wpdb->get_results(
     38        $wpdb->prepare(
     39            "
     40            SELECT DISTINCT post_id
     41            FROM {$wpdb->prefix}postmeta
     42            WHERE
     43                meta_key like '_status_change_log_$wordcamp_post_type%'
     44            AND
     45                meta_value >= %d
     46            ",
     47            $inactive_timestamp
     48        )
     49    );
     50    $wordcamp_post_ids = wp_list_pluck( $wordcamp_post_objs, 'post_id' );
    3451
    3552    $raw_posts = get_posts(
     
    3754            'post_type'      => WCPT_POST_TYPE_ID,
    3855            'post_status'    => $shown_statuses,
    39             'posts_per_page' => 300,
     56            'posts_per_page' => -1,
    4057            'order'          => 'ASC',
    4158            'orderby'        => 'post_title',
     59            'post__in'       => $wordcamp_post_ids,
    4260        )
    4361    );
     
    4563    foreach ( $raw_posts as $key => $post ) {
    4664        $last_update_timestamp = get_last_update_timestamp( $post->ID );
    47 
    48         if ( $last_update_timestamp <= $inactive_timestamp ) {
    49             continue;
    50         }
    5165
    5266        $wordcamps[] = array(
Note: See TracChangeset for help on using the changeset viewer.