Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MessageGroupStats Class Reference

This class abstract MessageGroup statistics calculation and storing. More...

Static Public Member Functions

static getEmptyStats ()
 Returns empty stats array.
 
static forItem ( $id, $code, $flags=0)
 Returns stats for given group in given language.
 
static forLanguage ( $code, $flags=0)
 Returns stats for all groups in given language.
 
static forGroup ( $id, $flags=0)
 Returns stats for all languages in given group.
 
static forEverything ( $flags=0)
 Returns stats for all group in all languages.
 
static clear (MessageHandle $handle)
 Recalculate stats for all groups associated with the message.
 
static clearGroup ( $id, int $flags=0)
 Recalculate stats for given group(s).
 
static clearLanguage ( $code)
 
static clearAll ()
 Purges all cached stats.
 
static multiAdd (&$a, $b)
 
static getDatabaseIdForGroupId ( $id)
 

Public Attributes

const TOTAL = 0
 Array index.
 
const TRANSLATED = 1
 Array index.
 
const FUZZY = 2
 Array index.
 
const PROOFREAD = 3
 Array index.
 
const FLAG_CACHE_ONLY = 1
 If stats are not cached, do not attempt to calculate them on the fly.
 
const FLAG_NO_CACHE = 2
 Ignore cached values. Useful for updating stale values.
 
const FLAG_IMMEDIATE_WRITES = 4
 Do not defer updates. Meant for jobs like MessageGroupStatsRebuildJob.
 

Static Protected Member Functions

static getUnknownStats ()
 Returns empty stats array that indicates stats are incomplete or unknown.
 
static extractResults ( $res, array $ids, array $stats=[])
 Use this to extract results returned from selectRowsIdLang.
 
static extractNumbers ( $row)
 Returns an array of needed database fields.
 
static forLanguageInternal ( $code, array $stats, $flags)
 
static expandAggregates (AggregateMessageGroup $agg)
 
static forGroupInternal (MessageGroup $group, array $stats, $flags)
 
static selectRowsIdLang (?array $ids, ?array $codes, $flags)
 Fetch rows from the database.
 
static forItemInternal (&$stats, MessageGroup $group, $code, $flags)
 
static calculateGroup (MessageGroup $group, $code)
 
static queueUpdates ( $flags)
 
static withLock (IDatabase $dbw, $key, $method, $callback)
 

Static Protected Attributes

static $updates = []
 

Detailed Description

This class abstract MessageGroup statistics calculation and storing.

You can access stats easily per language or per group. Stat array for each item is of format array( total, translate, fuzzy ).

Definition at line 22 of file MessageGroupStats.php.

Member Function Documentation

◆ calculateGroup()

static MessageGroupStats::calculateGroup ( MessageGroup $group,
$code )
staticprotected
Parameters
MessageGroup$group
string$codeLanguage code
Returns
int[] ( total, translated, fuzzy, proofread )

Definition at line 541 of file MessageGroupStats.php.

◆ clear()

static MessageGroupStats::clear ( MessageHandle $handle)
static

Recalculate stats for all groups associated with the message.

Hook: TranslateEventTranslationReview

Parameters
MessageHandle$handle

Definition at line 178 of file MessageGroupStats.php.

◆ clearAll()

static MessageGroupStats::clearAll ( )
static

Purges all cached stats.

Mostly for testing purposes. Calling this in normal operation will cause performance issues.

Definition at line 278 of file MessageGroupStats.php.

◆ clearGroup()

static MessageGroupStats::clearGroup ( $id,
int $flags = 0 )
static

Recalculate stats for given group(s).

Parameters
string | string[]$idMessage group ids.
int$flagsCombination of FLAG_* constants.

Definition at line 193 of file MessageGroupStats.php.

◆ clearLanguage()

static MessageGroupStats::clearLanguage ( $code)
static

Definition at line 263 of file MessageGroupStats.php.

◆ expandAggregates()

static MessageGroupStats::expandAggregates ( AggregateMessageGroup $agg)
staticprotected
Parameters
AggregateMessageGroup$agg
Returns
MessageGroup[]

Definition at line 352 of file MessageGroupStats.php.

◆ extractNumbers()

static MessageGroupStats::extractNumbers ( $row)
staticprotected

Returns an array of needed database fields.

Parameters
stdClass$row
Returns
array

Definition at line 316 of file MessageGroupStats.php.

◆ extractResults()

static MessageGroupStats::extractResults ( $res,
array $ids,
array $stats = [] )
staticprotected

Use this to extract results returned from selectRowsIdLang.

You must pass the message group ids you want to retrieve. Entries that do not match are not returned.

Parameters
iterable$resDatabase result object
string[]$idsList of message group ids
array[]$statsOptional array to append results to.
Returns
array[]

Definition at line 293 of file MessageGroupStats.php.

◆ forEverything()

static MessageGroupStats::forEverything ( $flags = 0)
static

Returns stats for all group in all languages.

Might be slow, might use lots of memory. Returns two dimensional array indexed by group and language.

Parameters
int$flagsCombination of FLAG_* constants.
Returns
array[]

