2017-02-02 02:24:12 +00:00
|
|
|
/**
|
2017-05-23 10:46:37 +00:00
|
|
|
* @module counts
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the count bucket for the number of edits a user has made.
|
2017-02-02 02:24:12 +00:00
|
|
|
*
|
|
|
|
* The buckets are defined as part of
|
|
|
|
* [the Popups schema](https://meta.wikimedia.org/wiki/Schema:Popups).
|
|
|
|
*
|
|
|
|
* Extracted from `mw.popups.schemaPopups.getEditCountBucket`.
|
|
|
|
*
|
|
|
|
* @param {Number} count
|
|
|
|
* @return {String}
|
|
|
|
*/
|
2017-05-23 10:46:37 +00:00
|
|
|
exports.getEditCountBucket = function getEditCountBucket( count ) {
|
2017-02-02 02:24:12 +00:00
|
|
|
var bucket;
|
|
|
|
|
|
|
|
if ( count === 0 ) {
|
|
|
|
bucket = '0';
|
|
|
|
} else if ( count >= 1 && count <= 4 ) {
|
|
|
|
bucket = '1-4';
|
|
|
|
} else if ( count >= 5 && count <= 99 ) {
|
|
|
|
bucket = '5-99';
|
|
|
|
} else if ( count >= 100 && count <= 999 ) {
|
|
|
|
bucket = '100-999';
|
|
|
|
} else if ( count >= 1000 ) {
|
|
|
|
bucket = '1000+';
|
|
|
|
}
|
|
|
|
|
|
|
|
return bucket + ' edits';
|
2017-05-23 10:46:37 +00:00
|
|
|
};
|
2017-02-02 02:24:12 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-23 10:46:37 +00:00
|
|
|
* Gets the count bucket for the number of previews a user has seen.
|
2017-02-02 02:24:12 +00:00
|
|
|
*
|
|
|
|
* If local storage isn't available - because the user has disabled it
|
|
|
|
* or the browser doesn't support it - then then "unknown" is returned.
|
|
|
|
*
|
|
|
|
* The buckets are defined as part of
|
|
|
|
* [the Popups schema](https://meta.wikimedia.org/wiki/Schema:Popups).
|
|
|
|
*
|
|
|
|
* Extracted from `mw.popups.getPreviewCountBucket`.
|
|
|
|
*
|
|
|
|
* @param {Number} count
|
|
|
|
* @return {String}
|
|
|
|
*/
|
2017-05-23 10:46:37 +00:00
|
|
|
exports.getPreviewCountBucket = function getPreviewCountBucket( count ) {
|
2017-02-02 02:24:12 +00:00
|
|
|
var bucket;
|
|
|
|
|
|
|
|
if ( count === 0 ) {
|
|
|
|
bucket = '0';
|
|
|
|
} else if ( count >= 1 && count <= 4 ) {
|
|
|
|
bucket = '1-4';
|
|
|
|
} else if ( count >= 5 && count <= 20 ) {
|
|
|
|
bucket = '5-20';
|
|
|
|
} else if ( count >= 21 ) {
|
|
|
|
bucket = '21+';
|
|
|
|
}
|
|
|
|
|
2017-08-15 14:12:26 +00:00
|
|
|
return bucket !== undefined ? ( bucket + ' previews' ) : 'unknown';
|
2017-02-02 02:24:12 +00:00
|
|
|
};
|