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 | getApproximateLanguageStats () |
Fetch aggregated statistics for all languages across groups. | |
static | getLanguages () |
Get list of supported languages for statistics. | |
static | clearLanguage ( $code) |
static | clearAll () |
Purges all cached stats. | |
static | multiAdd (&$a, $b) |
static | getDatabaseIdForGroupId ( $id) |
static | getStatsForCollection (MessageCollection $collection) |
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 = [] |
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 26 of file MessageGroupStats.php.
|
staticprotected |
MessageGroup | $group | |
string | $code | Language code |
Definition at line 614 of file MessageGroupStats.php.
|
static |
Recalculate stats for all groups associated with the message.
Hook: TranslateEventTranslationReview
MessageHandle | $handle |
Definition at line 196 of file MessageGroupStats.php.
|
static |
Purges all cached stats.
Mostly for testing purposes. Calling this in normal operation will cause performance issues.
Definition at line 351 of file MessageGroupStats.php.
|
static |
Recalculate stats for given group(s).
string | string[] | $id | Message group ids. |
int | $flags | Combination of FLAG_* constants. |
Definition at line 211 of file MessageGroupStats.php.
|
static |
Definition at line 336 of file MessageGroupStats.php.
|
staticprotected |
AggregateMessageGroup | $agg |
Definition at line 425 of file MessageGroupStats.php.
|
staticprotected |
Returns an array of needed database fields.
stdClass | $row |
Definition at line 389 of file MessageGroupStats.php.
|
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.
iterable | $res | Database result object |
string[] | $ids | List of message group ids |
array[] | $stats | Optional array to append results to. |
Definition at line 366 of file MessageGroupStats.php.
|
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.
int | $flags | Combination of FLAG_* constants. |
Definition at line 166 of file MessageGroupStats.php.
|
static |
Returns stats for all languages in given group.
string | $id | Group id |
int | $flags | Combination of FLAG_* constants. |
Definition at line 140 of file MessageGroupStats.php.
|
staticprotected |
MessageGroup | $group | |
array[] | $stats | |
int | $flags | Combination of FLAG_* constants. |
Definition at line 446 of file MessageGroupStats.php.
|
static |
Returns stats for given group in given language.
string | $id | Group id |
string | $code | Language code |
int | $flags | Combination of FLAG_* constants. |
Definition at line 87 of file MessageGroupStats.php.
|
staticprotected |
array[] | &$stats | |
MessageGroup | $group | |
string | $code | Language code |
int | $flags | Combination of FLAG_* constants. |
Definition at line 505 of file MessageGroupStats.php.
|
static |
Returns stats for all groups in given language.
string | $code | Language code |
int | $flags | Combination of FLAG_* constants. |
Definition at line 111 of file MessageGroupStats.php.
|
staticprotected |
string | $code | Language code |
array[] | $stats | |
int | $flags | Combination of FLAG_* constants. |
Definition at line 404 of file MessageGroupStats.php.
|
static |
Fetch aggregated statistics for all languages across groups.
The stats are cached in the WANObjectCache, and recalculated on the fly if the values are stale. The statistics may lag behind the actuals due to extra and missing values
Definition at line 227 of file MessageGroupStats.php.
|
static |
Definition at line 708 of file MessageGroupStats.php.
|
static |
Returns empty stats array.
Useful because the number of elements may change.
Definition at line 55 of file MessageGroupStats.php.
|
static |
Get list of supported languages for statistics.
Definition at line 326 of file MessageGroupStats.php.
|
static |
Definition at line 719 of file MessageGroupStats.php.
|
staticprotected |
Returns empty stats array that indicates stats are incomplete or unknown.
Definition at line 65 of file MessageGroupStats.php.
|
static |
Definition at line 598 of file MessageGroupStats.php.
|
staticprotected |
Definition at line 639 of file MessageGroupStats.php.
|
staticprotected |
Fetch rows from the database.
Use extractResults to process this value.
?string[] | $ids | List of message group ids |
?string[] | $codes | List of language codes |
int | $flags | Combination of FLAG_* constants. |
Definition at line 477 of file MessageGroupStats.php.
|
staticprotected |
Definition at line 692 of file MessageGroupStats.php.
|
staticprotected |
Definition at line 45 of file MessageGroupStats.php.
const MessageGroupStats::FLAG_CACHE_ONLY = 1 |
If stats are not cached, do not attempt to calculate them on the fly.
Definition at line 38 of file MessageGroupStats.php.
const MessageGroupStats::FLAG_IMMEDIATE_WRITES = 4 |
Do not defer updates. Meant for jobs like MessageGroupStatsRebuildJob.
Definition at line 42 of file MessageGroupStats.php.
const MessageGroupStats::FLAG_NO_CACHE = 2 |
Ignore cached values. Useful for updating stale values.
Definition at line 40 of file MessageGroupStats.php.
const MessageGroupStats::FUZZY = 2 |
Array index.
Definition at line 34 of file MessageGroupStats.php.
const MessageGroupStats::PROOFREAD = 3 |
Array index.
Definition at line 35 of file MessageGroupStats.php.
const MessageGroupStats::TOTAL = 0 |
Array index.
Definition at line 32 of file MessageGroupStats.php.
const MessageGroupStats::TRANSLATED = 1 |
Array index.
Definition at line 33 of file MessageGroupStats.php.