id
int64
0
1.29M
original_id
stringlengths
32
32
swhid
stringlengths
100
170
sha1
stringlengths
40
40
repo_name
stringlengths
2
45
repo_group
stringclasses
12 values
filepath
stringlengths
5
153
name
stringlengths
1
14.9k
type
stringclasses
3 values
code
stringlengths
7
2.12M
15,400
948664efd947d231adcec52cac543c10
swh:1:cnt:e77827037cba67238e3016f086e78818656e02c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=115-131/
dfddebbca35d1232d0ad501f4d8cc506a70cbf0f
test-kitchen
analytics
util/experimentUtil.js
getBins
function
function getBins(sampleSize, groups) { const sampleSizePerGroup = sampleSize / groups.length; const binRangeSizePerGroup = sampleSizePerGroup * 100000; const binRangeMaxSizePerGroup = 100000 / groups.length; const binRanges = groups.reduce((acc, cur, i) => { const start = Math.floor(i * binRang...
15,401
1bc19685faf1f125c132d4709c8f7c21
swh:1:cnt:e77827037cba67238e3016f086e78818656e02c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=133-145/
dfddebbca35d1232d0ad501f4d8cc506a70cbf0f
test-kitchen
analytics
util/experimentUtil.js
transformGroupsForAnalyticsResponse
function
// TODO: this will need to be updated to append custom splits // when the UI and DB have/make these fields available. // See https://phabricator.wikimedia.org/T393530 function transformGroupsForAnalyticsResponse(variants) { const groups = JSON.parse(variants); return groups.map((item) => ({ name: item.n...
15,402
b735d168bb0f1a5731bf84c7c3bab044
swh:1:cnt:e77827037cba67238e3016f086e78818656e02c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=147-152/
dfddebbca35d1232d0ad501f4d8cc506a70cbf0f
test-kitchen
analytics
util/experimentUtil.js
getUserIdentifierType
function
function getUserIdentifierType(sampleUnit) { if (sampleUnit === 'edge-unique-no-cache-split') { return 'edge-unique'; } return sampleUnit; }
15,403
75e4b4e7bdccf323e06c2dc585e37d22
swh:1:cnt:e77827037cba67238e3016f086e78818656e02c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=154-183/
dfddebbca35d1232d0ad501f4d8cc506a70cbf0f
test-kitchen
analytics
util/experimentUtil.js
getTrafficSplits
function
/** * Converts the sample_rate and variants fields to a map of wiki ID to per-group traffic allocation. * * @param {Object} row * @return {Object<string,Object<string,number>>} */ function getTrafficSplits(row) { const sampleRate = JSON.parse(row.sample_rate); const groups = JSON.parse(row.variants).map((v...
15,404
e3105f4f78e0133461dbcdb377250c53
swh:1:cnt:e77827037cba67238e3016f086e78818656e02c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=185-187/
dfddebbca35d1232d0ad501f4d8cc506a70cbf0f
test-kitchen
analytics
util/experimentUtil.js
parseContextualAttributes
function
function parseContextualAttributes(value) { return typeof value === 'string' ? JSON.parse(value) : (value || []); }
15,405
f1033b4cef2b0c541a11fce919d6f6ad
swh:1:cnt:e77827037cba67238e3016f086e78818656e02c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=198-200/
dfddebbca35d1232d0ad501f4d8cc506a70cbf0f
test-kitchen
analytics
util/experimentUtil.js
parseUserIdentifierType
function
function parseUserIdentifierType(hashAttribute) { return HASH_ATTRIBUTE_MAP[hashAttribute]; }
15,406
6dce095ba2cafb96115814f517ac8978
swh:1:cnt:287aae3b28ecb2a0f485c730481233244651f7f4;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=7-21/
cbc6ddc039a66bd29c923547fe20bf9579c3573e
test-kitchen
analytics
util/instrumentUtil.js
formatInstruments
function
function formatInstruments(instruments) { return instruments.map(({ slug, utc_start_dt, utc_end_dt, sample_unit, sample_rate, stream_name, schema_title, contextual_attributes }) => { return { name: slug, start: formatDateISO8601MinusMilliseconds(utc_start_dt), end...
15,407
aaebf54d947961b4cc8c971198de65c9
swh:1:cnt:714872a53423bf806266bacb9e2b740afb75ce0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=11-27/
1ca0b92b68b7aff61e3d557377c7f6b43135d826
test-kitchen
analytics
util/statusUtil.js
getStatusForDBRow
function
function getStatusForDBRow(row) { const { was_activated, status, utc_start_dt, utc_end_dt } = row; const now = new Date(); const endDate = new Date(utc_end_dt); if (endDate < now) { return 'Complete'; } if (!status) { return was_activated ? 'Inactive' : 'Not ready'; } ...
15,408
0546a1f3244d1b8e1522a35b74dc0305
swh:1:cnt:714872a53423bf806266bacb9e2b740afb75ce0e;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=29-31/
1ca0b92b68b7aff61e3d557377c7f6b43135d826
test-kitchen
analytics
util/statusUtil.js
compareDBRowByStatus
function
function compareDBRowByStatus(a, b) { return STATUS_TO_NUMBER_MAP[a.status] - STATUS_TO_NUMBER_MAP[b.status]; }
15,409
2d914cf86e747ac42d46ae21eb412f24
swh:1:cnt:86203ff3c2325c0f4d509cabeeb5b23c4613b3db;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=64-78/
c128ea8ff57ad811726dae560d9a578d97508dea
test-kitchen
analytics
validation/index.js
runServerSideValidation
function
/** * Run the full validation process: server specific + client sides (update + blur) * * @param data the data to be validated * @param event the event whose validation rules must be run: `new` or `update` * @param namesSlugs all existing names and slugs of instruments and experiments * @param currentData */ fun...
15,410
af0f230060d50a70d7fe1325ce743ee6
swh:1:cnt:86203ff3c2325c0f4d509cabeeb5b23c4613b3db;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=98-118/
c128ea8ff57ad811726dae560d9a578d97508dea
test-kitchen
analytics
validation/index.js
runClientSideValidation
function
/** * Run a validation process on the client side only for a specific field * * @param data data to validate * @param event the event whose validation rules must be run: `blur` or `update` * @param currentField the field that must be validated * @param currentData */ function runClientSideValidation(data, event,...
15,411
6045d6dae766e6e28ecdcb814d1943b1
swh:1:cnt:86203ff3c2325c0f4d509cabeeb5b23c4613b3db;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=120-133/
c128ea8ff57ad811726dae560d9a578d97508dea
test-kitchen
analytics
validation/index.js
validateBlurClientSide
function
/** * Run all the validation rules that correspond to the `blur` event on the client side * * @param data Data that must be validated * @param currentData current data */ function validateBlurClientSide(data, currentData) { validateBlurName(data); validateBlurDetails(data); validateBlurTraffic(data); ...
15,412
f4e582e68cd36705108b10a4db946721
swh:1:cnt:86203ff3c2325c0f4d509cabeeb5b23c4613b3db;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=135-147/
c128ea8ff57ad811726dae560d9a578d97508dea
test-kitchen
analytics
validation/index.js
validateUpdateClientSide
function
/** * Run all the validation rules that correspond to the `update` event on the client side * * @param data Data that must be validated * @param currentData */ function validateUpdateClientSide(data, currentData) { validateUpdateName(data); validateUpdateTraffic(data, currentData); validateUpdateSampli...
15,413
ae80198772df0b86b88ac22ecfd4cd60
swh:1:cnt:86203ff3c2325c0f4d509cabeeb5b23c4613b3db;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=80-96/
c128ea8ff57ad811726dae560d9a578d97508dea
test-kitchen
analytics
validation/index.js
validateServerSide
function
/** * Run all the validation rules that are specific for the server side * * @param data the data to be validated * @param event the event whose validation rules must be run: `new` or `update` * @param namesSlugs all existing names and slugs of instruments and experiments * @param currentData */ function validat...
15,414
b8ad9eae6ad7dbb193da3d207679a597
swh:1:cnt:5700d55fdafd19b2a5c6c1bf05edc6a5a8e5e819;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=4-16/
ee69bbdfaa383f344dea7792144db10e019f9b00
test-kitchen
analytics
validation/validateDetails.js
validateBlurDetails
function
function validateBlurDetails(data) { omitWhen(data.task === '', () => { test('task', 'Enter a valid URL', () => { enforce(data.task).isURL(URL_OPTIONS); }); }); omitWhen(data.email_address === '', () => { test('email_address', 'Enter a valid email address', () => { ...
15,415
81ba7085691f0531560a45c570744353
swh:1:cnt:5700d55fdafd19b2a5c6c1bf05edc6a5a8e5e819;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=18-26/
ee69bbdfaa383f344dea7792144db10e019f9b00
test-kitchen
analytics
validation/validateDetails.js
validateServerDetails
function
function validateServerDetails(data) { test('task', 'Phabricator task is required', () => { enforce(data.task).isNotEmpty(); }); test('email_address', 'Contact email is required', () => { enforce(data.email_address).isNotEmpty(); }); }
15,416
4e5eeed95cb09faf91df93e0c9a08c51
swh:1:cnt:839787ec40aceaef9173b268679e523b21167b8f;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=5-54/
a158f2aa2978bdf1059eb09a99e6fda109297d3a
test-kitchen
analytics
validation/validateDuration.js
validateBlurDuration
function
function validateBlurDuration(data, currentData) { let startDateIsUnchanged = true; if (currentData) { startDateIsUnchanged = new Date(data.utc_start_dt).getTime() === new Date(currentData.utc_start_dt).getTime(); } omitWhen(data.utc_start_dt === '' || data.utc_end_dt === '', () => { te...
15,417
774c82ee8d55559d82a4e9fe2dedce7c
swh:1:cnt:839787ec40aceaef9173b268679e523b21167b8f;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=56-64/
a158f2aa2978bdf1059eb09a99e6fda109297d3a
test-kitchen
analytics
validation/validateDuration.js
validateServerDuration
function
function validateServerDuration(data) { test('utc_start_dt', 'Start date is required', () => { enforce(data.utc_start_dt).isNotEmpty(); }); test('utc_end_dt', 'End date is required', () => { enforce(data.utc_end_dt).isNotEmpty(); }); }
15,418
6d206a32cfd4bf6e929222372e927920
swh:1:cnt:b401cef32e77b0a54df22b65298ad504698d4eba;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=4-26/
31d16f44b6c2b5a80d7961da954dba95f6a87158
test-kitchen
analytics
validation/validateName.js
validateBlurName
function
function validateBlurName(data) { omitWhen(data.name === '', () => { test('name', 'Name cannot be longer than 63 characters', () => { enforce(data.name).shorterThanOrEquals(63); }); }); omitWhen(data.name === '', () => { test('name', 'Name must be at least 8 characters l...
15,419
945866a4b07c9aea54ac1de10af04f9c
swh:1:cnt:b401cef32e77b0a54df22b65298ad504698d4eba;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=28-40/
31d16f44b6c2b5a80d7961da954dba95f6a87158
test-kitchen
analytics
validation/validateName.js
validateUpdateName
function
function validateUpdateName(data) { omitWhen(data.slug === '', () => { test('slug', 'Machine-readable name cannot be longer than 63 characters', () => { enforce(data.slug).shorterThanOrEquals(63); }); }); omitWhen(data.slug === '', () => { test('slug', 'Only letters, num...
15,420
882eaa0f8217d4a6f016dabdbd48d446
swh:1:cnt:b401cef32e77b0a54df22b65298ad504698d4eba;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=42-82/
31d16f44b6c2b5a80d7961da954dba95f6a87158
test-kitchen
analytics
validation/validateName.js
validateServerName
function
function validateServerName(data, event, namesSlugs) { // Create arrays of all names and slugs for searching against pre-existing // names and slugs in the case of new instruments and experiments. const names = Object.values(namesSlugs ?? {}).map((entry) => entry.name); const slugs = Object.values(names...
15,421
f7e60c4b3e98b4e2809b0a67a8bf39ee
swh:1:cnt:cdce43ca35ddf020ae793a2619df839c6b13581e;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=4-18/
18884b0fff076eeef5e1aa6f39f9578d3fb8db41
test-kitchen
analytics
validation/validateRegulation.js
validateUpdateRegulation
function
function validateUpdateRegulation(data) { const contextualAttributes = getContextualAttributesAsArray(data.contextual_attributes); const requiredRiskLevel = getRequiredRiskLevel(contextualAttributes, data.schema_type); // Shows an error if the required risk level is lower than what is required based on se...
15,422
2a1c5c3aed4f8776bedb9bd60c5334bb
swh:1:cnt:cdce43ca35ddf020ae793a2619df839c6b13581e;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=32-48/
18884b0fff076eeef5e1aa6f39f9578d3fb8db41
test-kitchen
analytics
validation/validateRegulation.js
validateServerRegulation
function
function validateServerRegulation(data) { omitWhen(data.risk_level === 'Risk assessment pending' || data.risk_level === 'Tier 3: Low risk', () => { test('security_legal_review', 'Please provide a link to the Security and legal review required for high and medium risk ' + data.type + 's', ...
15,423
050bbcc719986292e666be577817207e
swh:1:cnt:cdce43ca35ddf020ae793a2619df839c6b13581e;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=20-30/
18884b0fff076eeef5e1aa6f39f9578d3fb8db41
test-kitchen
analytics
validation/validateRegulation.js
validateBlurRegulation
function
function validateBlurRegulation(data) { omitWhen( data.security_legal_review === '' || (data.security_legal_review === '' && (data.risk_level === 'Risk assessment pending' || data.risk_level === 'Tier 3: Low risk')), () => { test('security_legal_review', 'Enter a vali...
15,424
63531644cda137f03f90c1b183830432
swh:1:cnt:5c0660502ebfef56a1859f112015a9647555b70d;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=6-30/
7d3420304f2e9f7f4fa425ba91b0a4c3b561c5fb
test-kitchen
analytics
validation/validateSampling.js
validateUpdateSampling
function
function validateUpdateSampling(data) { // Validation rules for traffic for Instruments omitWhen(data.type !== 'instrument', () => { // Validates custom traffic per wiki let i = 0; each(data.sample_rate.custom, (field) => { test('traffic.rate[' + i + ']', 'Enter a value betwe...
15,425
7f79bffbcbce0954432e4c2f50025e56
swh:1:cnt:74f2596a867b9c48a87de48f7b62a7c5f9aa83b1;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=3-11/
2cace52f6be58a5c196f6373250bb273d1abe362
test-kitchen
analytics
validation/validateSchema.js
validateServerSchema
function
function validateServerSchema(data) { test('schema_type', 'Schema type is required', () => { enforce(data.schema_type).isNotEmpty(); }); test('stream_name', 'Stream name is required', () => { enforce(data.stream_name).isNotEmpty(); }); }
15,426
db27ed0fa4dc7f42bbe1e2039bc2dd05
swh:1:cnt:37868e674a5ec32dc0225eba5bf4a235b122d626;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=4-77/
14ea0cd53a7bc315b15e4f5c055cdc92f566e61e
test-kitchen
analytics
validation/validateTraffic.js
validateUpdateTraffic
function
function validateUpdateTraffic(data, currentData) { // T421972: auth.wikimedia.org will be available as a wiki only for edge-unique experiments omitWhen(data.type === 'A/B test' && (data.sample_unit !== 'mw-user'), () => { let i = 0; each(data.sample_rate.custom, (field) => { const i...
15,427
531af3652a27d2073937b4cbc15c849f
swh:1:cnt:37868e674a5ec32dc0225eba5bf4a235b122d626;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=85-113/
14ea0cd53a7bc315b15e4f5c055cdc92f566e61e
test-kitchen
analytics
validation/validateTraffic.js
validateServerTraffic
function
function validateServerTraffic(data) { omitWhen(data.type !== 'A/B test', () => { // TODO Validates data.sample_rate.custom for "No wiki has been selected" // TODO Validates data.sample_rate.custom_projects for "No traffic was assigned" // FIXME // test('wiki', 'There is duplicated ...
15,428
eb92dda34fe314f6854016fcbb19003a
swh:1:cnt:37868e674a5ec32dc0225eba5bf4a235b122d626;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=79-83/
14ea0cd53a7bc315b15e4f5c055cdc92f566e61e
test-kitchen
analytics
validation/validateTraffic.js
validateBlurTraffic
function
function validateBlurTraffic(data) { test('sample_unit', (data.type === 'A/B test' ? 'Identifier type' : 'Sample unit') + ' is required', () => { enforce(data.sample_unit).isNotEmpty(); }); }
15,429
b70e3fa1b2aa562586d255a9d0d351a3
swh:1:cnt:636f14574c6625f4e6bd8028e048723bff3af101;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=3-23/
cf9688a1e93e2cb10f44f86b0e1f683ba14add98
test-kitchen
analytics
validation/validateVariants.js
validateBlurVariants
function
function validateBlurVariants(data) { omitWhen(data.type !== 'A/B test', () => { let i = 0; const currentVariants = []; each(data.variants, (field) => { omitWhen(field.slug === '', () => { test('variants[' + i + '].slug', 'Name must start with a letter or number',...
15,430
1afd152be9d99d94a62c989aba3a5e22
swh:1:cnt:636f14574c6625f4e6bd8028e048723bff3af101;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=50-65/
cf9688a1e93e2cb10f44f86b0e1f683ba14add98
test-kitchen
analytics
validation/validateVariants.js
validateServerVariants
function
function validateServerVariants(data) { omitWhen(data.type !== 'A/B test', () => { let i = 0; each(data.variants, (field) => { test('variants[' + i + '].name', 'Variation name is required', () => { enforce(field.name).isNotEmpty(); }); test('varia...
15,431
bffa54114a7bae3b35d513e605ba894f
swh:1:cnt:636f14574c6625f4e6bd8028e048723bff3af101;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=25-48/
cf9688a1e93e2cb10f44f86b0e1f683ba14add98
test-kitchen
analytics
validation/validateVariants.js
validateUpdateVariants
function
function validateUpdateVariants(data) { let i = 0; each(data.variants, (field) => { omitWhen(field.slug === '', () => { test('variants[' + i + '].slug', 'Only letters, numbers, hyphens (-), underscores (_) and dots (.) are allowed', () => { enforce(field.slug).matches(/^[a-zA...
15,432
3afebc2352486dec79d78b2da1d2d491
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=33-50/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
addDummyVariations
function
/** * Add a couple of dummy variations to an instrument to unify data when validating: * validation rules can be omitted via `omitWhen`but the code is executed anyway so * both structures experiment and instrument must be similar * * @param {Object} data the instrument data */ function addDummyVariations(data) { ...
15,433
420eaa0346ff7a53d289ae81ce1a44e7
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=99-114/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
wikisAreNotRepeated
function
/** * TODO Not in used yet (exploration code for T394486) * Checks whether there is a duplicated wiki project for a given traffic * configuration of an Experiment * * @param sampleRate The given traffic configuration * @return {boolean} Whether there is a duplicated */ function wikisAreNotRepeated(sampleRate) { ...
15,434
46d662aa6e32509973e761174bc742a2
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=89-97/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
isWikiIncluded
function
function isWikiIncluded(sampleRate, wiki) { for (const [, item] of Object.entries(sampleRate)) { if (item.wikis.includes(wiki)) { return true; } } return false; }
15,435
5c7e336bc109273f964c75f54662ef4c
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=68-87/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
getWikiCount
function
/** * Get how many wikis have been added for a specific groups of wikis and their traffic configuration * of an Experiment * * @param {number} sampleRate the `sample_rate` field value which contains the traffic configuration * for an instrument/experiment * @param {number} position the position in the Traffic con...
15,436
3feb82707b10a6b60ad726820a4c16f5
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=52-66/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
getWikiTotalCount
function
/** * Get how many wikis have been added for a specific traffic configuration of an Experiment * * @param {number} sampleRate the `sample_rate` field value which contains the traffic configuration * for an instrument/experiment * @return {number} The number of wikis in the given traffic configuration */ function ...
15,437
936f850980eb57f92f01b35ec0aeab19
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=116-136/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
transformSampleRateForValidation
function
/** * Transforms sample_rate structure, depending on the side where validation is running. * That way there is a common structure to validate same way regardless whether a client * or server validation is running `transformSampleRateForDB` call has been delayed/moved * to be done before saving to the database so no...
15,438
02546c944e3a4054f87f545ff0029a4d
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=138-157/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
getSampleRateForCurrentDataValidation
function
/** * Transform sample_rate structure of the current data to something that can be validated * to be able to compare with data and see if there have been any changes * * @param sampleRate */ function getSampleRateForCurrentDataValidation(sampleRate) { // currentData comes from the database so `sample_rate` is ...
15,439
ad19113c6b76aa4feabae5ff22ac3f9e
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=159-175/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
trimStrings
function
function trimStrings(value) { if (typeof value === 'string') { return value.trim(); } if (Array.isArray(value)) { return value.map(trimStrings); } if (value !== null && typeof value === 'object') { return Object.fromEntries( Object.entries(value).map(([key, val]...
15,440
4770d56941a2b299ddcd969f07d515b1
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=177-194/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
createLookupMaps
function
function createLookupMaps(data) { const idToName = {}; const idToSlug = {}; for (const [id, { name, slug }] of Object.entries(data)) { const numericId = Number(id); if (typeof name === 'string') { idToName[numericId] = name; } if (typeof slug === 'string') { ...
15,441
c3845322ac5ec24095661e04b88d1a82
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=196-210/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
getContextualAttributesAsArray
function
/** * Get the contextual attributes as an array * * @param contextualAttributesAsString Contextual attributes as a string with commas * @return {[]} */ function getContextualAttributesAsArray(contextualAttributesAsString) { const contextualAttributes = []; if (contextualAttributesAsString) { conte...
15,442
fb3f8303249eac5274fca2b7530ee95b
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=218-253/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
getRequiredRiskLevel
function
/** * Get the required risk level based on the combination of contextual attributes selected by the user * * - Only one category is present = Low risk level = 1 * - PERSONAL_INFORMATION_ATTR + UNIQUE_ID_ATTR = Medium risk level = 2 * - LONG_VIEW_HISTORY_ATTR + UNIQUE_ID_ATTR = Medium risk level = 2 * - LONG_TERM_...
15,443
f788a9a0e280dd38fc88387379c5b3c3
swh:1:cnt:ada7ad65923caa07499c165b26141d0ed8b95dbd;origin=https://gitlab.wikimedia.org/repos/data-engineering/test-kitchen.git;lines=212-216/
97fd19857e6120db495b6a12209b188b6f8e2fe0
test-kitchen
analytics
validation/validationUtil.js
isContextualAttributePresent
function
function isContextualAttributePresent(contextualAttributeNames, contextualAttributesAsString) { const contextualAttributesAsArray = getContextualAttributesAsArray(contextualAttributesAsString); return contextualAttributesAsArray.some((item) => contextualAttributeNames.includes(item)); }
15,444
9b8761c15b316537cc663234eadffb8e
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=10-423/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable
type
class CalendarTable { /** @var string */ protected $lng = 'content'; /** @var string */ protected $prevLink = ''; /** @var string */ protected $nextLink = ''; /** @var string */ protected $calTitle = ''; /** @var string[] */ protected $highlightedDays = []; /** @var string[] */ protected $dailyLinks = []; ...
15,445
850436aea0a8d066c61f1305920764cb
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=58-64/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::dayOfWeek( $timestamp )
function
/** * @param int $timestamp * @return int */ public function dayOfWeek( $timestamp ) { return intval( date( 'w', $timestamp ) ); }
15,446
f95fb1aff7898e85854d90da5b7a1929
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=93-101/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::getMonthNameAbbrev( $aMonth, $aLen )
function
/** * @param int $aMonth * @param int $aLen * @return string */ public function getMonthNameAbbrev( $aMonth, $aLen ) { $out = $this->getLang()->getMonthAbbreviation( $aMonth ); return $this->cutLength( $out, $aLen ); }
15,447
55a5b57182848c92ad596efe12bcc0d9
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=83-91/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::getMonthName( $aMonth, $aLen )
function
/** * @param int $aMonth * @param int $aLen * @return string */ public function getMonthName( $aMonth, $aLen ) { $out = $this->getLang()->getMonthName( $aMonth ); return $this->cutLength( $out, $aLen ); }
15,448
4b1b99fa68dbeb0f4f142e65a7e5abcd
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=66-72/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::isLeapYear( $aYear )
function
/** * @param int $aYear * @return bool */ public function isLeapYear( $aYear ) { return cal_days_in_month( CAL_GREGORIAN, 2, $aYear ) === 29; }
15,449
3a66528af265d09d265368c2c45f6ee3
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=74-81/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::dayOfWeekOfFirstOfMonth( $aMonth, $aYear )
function
/** * @param int $aMonth * @param int $aYear * @return int */ public function dayOfWeekOfFirstOfMonth( $aMonth, $aYear ) { return $this->dayOfWeek( mktime( 0, 0, 0, $aMonth, 1, $aYear ) ); }
15,450
6e9a49a614e7d94755915d9fa18de58c
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=103-112/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::getWeekday( $aDay, $aLen )
function
/** * @param int $aDay * @param int $aLen * @return string */ public function getWeekday( $aDay, $aLen ) { // Language::getWeekdayName will subtract 1 from key $out = $this->getLang()->getWeekdayName( $aDay % 7 + 1 ); return $this->cutLength( $out, $aLen ); }
15,451
52c693094445265eae4f25a0aaffd4eb
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=114-123/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::getWeekdayAbbrev( $aDay, $aLen )
function
/** * @param int $aDay * @param int $aLen * @return string */ public function getWeekdayAbbrev( $aDay, $aLen ) { // Language::getWeekdayAbbreviation will subtract 1 from key $out = $this->getLang()->getWeekdayAbbreviation( $aDay % 7 + 1 ); return $this->cutLength( $out, $aLen ); }
15,452
eae90fa91243ee9fffe43a77fbc1bc48
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=125-135/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::cutLength( $string, $len )
function
/** * @param string $string * @param int $len * @return string */ private function cutLength( $string, $len ) { if ( $len > 0 ) { $string = mb_substr( $string, 0, $len ); } return ucfirst( $string ); }
15,453
42c02d2efde8b6e1e21ff4f6a8e92dba
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=137-145/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::getLang()
function
/** * @return Language */ private function getLang() { if ( $this->lng === 'user' ) { return RequestContext::getMain()->getLanguage(); } return MediaWikiServices::getInstance()->getContentLanguage(); }
15,454
f51e4ec6c5cb9140a5dc5289c4c18c0a
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=147-157/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::replace( $str, array $array )
function
/** * @param string $str * @param string[] $array * @return string */ public function replace( $str, array $array ) { foreach ( $array as $key => $val ) { $str = str_replace( '$' . $key, $val, $str ); } return str_replace( '$%', '$', $str ); }
15,455
c6d744a569b84dfe1080af5fa3913970
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=268-422/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::setParameters( array $args )
function
/** * @param array $args */ public function setParameters( array $args ) { $this->today = new DateTime( "now" ); $this->curDay = intval( $this->today->format( "d" ) ); $this->curMonth = intval( $this->today->format( "m" ) ); $this->curYear = intval( $this->today->format( "Y" ) ); $this->month = $this->cu...
15,456
bb7409898c83212c635bc2121698d77a
swh:1:cnt:100d17e3e4f7ba5d152a21e8bcbed402e7152625;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=159-266/
d22818c607d8e3d1277049830c60da84bd54ad10
Calendar
deployed
includes/CalendarTable.php
CalendarTable::buildTable()
function
/** * @return string */ public function buildTable() { $day1 = $this->dayOfWeekOfFirstOfMonth( $this->month, $this->year ); if ( ( $this->weekStart > 0 ) && ( $day1 === 0 ) ) { $day1 = 7; } $days = cal_days_in_month( CAL_GREGORIAN, $this->month, $this->year ); $style = ''; $result = 'calendar'; s...
15,457
3124e5261dfefa6961109b4b4513e73c
swh:1:cnt:a399da8ec06619d6a93d54d1f4a15774934d1eff;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=8-31/
2a6ac8a19a84bb5629c8993b1507d188ee0ea981
Calendar
deployed
includes/Hooks.php
Hooks
type
/** * Some hooks for Calendar extension. */ class Hooks implements ParserFirstCallInitHook { /** * @param Parser $parser */ public function onParserFirstCallInit( $parser ) { $parser->setFunctionHook( 'calendar', [ self::class, 'calendarMagicWord' ] ); } /** * @param Parser $parser * @param string ...$...
15,458
0472e758636475e31d1febc46bccc3fe
swh:1:cnt:a399da8ec06619d6a93d54d1f4a15774934d1eff;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=12-17/
2a6ac8a19a84bb5629c8993b1507d188ee0ea981
Calendar
deployed
includes/Hooks.php
Hooks::onParserFirstCallInit( $parser )
function
/** * @param Parser $parser */ public function onParserFirstCallInit( $parser ) { $parser->setFunctionHook( 'calendar', [ self::class, 'calendarMagicWord' ] ); }
15,459
ee99e0e00f1a3c4e04da7e64c7da3cd7
swh:1:cnt:a399da8ec06619d6a93d54d1f4a15774934d1eff;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/Calendar.git;lines=19-30/
2a6ac8a19a84bb5629c8993b1507d188ee0ea981
Calendar
deployed
includes/Hooks.php
Hooks::calendarMagicWord( Parser $parser, ...$args )
function
/** * @param Parser $parser * @param string ...$args * @return string */ public static function calendarMagicWord( Parser $parser, ...$args ) { $parser->getOutput()->addModuleStyles( [ 'ext.calendar' ] ); $calendar = new CalendarTable; $calendar->setParameters( $args ); return $calendar->buildTable();...
15,460
ff90778e15563c530faeb1e0b00bcec5
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=26-235/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer
type
/** * The AboutTopic SpecialPage for the ArticlePlaceholder extension * The AboutTopicRenderer assumes the 'wikibase_item' OutputPage property * is set in SpecialAboutTopic * * @ingroup Extensions * @author Lucie-Aimée Kaffee * @license GPL-2.0-or-later */ class AboutTopicRenderer { public function __construc...
15,461
48de07972b6ff3aed63c15b61413fd11
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=37-48/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::__construct( private readonly FallbackLabelDescriptionLookupFactory $termLookupFactory, private readonly LanguageNameUtils $languageNameUtils, private readonly SiteLinkLookup $siteLinkLookup, private readonly SiteLookup $siteLookup, private readonly string $langLinkSiteGroup, private rea...
function
public function __construct( private readonly FallbackLabelDescriptionLookupFactory $termLookupFactory, private readonly LanguageNameUtils $languageNameUtils, private readonly SiteLinkLookup $siteLinkLookup, private readonly SiteLookup $siteLookup, private readonly string $langLinkSiteGroup, private readonl...
15,462
79f4a7243da888fac98499696d2e7d9d
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=50-91/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::showPlaceholder( ItemId $entityId, Language $language, User $user, OutputPage $output, )
function
/** * Show content of the ArticlePlaceholder */ public function showPlaceholder( ItemId $entityId, Language $language, User $user, OutputPage $output, ): void { $termLookup = $this->termLookupFactory->newLabelDescriptionLookup( $language, [ $entityId ], [ TermTypes::TYPE_LABEL, TermTypes::TYPE_...
15,463
9b715d47eb612fa54c39bbe2728d4179
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=179-184/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::showTitle( string $label, OutputPage $output )
function
/** * Show label as page title */ private function showTitle( string $label, OutputPage $output ): void { $output->setPageTitle( htmlspecialchars( $label ) ); }
15,464
1c3ef7acb5e1c31bdab102eb09740615
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=93-138/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::showTopMessage( ItemId $entityId, ?string $label, OutputPage $output, bool $canEdit, )
function
/** * Adds the top message bar */ private function showTopMessage( ItemId $entityId, ?string $label, OutputPage $output, bool $canEdit, ): void { $infoIcon = new OOUI\IconWidget( [ 'icon' => 'infoFilled', 'title' => $output->msg( 'articleplaceholder-abouttopic-icon-title' )->text() ] ); $outp...
15,465
66cb466b0420406d4401e6d66c42c829
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=140-177/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::showCreateArticle( ItemId $itemId, string $label, OutputPage $output, )
function
/** * Adds a button to create an article * * @param ItemId $itemId * @param string $label * @param OutputPage $output * * @return string HTML */ private function showCreateArticle( ItemId $itemId, string $label, OutputPage $output, ): string { $siteLinks = $this->siteLinkLookup->getSiteLinksFo...
15,466
6da49388f3f70fc151a5496c4fe76076
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=186-219/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::showLanguageLinks( ItemId $entityId, OutputPage $output )
function
/** * Set language links */ private function showLanguageLinks( ItemId $entityId, OutputPage $output ): void { $siteLinks = $this->siteLinkLookup->getSiteLinksForItem( $entityId ); $languageLinks = []; $languageNames = []; $pageNames = []; foreach ( $siteLinks as $siteLink ) { $site = $this->siteLook...
15,467
ddab3b68635c770231c8ca832b618f65
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=221-227/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::setOtherProjectsLinks( ItemId $itemId, OutputPage $output )
function
private function setOtherProjectsLinks( ItemId $itemId, OutputPage $output ): void { $otherProjectsSidebarGenerator = $this->otherProjectsSidebarGeneratorFactory ->getOtherProjectsSidebarGenerator( new HashUsageAccumulator() ); $otherProjects = $otherProjectsSidebarGenerator->buildProjectLinkSidebarFromItemId( ...
15,468
b1917995f94c4f93464a917d0f5baab1
swh:1:cnt:36208ce79d4d511fedb012d918da74fdf81b0721;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=229-233/
b3de143d337ac7d3b7eff7ec60c897b3706f9e0a
ArticlePlaceholder
deployed
includes/AboutTopicRenderer.php
AboutTopicRenderer::addMetaTags( OutputPage $output, ?Term $description )
function
private function addMetaTags( OutputPage $output, ?Term $description ): void { if ( $description !== null ) { $output->addMeta( 'description', trim( $description->getText() ) ); } }
15,469
e31be7ddfeeb7d46c8c5cd432017fe3a
swh:1:cnt:b272d0543348531d16b15fc3008cc3010a4fa4dd;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=12-132/
509025fec69a7dc0b6e2e917d9b0ec57e9460ca4
ArticlePlaceholder
deployed
includes/ItemNotabilityFilter.php
ItemNotabilityFilter
type
/** * Filter a list of items by article placeholder notability. * * @license GPL-2.0-or-later * @author Lucie-Aimée Kaffee * @author Marius Hoch */ class ItemNotabilityFilter { /** * Minimum number of statements for an item to be notable */ private const MIN_STATEMENTS = 3; /** * Minimum number of site...
15,470
80a5ff06e57d04db4440d8c580eac120
swh:1:cnt:b272d0543348531d16b15fc3008cc3010a4fa4dd;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=31-37/
509025fec69a7dc0b6e2e917d9b0ec57e9460ca4
ArticlePlaceholder
deployed
includes/ItemNotabilityFilter.php
ItemNotabilityFilter::__construct( private readonly IReadableDatabase $dbr, private readonly EntityNamespaceLookup $entityNamespaceLookup, private readonly SiteLinkLookup $siteLinkLookup, private readonly string $siteGlobalId, )
function
public function __construct( private readonly IReadableDatabase $dbr, private readonly EntityNamespaceLookup $entityNamespaceLookup, private readonly SiteLinkLookup $siteLinkLookup, private readonly string $siteGlobalId, ) { }
15,471
69f1d9083a2cc7bcf7f20492035c9830
swh:1:cnt:b272d0543348531d16b15fc3008cc3010a4fa4dd;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=89-116/
509025fec69a7dc0b6e2e917d9b0ec57e9460ca4
ArticlePlaceholder
deployed
includes/ItemNotabilityFilter.php
ItemNotabilityFilter::selectPagePropsPage( array $itemIds )
function
/** * @param ItemId[] $itemIds * @return IResultWrapper */ private function selectPagePropsPage( array $itemIds ): IResultWrapper { $entityNamespace = $this->entityNamespaceLookup->getEntityNamespace( 'item' ); if ( !is_int( $entityNamespace ) ) { wfLogWarning( 'The ArticlePlaceholder extension requires ...
15,472
2d964bda30acb7b5be14266722a1357d
swh:1:cnt:b272d0543348531d16b15fc3008cc3010a4fa4dd;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=73-87/
509025fec69a7dc0b6e2e917d9b0ec57e9460ca4
ArticlePlaceholder
deployed
includes/ItemNotabilityFilter.php
ItemNotabilityFilter::getPagePropsByItem( array $itemIds )
function
/** * @param ItemId[] $itemIds * @return int[][] Map of page_title => propname => numeric value */ private function getPagePropsByItem( array $itemIds ): array { $values = []; $res = $this->selectPagePropsPage( $itemIds ); foreach ( $res as $row ) { $values[$row->page_title][$row->pp_propname] = intva...
15,473
a38e351b1428158bf3abb408497baf62
swh:1:cnt:b272d0543348531d16b15fc3008cc3010a4fa4dd;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=39-71/
509025fec69a7dc0b6e2e917d9b0ec57e9460ca4
ArticlePlaceholder
deployed
includes/ItemNotabilityFilter.php
ItemNotabilityFilter::getNotableEntityIds( array $itemIds )
function
/** * @param ItemId[] $itemIds * @return ItemId[] */ public function getNotableEntityIds( array $itemIds ): array { if ( $itemIds === [] ) { return []; } $byNumericId = []; $pagePropsByItem = $this->getPagePropsByItem( $itemIds ); foreach ( $itemIds as $itemId ) { $itemIdSerialization = $itemI...
15,474
6e0668efea0fb2f480115a9c707f7416
swh:1:cnt:b272d0543348531d16b15fc3008cc3010a4fa4dd;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=118-130/
509025fec69a7dc0b6e2e917d9b0ec57e9460ca4
ArticlePlaceholder
deployed
includes/ItemNotabilityFilter.php
ItemNotabilityFilter::getItemsWithoutArticle( array $itemIds )
function
/** * @param ItemId[] $itemIds expected to be indexed by numeric item ID * @return ItemId[] */ private function getItemsWithoutArticle( array $itemIds ): array { $links = $this->siteLinkLookup->getLinks( array_keys( $itemIds ), [ $this->siteGlobalId ] ); foreach ( $links as [ , , $numericId ] ) { unset( ...
15,475
e832579bf306316941c16d6afba40e16
swh:1:cnt:b7e8fcae7cdc437dc86563a68891b07d18b51442;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=9-57/
2e1f5a890100c95a5edf094b6c6fe796a8047ccb
ArticlePlaceholder
deployed
includes/RepoApiInteractor.php
RepoApiInteractor
type
/** * Gateway to API of the repository * * @license GPL-2.0-or-later */ class RepoApiInteractor { public function __construct( private readonly string $repoApiUrl, private readonly StatsFactory $statsFactory, private readonly HttpRequestFactory $httpRequestFactory, ) { } public function request( array $...
15,476
1c047f517a2350f586ff4c9128e6007b
swh:1:cnt:b7e8fcae7cdc437dc86563a68891b07d18b51442;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=16-21/
2e1f5a890100c95a5edf094b6c6fe796a8047ccb
ArticlePlaceholder
deployed
includes/RepoApiInteractor.php
RepoApiInteractor::__construct( private readonly string $repoApiUrl, private readonly StatsFactory $statsFactory, private readonly HttpRequestFactory $httpRequestFactory, )
function
public function __construct( private readonly string $repoApiUrl, private readonly StatsFactory $statsFactory, private readonly HttpRequestFactory $httpRequestFactory, ) { }
15,477
bd505d422e1b8c0ba87f84fd1180556d
swh:1:cnt:b7e8fcae7cdc437dc86563a68891b07d18b51442;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=23-55/
2e1f5a890100c95a5edf094b6c6fe796a8047ccb
ArticlePlaceholder
deployed
includes/RepoApiInteractor.php
RepoApiInteractor::request( array $params )
function
public function request( array $params ): array { $url = wfAppendQuery( $this->repoApiUrl, $params ); $req = $this->httpRequestFactory->create( $url, [ 'userAgent' => 'ArticlePlaceholder ' . $this->httpRequestFactory->getUserAgent(), ], __METHOD__ ); $metric = $this->statsFactory->getCounter( 'A...
15,478
12197f03f6b7e3947a1ffc808e280232
swh:1:cnt:a569a0b7a17e47e561ebb56dfc523957234d154d;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=9-51/
1e2fe3bc6715c940f199a14353f782170177a375
ArticlePlaceholder
deployed
includes/ScribuntoHooks.php
ScribuntoHooks
type
/** * File defining the hook handlers for the ArticlePlaceholder extension. * All hooks from the Scribunto extension which is optional to use with this extension. * * @license GPL-2.0-or-later * @author Lucie-Aimée Kaffee */ class ScribuntoHooks implements ScribuntoExternalLibrariesHook, ScribuntoExternalLibrar...
15,479
c80985334f7ccb781e922955a0a02b0a
swh:1:cnt:a569a0b7a17e47e561ebb56dfc523957234d154d;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=21-34/
1e2fe3bc6715c940f199a14353f782170177a375
ArticlePlaceholder
deployed
includes/ScribuntoHooks.php
ScribuntoHooks::onScribuntoExternalLibraries( string $engine, array &$extraLibraries )
function
/** * External Lua libraries for Scribunto * * @param string $engine * @param array[] &$extraLibraries */ public function onScribuntoExternalLibraries( string $engine, array &$extraLibraries ): void { if ( $engine === 'lua' ) { $extraLibraries['mw.ext.articlePlaceholder.entityRenderer'] = [ 'class' ...
15,480
4c4677e3caaa1d8a46689f572c4ddc05
swh:1:cnt:a569a0b7a17e47e561ebb56dfc523957234d154d;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=36-49/
1e2fe3bc6715c940f199a14353f782170177a375
ArticlePlaceholder
deployed
includes/ScribuntoHooks.php
ScribuntoHooks::onScribuntoExternalLibraryPaths( string $engine, array &$extraLibraryPaths )
function
/** * External Lua library paths for Scribunto * * @param string $engine * @param string[] &$extraLibraryPaths */ public function onScribuntoExternalLibraryPaths( string $engine, array &$extraLibraryPaths ): void { if ( $engine === 'lua' ) { $extraLibraryPaths[] = __DIR__ . '/Lua'; } }
15,481
d76156d0f89c2080c868c2256d1f077f
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=20-197/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler
type
/** * Add results from ArticlePlaceholder to search * * @license GPL-2.0-or-later * @author Lucie-Aimée Kaffee */ class SearchHookHandler implements SpecialSearchResultsAppendHook { public static function newFromGlobalState( Config $config, IConnectionProvider $connectionProvider, HttpRequestFactory $httpR...
15,482
a5f265a159f2f2f1869a0341bb51b095
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=28-62/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::newFromGlobalState( Config $config, IConnectionProvider $connectionProvider, HttpRequestFactory $httpRequestFactory, StatsFactory $statsFactory, )
function
public static function newFromGlobalState( Config $config, IConnectionProvider $connectionProvider, HttpRequestFactory $httpRequestFactory, StatsFactory $statsFactory, ): self { // TODO inject services into hook handler instance $mwServices = MediaWikiServices::getInstance(); $repoDB = WikibaseClient::g...
15,483
aa812b9d09569a325bfe42b78d5d2c80
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=123-134/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::getTermSearchResults( string $term )
function
/** * @return TermSearchResult[] */ private function getTermSearchResults( string $term ): array { $termSearchResults = []; foreach ( $this->searchEntities( $term ) as $searchResult ) { $termSearchResults[ $searchResult->getEntityIdSerialization() ] = $searchResult; } return $termSearchResults; }
15,484
f4609be824e266efa5a08a7fdf496c77
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=94-121/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::addToSearch( OutputPage $output, string $term )
function
private function addToSearch( OutputPage $output, string $term ): void { $termSearchResults = $this->getTermSearchResults( $term ); if ( $termSearchResults ) { $renderedTermSearchResults = $this->renderTermSearchResults( $termSearchResults ); if ( $renderedTermSearchResults !== '' ) { $output->addWikiTe...
15,485
1be6d0135c928ff669d194496a020939
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=64-70/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::__construct( private readonly TermSearchInteractor $termSearchInteractor, private readonly string $languageCode, private readonly ItemNotabilityFilter $itemNotabilityFilter, private readonly CounterMetric $searchesMetric, )
function
public function __construct( private readonly TermSearchInteractor $termSearchInteractor, private readonly string $languageCode, private readonly ItemNotabilityFilter $itemNotabilityFilter, private readonly CounterMetric $searchesMetric, ) { }
15,486
a21f6bf528ad8303df2dda362790a1c7
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=72-92/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::onSpecialSearchResultsAppend( $specialSearch, $output, $term )
function
/** * @param SpecialSearch $specialSearch * @param OutputPage $output * @param string $term */ public function onSpecialSearchResultsAppend( $specialSearch, $output, $term ) { if ( trim( $term ) === '' ) { return; } $config = $specialSearch->getConfig(); if ( !$config->get( 'ArticlePlacehold...
15,487
77cc0ba1dfdab0eed81fad73cc1e2d5d
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=136-161/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::renderTermSearchResults( array $termSearchResults )
function
/** * Render search results, filtered for notability. * * @param TermSearchResult[] $termSearchResults * @return string Wikitext */ private function renderTermSearchResults( array $termSearchResults ): string { $wikitext = ''; $itemIds = []; foreach ( $termSearchResults as $termSearchResult ) { $it...
15,488
d3c323947de9cb2f098998108f647cf4
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=163-183/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::renderTermSearchResult( TermSearchResult $searchResult )
function
/** * @return string Wikitext */ private function renderTermSearchResult( TermSearchResult $searchResult ): string { $entityIdString = $searchResult->getEntityIdSerialization(); $displayLabel = $searchResult->getDisplayLabel(); $displayDescription = $searchResult->getDisplayDescription(); $label = $displ...
15,489
c0e50add9f5ba752043066c9d5003711
swh:1:cnt:d2304ebfbdcc64e511b19fbebaa14abf3c703e89;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=185-195/
3f0176a0670648271c3701384bb1598faed1a516
ArticlePlaceholder
deployed
includes/SearchHookHandler.php
SearchHookHandler::searchEntities( string $term )
function
/** * @return TermSearchResult[] */ private function searchEntities( string $term ): array { return $this->termSearchInteractor->searchForEntities( $term, $this->languageCode, 'item', [ TermIndexEntry::TYPE_LABEL, TermIndexEntry::TYPE_ALIAS ] ); }
15,490
efa0002b91306b29479c9f1e6faab4b0
swh:1:cnt:97a4b934f599736d181df604e5b4f46a2cb75de0;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=15-109/
027328aef415c047f87e6f74a4a1f3b3b072f319
ArticlePlaceholder
deployed
includes/SidebarBeforeOutputHookHandler.php
SidebarBeforeOutputHookHandler
type
/** * Add Wikibase item link in toolbox for placeholders: Handler for the "SidebarBeforeOutput" hook. * * @license GPL-2.0-or-later * @author Marius Hoch < hoo@online.de > */ class SidebarBeforeOutputHookHandler implements SidebarBeforeOutputHook { public static function newFromGlobalState( SpecialPageFactory $s...
15,491
6fa06151f9c573f3267d10d1070e8db3
swh:1:cnt:97a4b934f599736d181df604e5b4f46a2cb75de0;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=23-30/
027328aef415c047f87e6f74a4a1f3b3b072f319
ArticlePlaceholder
deployed
includes/SidebarBeforeOutputHookHandler.php
SidebarBeforeOutputHookHandler::newFromGlobalState( SpecialPageFactory $specialPageFactory )
function
public static function newFromGlobalState( SpecialPageFactory $specialPageFactory ): self { return new self( WikibaseClient::getEntityIdParser(), WikibaseClient::getRepoLinker(), WikibaseClient::getStore()->getEntityLookup(), $specialPageFactory ); }
15,492
a634f45747f1c6e261dd23d2c2f77a09
swh:1:cnt:97a4b934f599736d181df604e5b4f46a2cb75de0;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=54-79/
027328aef415c047f87e6f74a4a1f3b3b072f319
ArticlePlaceholder
deployed
includes/SidebarBeforeOutputHookHandler.php
SidebarBeforeOutputHookHandler::buildSidebarLink( Skin $skin )
function
/** * Do checks. Build link array, if possible. * * @param Skin $skin * * @return bool|string[] Array of link elements or False if link cannot be created */ public function buildSidebarLink( Skin $skin ) { // Return early (for performance reasons) in case we're not on // Special:AboutTopic (even before...
15,493
08a92946f5a9699764dc648c9702fa3e
swh:1:cnt:97a4b934f599736d181df604e5b4f46a2cb75de0;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=32-38/
027328aef415c047f87e6f74a4a1f3b3b072f319
ArticlePlaceholder
deployed
includes/SidebarBeforeOutputHookHandler.php
SidebarBeforeOutputHookHandler::__construct( private readonly EntityIdParser $entityIdParser, private readonly RepoLinker $repoLinker, private readonly EntityLookup $entityLookup, private readonly SpecialPageFactory $specialPageFactory, )
function
public function __construct( private readonly EntityIdParser $entityIdParser, private readonly RepoLinker $repoLinker, private readonly EntityLookup $entityLookup, private readonly SpecialPageFactory $specialPageFactory, ) { }
15,494
90727de1a14b9fdc996c86af349e2244
swh:1:cnt:97a4b934f599736d181df604e5b4f46a2cb75de0;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=40-52/
027328aef415c047f87e6f74a4a1f3b3b072f319
ArticlePlaceholder
deployed
includes/SidebarBeforeOutputHookHandler.php
SidebarBeforeOutputHookHandler::onSidebarBeforeOutput( $skin, &$sidebar )
function
/** * @param Skin $skin * @param array[] &$sidebar * * @return void */ public function onSidebarBeforeOutput( $skin, &$sidebar ): void { $sidebarLink = $this->buildSidebarLink( $skin ); if ( $sidebarLink ) { // Append link $sidebar['TOOLBOX']['wikibase'] = $sidebarLink; } }
15,495
8e68f19cf61f9b058403e5f990f7b172
swh:1:cnt:97a4b934f599736d181df604e5b4f46a2cb75de0;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=81-107/
027328aef415c047f87e6f74a4a1f3b3b072f319
ArticlePlaceholder
deployed
includes/SidebarBeforeOutputHookHandler.php
SidebarBeforeOutputHookHandler::getItemId( Skin $skin )
function
private function getItemId( Skin $skin ): ?ItemId { $title = $skin->getTitle(); if ( !$title ) { return null; } $request = $skin->getRequest(); $idSerialization = $request->getVal( 'entityid', $this->specialPageFactory->resolveAlias( $title->getText() )[1] ); if ( !$idSerialization ) { ret...
15,496
9aa24afd59334a6b599aee6b33454add
swh:1:cnt:6674ae4fdd88d2e111b09f01fc3e550960033442;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=10-71/
963ad209b8f7b2e391a0982113473c8881a680fb
ArticlePlaceholder
deployed
includes/TermSearchApiInteractor.php
TermSearchApiInteractor
type
/** * Repository's API-based term search interactor * * @license GPL-2.0-or-later */ class TermSearchApiInteractor implements TermSearchInteractor { public function __construct( private readonly RepoApiInteractor $repoApiInteractor, private readonly EntityIdParser $entityIdParser, ) { } /** @inheritDoc */...
15,497
de6719e3019f5dcd3339481a2eb5c0c9
swh:1:cnt:6674ae4fdd88d2e111b09f01fc3e550960033442;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=17-21/
963ad209b8f7b2e391a0982113473c8881a680fb
ArticlePlaceholder
deployed
includes/TermSearchApiInteractor.php
TermSearchApiInteractor::__construct( private readonly RepoApiInteractor $repoApiInteractor, private readonly EntityIdParser $entityIdParser, )
function
public function __construct( private readonly RepoApiInteractor $repoApiInteractor, private readonly EntityIdParser $entityIdParser, ) { }
15,498
2d9ff50c0543fc082c1bd9b6fd32c2ce
swh:1:cnt:6674ae4fdd88d2e111b09f01fc3e550960033442;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=23-52/
963ad209b8f7b2e391a0982113473c8881a680fb
ArticlePlaceholder
deployed
includes/TermSearchApiInteractor.php
TermSearchApiInteractor::searchForEntities( string $text, string $languageCode, string $entityType, array $termTypes )
function
/** @inheritDoc */ public function searchForEntities( string $text, string $languageCode, string $entityType, array $termTypes ): array { $params = [ 'action' => 'wbsearchentities', 'language' => $languageCode, 'strictlanguage' => 1, 'search' => $text, 'format' => 'json', 'type' => $entity...
15,499
e3d6d4ab95ffe9063da2d522405462fc
swh:1:cnt:6674ae4fdd88d2e111b09f01fc3e550960033442;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/ArticlePlaceholder.git;lines=54-69/
963ad209b8f7b2e391a0982113473c8881a680fb
ArticlePlaceholder
deployed
includes/TermSearchApiInteractor.php
TermSearchApiInteractor::parseDatum( array $datum, string $languageCode )
function
private function parseDatum( array $datum, string $languageCode ): ?TermSearchResult { if ( !isset( $datum['title'] ) || !isset( $datum['match']['text'] ) || !isset( $datum['match']['type'] ) ) { return null; } return new TermSearchResult( new Term( $languageCode, $datum['match']['text'] ), $dat...