Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/311652
Change subject: [WIP] Refactor and simplify changeslist/contribs queries a bit ...................................................................... [WIP] Refactor and simplify changeslist/contribs queries a bit Change-Id: Ic19ad7dd2ca10bdfab48a95c7deb1247dc655d47 --- M includes/Hooks.php 1 file changed, 20 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES refs/changes/52/311652/1 diff --git a/includes/Hooks.php b/includes/Hooks.php index fee726d..ffa8ad3 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -132,32 +132,25 @@ $threshold = self::getDamagingThreshold( $wgUser ); $dbr = \wfGetDB( DB_REPLICA ); - $tables[] = 'ores_classification'; $tables[] = 'ores_model'; + $tables[] = 'ores_classification'; $fields[] = 'oresc_probability'; // Add user-based threshold $fields[] = $dbr->addQuotes( $threshold ) . ' AS ores_threshold'; - $conds[] = '(oresm_name = ' . $dbr->addQuotes( 'damaging' ) . - ' OR oresm_name IS NULL)'; + $join_conds['ores_model'] = [ 'LEFT JOIN', [ + 'oresm_is_current' => 1, + 'oresm_name' => 'damaging' + ] ]; + $join_conds['ores_classification'] = [ 'LEFT JOIN', [ + 'oresc_model = oresm_id', + 'rc_this_oldid = oresc_rev', + 'oresc_class' => 1 + ] ]; - $conds[] = '(oresm_is_current != 0 OR oresm_is_current IS NULL)'; - - $join_conds['ores_classification'] = [ 'LEFT JOIN', - 'rc_this_oldid = oresc_rev ' . - 'AND oresc_class = 1' ]; - - $join_conds['ores_model'] = [ 'LEFT JOIN', - 'oresc_model = oresm_id ' . - 'AND oresm_is_current = 1' - ]; if ( self::isModelEnabled( 'damaging' ) && $opts->getValue( 'hidenondamaging' ) ) { - // Override the join conditions. - $join_conds['ores_classification'] = [ 'INNER JOIN', - 'rc_this_oldid = oresc_rev ' . - 'AND oresc_class = 1' ]; // Filter out non-damaging edits. $conds[] = 'oresc_probability > ' @@ -257,32 +250,25 @@ $threshold = self::getDamagingThreshold( $pager->getUser() ); $dbr = \wfGetDB( DB_REPLICA ); - $query['tables'][] = 'ores_classification'; $query['tables'][] = 'ores_model'; + $query['tables'][] = 'ores_classification'; $query['fields'][] = 'oresc_probability'; // Add user-based threshold $query['fields'][] = $dbr->addQuotes( $threshold ) . ' AS ores_threshold'; - $query['conds'][] = '(oresm_name = ' . $dbr->addQuotes( 'damaging' ) . - ' OR oresm_name IS NULL)'; + $query['join_conds']['ores_model'] = [ 'LEFT JOIN', [ + 'oresm_is_current' => 1, + 'oresm_name' => 'damaging', + ] ]; - $query['conds'][] = '(oresm_is_current != 0 OR oresm_is_current IS NULL)'; - - $query['join_conds']['ores_classification'] = [ 'LEFT JOIN', - 'rev_id = oresc_rev ' . - 'AND oresc_class = 1' ]; - - $query['join_conds']['ores_model'] = [ 'LEFT JOIN', - 'oresc_model = oresm_id ' . - 'AND oresm_is_current = 1' ]; + $query['join_conds']['ores_classification'] = [ 'LEFT JOIN', [ + 'oresc_model = oresm_id', + 'rev_id = oresc_rev', + 'oresc_class' => 1 + ]; if ( self::isModelEnabled( 'damaging' ) && $pager->getContext()->getRequest()->getVal( 'hidenondamaging' ) ) { - // Override the join conditions. - $join_conds['ores_classification'] = [ 'INNER JOIN', - 'rc_this_oldid = oresc_rev ' . - 'AND oresc_class = 1' ]; - // Filter out non-damaging edits. $query['conds'][] = 'oresc_probability > ' . $dbr->addQuotes( $threshold ); -- To view, visit https://gerrit.wikimedia.org/r/311652 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic19ad7dd2ca10bdfab48a95c7deb1247dc655d47 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ORES Gerrit-Branch: master Gerrit-Owner: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits