Making WordPress.org

Changeset 1883


Ignore:
Timestamp:
09/17/2015 04:32:54 AM (9 years ago)
Author:
dd32
Message:

Translate: Simplify the query to locate projects to list.
This change leverages our project translation status table to determine a project has a given locale, making it a far simpler query.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/routes/locale.php

    r1872 r1883  
    436436                // We only need to check against tp.id and not tp_sub.id in this case as we've overriding the parent_project_id check
    437437                $ids = implode( ', ', array_map( 'intval', $allowed_projects ) );
    438                 $parent_project_sql = "AND tp_sub.id IN( $ids ) AND stats.waiting > 0";
     438                $parent_project_sql = "AND tp.id IN( $ids ) AND stats.waiting > 0";
    439439
    440440            } else {
     
    506506        $_projects = $project->many( "
    507507            SELECT SQL_CALC_FOUND_ROWS tp.*
    508                 FROM {$gpdb->projects} tp
    509                 LEFT JOIN {$gpdb->projects} tp_sub ON tp.id = tp_sub.parent_project_id AND tp_sub.active = 1
    510                 LEFT JOIN {$gpdb->translation_sets} sets ON sets.project_id = tp.id AND sets.locale = %s AND sets.slug = %s
    511                 LEFT JOIN {$gpdb->translation_sets} sets_sub ON sets_sub.project_id = tp_sub.id AND sets_sub.locale = %s AND sets_sub.slug = %s
    512                 LEFT JOIN {$gpdb->project_translation_status} stats ON stats.project_id = tp.id AND stats.translation_set_id = sets.id
     508            FROM {$gpdb->projects} tp
     509                LEFT JOIN {$gpdb->project_translation_status} stats ON stats.project_id = tp.id AND stats.locale = %s AND stats.locale_slug = %s
    513510            WHERE
    514511                tp.active = 1
    515                 AND ( sets.id IS NOT NULL OR sets_sub.id IS NOT NULL )
    516512                $parent_project_sql
    517513                $search_sql
     
    520516            ORDER BY $filter_order_by
    521517            $limit_sql
    522         ", $locale, $set_slug, $locale, $set_slug );
     518        ", $locale, $set_slug );
    523519
    524520        $results = (int) $project->found_rows();
Note: See TracChangeset for help on using the changeset viewer.