reunion_get_legislative_2022_round1
Retrieve per-polling-station results of the June 12, 2022 legislative elections first round for La Réunion, including candidate votes, voter turnout, and abstentions. Filter by commune, circonscription, or polling station code.
Instructions
Per polling-station (bureau de vote) results of the June 12, 2022 legislative elections, 1st round, for La Réunion (7 circonscriptions). Each row is one candidate at one polling station, with: commune, INSEE code, circonscription, polling station code/name, registered voters (inscrits), abstentions, voters, blank votes, null votes, expressed votes, candidate panel number, last name, first name, sex, political nuance, votes, vote share of expressed. Sorted by vote count descending. For round 2 use reunion_get_legislative_2022_round2.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commune | No | Commune name prefix match (e.g. "Saint-Denis") | |
| circumscription | No | Circonscription label prefix match (e.g. "1ère circonscription de La Réunion") | |
| polling_station | No | Exact polling-station code (bureau de vote), e.g. "0001" | |
| limit | No | Max rows to return (1-500, default 100) |
Implementation Reference
- src/modules/administration.ts:179-226 (registration)Tool registration for 'reunion_get_legislative_2022_round1' — defined via server.tool() within registerAdministrationTools()
server.tool( 'reunion_get_legislative_2022_round1', 'Per polling-station (bureau de vote) results of the June 12, 2022 legislative elections, 1st round, for La Réunion (7 circonscriptions). Each row is one candidate at one polling station, with: commune, INSEE code, circonscription, polling station code/name, registered voters (inscrits), abstentions, voters, blank votes, null votes, expressed votes, candidate panel number, last name, first name, sex, political nuance, votes, vote share of expressed. Sorted by vote count descending. For round 2 use reunion_get_legislative_2022_round2.', { commune: z.string().optional().describe('Commune name prefix match (e.g. "Saint-Denis")'), circumscription: z.string().optional().describe('Circonscription label prefix match (e.g. "1ère circonscription de La Réunion")'), polling_station: z.string().optional().describe('Exact polling-station code (bureau de vote), e.g. "0001"'), limit: z.number().int().min(1).max(500).default(100).describe('Max rows to return (1-500, default 100)'), }, async ({ commune, circumscription, polling_station, limit }) => { try { const data = await client.getRecords<RecordObject>(DATASET_LEGIS_2022_T1, { where: buildWhere([ commune ? `com_name LIKE ${quote(`${commune}%`)}` : undefined, circumscription ? `libelle_de_la_circonscription LIKE ${quote(`${circumscription}%`)}` : undefined, polling_station ? `code_du_b_vote = ${quote(polling_station)}` : undefined, ]), order_by: 'voix DESC', limit, }); return jsonResult({ total_rows: data.total_count, results: data.results.map((row) => ({ commune: pickString(row, ['com_name']), commune_code: pickString(row, ['com_code']), circumscription: pickString(row, ['libelle_de_la_circonscription']), polling_station_code: pickString(row, ['code_du_b_vote']), polling_station_name: pickString(row, ['lib_du_b_vote']), registered: pickNumber(row, ['inscrits']), abstentions: pickNumber(row, ['abstentions']), voters: pickNumber(row, ['votants']), blank: pickNumber(row, ['blancs']), null_votes: pickNumber(row, ['nuls']), expressed: pickNumber(row, ['exprimes']), panel_num: pickNumber(row, ['ndegpanneau']), candidate_last_name: pickString(row, ['nom']), candidate_first_name: pickString(row, ['prenom']), candidate_sex: pickString(row, ['sexe']), political_label: pickString(row, ['nuance']), votes: pickNumber(row, ['voix']), votes_pct_expressed: pickNumber(row, ['voix_exp']), })), }); } catch (error) { return errorResult(error instanceof Error ? error.message : 'Failed to fetch legislative results'); } } ); - src/modules/administration.ts:188-225 (handler)Handler function for reunion_get_legislative_2022_round1 — queries OpenDataSoft dataset DATASET_LEGIS_2022_T1 with filters on commune, circumscription, polling_station, returns mapped results
async ({ commune, circumscription, polling_station, limit }) => { try { const data = await client.getRecords<RecordObject>(DATASET_LEGIS_2022_T1, { where: buildWhere([ commune ? `com_name LIKE ${quote(`${commune}%`)}` : undefined, circumscription ? `libelle_de_la_circonscription LIKE ${quote(`${circumscription}%`)}` : undefined, polling_station ? `code_du_b_vote = ${quote(polling_station)}` : undefined, ]), order_by: 'voix DESC', limit, }); return jsonResult({ total_rows: data.total_count, results: data.results.map((row) => ({ commune: pickString(row, ['com_name']), commune_code: pickString(row, ['com_code']), circumscription: pickString(row, ['libelle_de_la_circonscription']), polling_station_code: pickString(row, ['code_du_b_vote']), polling_station_name: pickString(row, ['lib_du_b_vote']), registered: pickNumber(row, ['inscrits']), abstentions: pickNumber(row, ['abstentions']), voters: pickNumber(row, ['votants']), blank: pickNumber(row, ['blancs']), null_votes: pickNumber(row, ['nuls']), expressed: pickNumber(row, ['exprimes']), panel_num: pickNumber(row, ['ndegpanneau']), candidate_last_name: pickString(row, ['nom']), candidate_first_name: pickString(row, ['prenom']), candidate_sex: pickString(row, ['sexe']), political_label: pickString(row, ['nuance']), votes: pickNumber(row, ['voix']), votes_pct_expressed: pickNumber(row, ['voix_exp']), })), }); } catch (error) { return errorResult(error instanceof Error ? error.message : 'Failed to fetch legislative results'); } } - Zod schema for reunion_get_legislative_2022_round1 input parameters: commune, circumscription, polling_station (optional strings) and limit (int 1-500, default 100)
commune: z.string().optional().describe('Commune name prefix match (e.g. "Saint-Denis")'), circumscription: z.string().optional().describe('Circonscription label prefix match (e.g. "1ère circonscription de La Réunion")'), polling_station: z.string().optional().describe('Exact polling-station code (bureau de vote), e.g. "0001"'), limit: z.number().int().min(1).max(500).default(100).describe('Max rows to return (1-500, default 100)'), }, - src/modules/administration.ts:24-45 (helper)Helper mapBallotRow function shared across election datasets (legis R1, legis R2, presidential R1) that maps raw API records to the standard output format
function mapBallotRow(row: RecordObject) { return { commune: pickString(row, ['com_name']), commune_code: pickString(row, ['com_code']), circumscription: pickString(row, ['libelle_de_la_circonscription']), polling_station_code: pickString(row, ['code_du_b_vote']), polling_station_name: pickString(row, ['lib_du_b_vote']), registered: pickNumber(row, ['inscrits']), abstentions: pickNumber(row, ['abstentions']), voters: pickNumber(row, ['votants']), blank: pickNumber(row, ['blancs']), null_votes: pickNumber(row, ['nuls']), expressed: pickNumber(row, ['exprimes']), panel_num: pickNumber(row, ['ndegpanneau']), candidate_last_name: pickString(row, ['nom']), candidate_first_name: pickString(row, ['prenom']), candidate_sex: pickString(row, ['sexe']), political_label: pickString(row, ['nuance']), votes: pickNumber(row, ['voix']), votes_pct_expressed: pickNumber(row, ['voix_exp']), }; } - src/modules/administration.ts:12-13 (helper)Dataset constant DATASET_LEGIS_2022_T1 pointing to the OpenDataSoft dataset for legislative 2022 round 1 results
const DATASET_LEGIS_2022_T1 = 'resultats-des-elections-legislatives-2022-1er-tour-par-bureau-de-vote-a-la-reuni';