Created
February 16, 2023 23:35
-
-
Save hpr/081b4c9946d255e5b5056855b218da64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const names = ['Amy Begley', 'Chris Lotsbom', 'Erik Kynard', 'Keturah Orji', 'Paul Swangard']; | |
const evts = [ | |
'Men 60', | |
'Men 60h', | |
'Men 400', | |
'Men 800', | |
'Men 1500', | |
'Men 3000', | |
'Women 60', | |
'Women 60h', | |
'Women 400', | |
'Women 800', | |
'Women 1500', | |
'Women 3000', | |
// 'Women 3000RW', | |
// 'Men 3000RW', | |
// 'Women PENT', | |
// 'Men HEP', | |
// 'Women SP', | |
// 'Men SP', | |
// 'Men PV', | |
// 'Men HJ', | |
// 'Men TJ', | |
// 'Women WT', | |
// 'Women PV', | |
// 'Women TJ', | |
// 'Women LJ', | |
// 'Women HJ', | |
// 'Men LJ', | |
// 'Men WT', | |
]; | |
for (const name of names) { | |
const { results } = await ( | |
await fetch('https://wabi-us-central-a-primary-api.analysis.windows.net/public/reports/querydata?synchronous=true', { | |
headers: { | |
ActivityId: '64aaf5ff-ff72-44d1-b6ae-dea784804560', | |
RequestId: '8796f7a4-4949-552a-3a86-911f370ca69d', | |
'X-PowerBI-ResourceKey': '8afdfa88-f6b4-4ca9-b2ff-f51c2453c4c9', | |
}, | |
body: JSON.stringify({ | |
cancelQueries: [], | |
modelId: 4815195, | |
queries: [ | |
{ | |
ApplicationContext: { | |
DatasetId: '0e308fc7-1784-42f3-a873-01a5ecfbcc51', | |
Sources: [ | |
{ | |
ReportId: 'f0c29693-a4d9-483b-8104-6503407a5b3b', | |
VisualId: '6c397c9dba9bcc388ac4', | |
}, | |
], | |
}, | |
Query: { | |
Commands: [ | |
{ | |
SemanticQueryDataShapeCommand: { | |
Binding: { | |
DataReduction: { | |
DataVolume: 3, | |
Primary: { | |
Window: { | |
Count: 500, | |
}, | |
}, | |
}, | |
Primary: { | |
Groupings: [ | |
{ | |
Projections: [0, 1, 2, 3, 4], | |
Subtotal: 1, | |
}, | |
], | |
}, | |
Version: 1, | |
}, | |
ExecutionMetricsKind: 1, | |
Query: { | |
From: [ | |
{ | |
Entity: 'Event Scores (2)', | |
Name: 'e1', | |
Type: 0, | |
}, | |
{ | |
Entity: 'Event Scores Pie Chart (2)', | |
Name: 'e11', | |
Type: 0, | |
}, | |
], | |
Select: [ | |
{ | |
Column: { | |
Expression: { | |
SourceRef: { | |
Source: 'e1', | |
}, | |
}, | |
Property: 'Athlete', | |
}, | |
Name: 'Event Scores (2).Athlete', | |
}, | |
{ | |
Aggregation: { | |
Expression: { | |
Column: { | |
Expression: { | |
SourceRef: { | |
Source: 'e1', | |
}, | |
}, | |
Property: 'Confidence', | |
}, | |
}, | |
Function: 0, | |
}, | |
Name: 'Sum(Event Scores (2).Confidence)', | |
}, | |
{ | |
Aggregation: { | |
Expression: { | |
Column: { | |
Expression: { | |
SourceRef: { | |
Source: 'e1', | |
}, | |
}, | |
Property: 'ConfidenceScore', | |
}, | |
}, | |
Function: 0, | |
}, | |
Name: 'Sum(Event Scores (2).ConfidenceScore)', | |
}, | |
{ | |
Column: { | |
Expression: { | |
SourceRef: { | |
Source: 'e1', | |
}, | |
}, | |
Property: 'Event', | |
}, | |
Name: 'Event Scores (2).Event', | |
}, | |
{ | |
Column: { | |
Expression: { | |
SourceRef: { | |
Source: 'e1', | |
}, | |
}, | |
Property: 'Name', | |
}, | |
Name: 'Event Scores (2).Name', | |
}, | |
], | |
Version: 2, | |
Where: [ | |
{ | |
Condition: { | |
In: { | |
Expressions: [ | |
{ | |
Column: { | |
Expression: { | |
SourceRef: { | |
Source: 'e1', | |
}, | |
}, | |
Property: 'Name', | |
}, | |
}, | |
], | |
Values: [ | |
[ | |
{ | |
Literal: { | |
Value: `'${name}'`, | |
}, | |
}, | |
], | |
], | |
}, | |
}, | |
}, | |
{ | |
Condition: { | |
In: { | |
Expressions: [ | |
{ | |
Column: { | |
Expression: { | |
SourceRef: { | |
Source: 'e11', | |
}, | |
}, | |
Property: 'Event', | |
}, | |
}, | |
], | |
Values: [ | |
[ | |
{ | |
Literal: { | |
Value: "'Women 60'", | |
}, | |
}, | |
], | |
], | |
}, | |
}, | |
}, | |
], | |
}, | |
}, | |
}, | |
], | |
}, | |
QueryId: '3d9c6a07-e21c-5912-ebc5-86ab9bad395b', | |
}, | |
], | |
version: '1.0.0', | |
}), | |
method: 'POST', | |
}) | |
).json(); | |
const { ValueDicts, PH } = results[0].result.data.dsr.DS[0]; | |
const meta = PH[1].DM1; | |
console.log(`${name}:`); | |
console.log( | |
ValueDicts.D1.map((evt, i) => [ | |
evt, | |
ValueDicts.D0[meta[i].R === 21 ? meta[i].C[0] - meta.slice(0, i + 1).filter((m) => m.R === 21).length : meta[i].C[0]], | |
meta[i].C.findLast((v) => v), | |
]) | |
.filter(([evt]) => evts.includes(evt)) | |
.sort((a, b) => evts.indexOf(a[0]) - evts.indexOf(b[0])) | |
.map(([evt, name, conf]) => `- ${evt}: ${name} (${Math.round((conf / 28) * 100)}% confident)`) | |
.join('\n') | |
); | |
console.log(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment