Page MenuHomePhabricator

Replace TranslationStatsInterface::preQuery with a SelectQueryBuilder
Closed, ResolvedPublic2 Estimated Story Points

Description

In Translate extension the TranslationStatsInterface::preQuery takes all arguments as IReadableDatabase::select.
The best replacement for the IReadableDatabase::select would be SelectQueryBuilder from the TranslationStats provider as suggested in code review at https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Translate/+/1026146/1/src/Statistics/TranslationStatsDataProvider.php

Example:

interface TranslationStatsInterface {
	// [...]
	// old:
	public function preQuery(
		IDatabase $database,
		&$tables,
		&$fields,
		&$conds,
		&$type,
		&$options,
		&$joins,
		$start,
		$end
	);
	// new:
	public function newSelectQueryBuilder( IReadableDatabase $dbr, string &$type, string $start, ?string $end ): SelectQueryBuilder;
	// [...]
}

Maybe omit $start/$end from the function and create a new function (getTimestampColumn) to get the name of the relevant column and add the condition before execution.

Event Timeline

abi_ set the point value for this task to 2.Aug 13 2024, 5:26 AM

Change #1062420 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] Replace TranslationStatsInterface::preQuery with createQueryBuilder

https://gerrit.wikimedia.org/r/1062420

Change #1062420 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Replace TranslationStatsInterface::preQuery with createQueryBuilder

https://gerrit.wikimedia.org/r/1062420

Change #1066781 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] TranslationStatsInterface: Replace getTimestamp with getTimestampColumn

https://gerrit.wikimedia.org/r/1066781

Change #1066781 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] TranslationStatsInterface: Replace getTimestamp with getTimestampColumn

https://gerrit.wikimedia.org/r/1066781

Deployed and tested on translatewiki.net