Definition at line 160 of file MessageGroupStats.php.

◆ forGroup()

static MessageGroupStats::forGroup ( $id,
$flags = 0 )
static

Returns stats for all languages in given group.

Parameters
string$idGroup id
int$flagsCombination of FLAG_* constants.
Returns
array[]

Definition at line 134 of file MessageGroupStats.php.

◆ forGroupInternal()

static MessageGroupStats::forGroupInternal ( MessageGroup $group,
array $stats,
$flags )
staticprotected
Parameters
MessageGroup$group
array[]$stats
int$flagsCombination of FLAG_* constants.
Returns
array[]

Definition at line 373 of file MessageGroupStats.php.

◆ forItem()

static MessageGroupStats::forItem ( $id,
$code,
$flags = 0 )
static

Returns stats for given group in given language.

Parameters
string$idGroup id
string$codeLanguage code
int$flagsCombination of FLAG_* constants.
Returns
null[]|int[]

Definition at line 81 of file MessageGroupStats.php.

◆ forItemInternal()

static MessageGroupStats::forItemInternal ( & $stats,
MessageGroup $group,
$code,
$flags )
staticprotected
Parameters
array[]&$stats
MessageGroup$group
string$codeLanguage code
int$flagsCombination of FLAG_* constants.
Returns
null[]|int[]

Definition at line 432 of file MessageGroupStats.php.

◆ forLanguage()

static MessageGroupStats::forLanguage ( $code,
$flags = 0 )
static

Returns stats for all groups in given language.

Parameters
string$codeLanguage code
int$flagsCombination of FLAG_* constants.
Returns
array[]

Definition at line 105 of file MessageGroupStats.php.

◆ forLanguageInternal()

static MessageGroupStats::forLanguageInternal ( $code,
array $stats,
$flags )
staticprotected
Parameters
string$codeLanguage code
array[]$stats
int$flagsCombination of FLAG_* constants.
Returns
array[]

Definition at line 331 of file MessageGroupStats.php.

◆ getDatabaseIdForGroupId()

static MessageGroupStats::getDatabaseIdForGroupId ( $id)
static

Definition at line 655 of file MessageGroupStats.php.

◆ getEmptyStats()

static MessageGroupStats::getEmptyStats ( )
static

Returns empty stats array.

Useful because the number of elements may change.

Returns
int[]
Since
2012-09-21

Definition at line 49 of file MessageGroupStats.php.

◆ getUnknownStats()

static MessageGroupStats::getUnknownStats ( )
staticprotected

Returns empty stats array that indicates stats are incomplete or unknown.

Returns
null[]
Since
2013-01-02

Definition at line 59 of file MessageGroupStats.php.

◆ multiAdd()

static MessageGroupStats::multiAdd ( & $a,
$b )
static

Definition at line 525 of file MessageGroupStats.php.

◆ queueUpdates()

static MessageGroupStats::queueUpdates ( $flags)
staticprotected

Definition at line 589 of file MessageGroupStats.php.

◆ selectRowsIdLang()

static MessageGroupStats::selectRowsIdLang ( ?array $ids,
?array $codes,
$flags )
staticprotected

Fetch rows from the database.

Use extractResults to process this value.

Parameters
?string[]$idsList of message group ids
?string[]$codesList of language codes
int$flagsCombination of FLAG_* constants.
Returns
iterable Database result object

Definition at line 404 of file MessageGroupStats.php.

◆ withLock()

static MessageGroupStats::withLock ( IDatabase $dbw,
$key,
$method,
$callback )
staticprotected

Definition at line 639 of file MessageGroupStats.php.

Member Data Documentation

◆ $updates

MessageGroupStats::$updates = []
staticprotected

Definition at line 39 of file MessageGroupStats.php.

◆ FLAG_CACHE_ONLY

const MessageGroupStats::FLAG_CACHE_ONLY = 1

If stats are not cached, do not attempt to calculate them on the fly.

Definition at line 32 of file MessageGroupStats.php.

◆ FLAG_IMMEDIATE_WRITES

const MessageGroupStats::FLAG_IMMEDIATE_WRITES = 4

Do not defer updates. Meant for jobs like MessageGroupStatsRebuildJob.

Definition at line 36 of file MessageGroupStats.php.

◆ FLAG_NO_CACHE

const MessageGroupStats::FLAG_NO_CACHE = 2

Ignore cached values. Useful for updating stale values.

Definition at line 34 of file MessageGroupStats.php.

◆ FUZZY

const MessageGroupStats::FUZZY = 2

Array index.

Definition at line 28 of file MessageGroupStats.php.

◆ PROOFREAD

const MessageGroupStats::PROOFREAD = 3

Array index.

Definition at line 29 of file MessageGroupStats.php.

◆ TOTAL

const MessageGroupStats::TOTAL = 0

Array index.

Definition at line 26 of file MessageGroupStats.php.

◆ TRANSLATED

const MessageGroupStats::TRANSLATED = 1

Array index.

Definition at line 27 of file MessageGroupStats.php.


The documentation for this class was generated from the following file: