Talk:2024 World Athletics Indoor Tour

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Script to generate meetings table[edit]

This is the script I used to generate the meetings table (note that the API key is public):

const meets = await (await fetch("https://wpgiegzkbrhj5mlsdxnipboepm.appsync-api.eu-west-1.amazonaws.com/graphql", {
    "credentials": "omit",
    "headers": {
        "x-api-key": "da2-juounigq4vhkvg5ac47mezxqge",
    },
    "body": JSON.stringify({
	"operationName": "getMinisiteCalendarEvents",
	"query": `query getMinisiteCalendarEvents($competitionGroupId: Int, $competitionSubgroupId: Int, $season: String) {
  getMinisiteCalendarEvents(competitionGroupId: $competitionGroupId, competitionSubgroupId: $competitionSubgroupId, season: $season) {
    options {
      seasons {
        id
        name
        __typename
      }
      competitionSubgroups {
        id
        name
        count
        __typename
      }
      __typename
    }
    parameters {
      season
      competitionGroupId
      competitionSubgroupId
      __typename
    }
    results {
      id
      iaafId
      hasResults
      hasStartlist
      hasApiResults
      disciplines
      rankingCategory
      competitionSubgroup
      undeterminedCompetitionPeriod {
        status
        label
        remark
        __typename
      }
      name
      venue
      country
      startDate
      endDate
      dateRange
      __typename
    }
    __typename
  }
}`,
	"variables": {
		"competitionGroupId": 3677,
		"competitionSubgroupId": 0,
		"season": "2023/24"
	}
    }),
    "method": "POST",
})).json();
console.log(['Gold', 'Silver', 'Bronze', 'Challenger'].map(tier => {
  const mtgs = meets.data.getMinisiteCalendarEvents.results.filter(m => m.competitionSubgroup === tier);
  return `| colspan="4" align="center" bgcolor="${tier === 'Challenger' ? 'white' : tier.toLowerCase()}" | '''${tier} Level Meetings''' (${mtgs.length})<ref>{{cite web |title=World Athletics Indoor Tour ${tier} {{!}} World Athletics |url=https://worldathletics.org/competitions/world-athletics-indoor-tour/calendar-results?season=2023%2F24&competitionSubgroupId=${{Gold:3887,Silver:3889,Bronze:3888,Challenger:4050}[tier]} |website=worldathletics.org |access-date=25 October 2023}}</ref>\n|-\n` + mtgs.map(m => {
  const words = m.name.split(' ').filter((w, i) => {
    if (+w === new Date(m.startDate).getFullYear()) return false;
    if (i === 0 && w.match(/^[0-9]+(st|nd|rd|th)$/)) return false;
    return true;
  });
  if (words.join(' ') === 'Meeting de Paris') words.push('Indoor');
  const name = words.join(' ');
  return `| {{dts|abbr=on|${m.startDate}|format=dm}} || ${['Gold', 'Silver'].includes(tier) ? `[[${name}]]` : name} || ${m.venue.split(', ').slice(1).join(', ')} || {{${m.country}}}`
}).join('\n|-\n')
}).join('\n|-\n'));

--Habst (talk) 19:18, 25 October 2023 (UTC)[reply]