Page MenuHomePhabricator

Replace TranslationStatsInterface::preQuery with a SelectQueryBuilder
Open, MediumPublic

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.