Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/apursley2012/rescue-retriever/llms.txt

Use this file to discover all available pages before exploring further.

The exportCSV function in filterUtils.js serializes the current animal array to a CSV string, wraps it in a Blob with MIME type text/csv;charset=utf-8, creates an object URL via URL.createObjectURL, programmatically clicks a hidden anchor element with the download attribute set, then immediately revokes the object URL with URL.revokeObjectURL. No server interaction occurs — the entire file is generated and delivered in the browser.

Export Columns

Each exported row corresponds to one animal record. Two computed columns — rescue_programs and best_match_score — are appended beyond the raw dataset fields.
ColumnTypeDescription
animalIdstringUnique shelter identifier (e.g. "A706953")
namestringAnimal name — may be an empty string for unnamed animals
animalTypestringAlways "Dog" in this dataset
breedstringShelter breed assessment at intake
colorstringRecorded coat color
sexstringSex and reproductive status (e.g. "Intact Female", "Neutered Male")
age_weeksintegerAge in whole weeks — Math.round(ageWeeks) applied before writing
locationstringShelter intake location (e.g. "Thorndale, Texas, US")
latitudefloatIntake latitude formatted to 4 decimal places
longitudefloatIntake longitude formatted to 4 decimal places
rescue_programsstringSemicolon-separated qualifying program ids (e.g. "water; disaster"), or empty string if none
best_match_scoreintegerHighest matchScore across all three programs — range 22–100

Encoding Rules

  • All fields are double-quoted regardless of content type
  • Internal double-quote characters (") are escaped as two consecutive double-quotes ("") per RFC 4180
  • File encoding is UTF-8
  • Lines are separated by \n (Unix line endings)
  • The first row is always the header row with column names

Sample Output

"animalId","name","animalType","breed","color","sex","age_weeks","location","latitude","longitude","rescue_programs","best_match_score"
"A706953","Stella","Dog","Labrador Retriever Mix","Yellow","Intact Female","30","Thorndale, Texas, US","30.2672","-97.7431","water","100"
"A691584","Luke","Dog","Labrador Retriever Mix","Tan/White","Neutered Male","134","Granger, Texas, US","30.7177","-97.4428","","80"
"A717863","Lucky","Dog","German Shepherd Mix","Brown","Intact Male","157","Georgetown, Texas, US","30.6333","-97.6779","disaster","100"
In the first row, Stella scores 100 on Water Rescue: breed matches Labrador Retriever Mix (+50), sex matches Intact Female (+25), and age of 30 weeks falls within the 26–156 week range (+25). Luke shares the same breed (contributing +50) but is a Neutered Male — Water Rescue requires Intact Female — so sex does not match (+5). His age of 134 weeks falls within the Water Rescue range (+25), giving a best score of 80 (50 + 5 + 25). He does not fully qualify for any program, so rescue_programs is empty. Lucky is a German Shepherd Mix Intact Male aged 157 weeks: breed matches Disaster Rescue (+50), sex matches (+25), and his age of 157 weeks falls within Disaster Rescue’s 20–300 week range (+25), scoring 100 and qualifying for that program. His age exceeds Mountain Rescue’s maximum of 156 weeks, so he does not qualify there despite matching breed and sex.

Implementation

The complete exportCSV function as it appears in filterUtils.js:
filterUtils.js
function exportCSV(animals, filename = 'rescue-candidates.csv') {
  const headers = [
    'animalId', 'name', 'animalType', 'breed', 'color', 'sex',
    'age_weeks', 'location', 'latitude', 'longitude',
    'rescue_programs', 'best_match_score'
  ];
  const rows = animals.map(animal => [
    animal.animalId,
    animal.name,
    animal.animalType,
    animal.breed,
    animal.color,
    animal.sex,
    Math.round(animal.ageWeeks),
    animal.location,
    animal.latitude.toFixed(4),
    animal.longitude.toFixed(4),
    getQualifyingPrograms(animal).join('; '),
    getBestScore(animal).matchScore
  ]);
  const csv = [headers, ...rows]
    .map(row => row.map(field => `"${String(field).replace(/"/g, '""')}"`).join(','))
    .join('\n');
  const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
  const url = URL.createObjectURL(blob);
  const link = document.createElement('a');
  link.href = url;
  link.download = filename;
  link.click();
  URL.revokeObjectURL(url);
}
Key implementation details:
  • getQualifyingPrograms(animal) returns a string[] of program ids — these are joined with "; " (semicolon + space) to produce the rescue_programs field value
  • getBestScore(animal).matchScore is the raw integer from the highest-scoring ProgramScore object
  • latitude and longitude are formatted with .toFixed(4) — any floating-point imprecision in the source data is truncated to four decimal places
  • The Blob object URL is created immediately before the anchor click and revoked immediately after, minimizing memory retention
The export reflects the current application state at the moment the export button is clicked. If you have filtered the dashboard to Water Rescue candidates before exporting, only those animals appear in the CSV. Filtering first is the recommended workflow for producing program-specific candidate lists.

Export Feature Guide

How to use the Export button in the Rescue Retriever UI, including filter-before-export workflows.

Filter Utilities

Full reference for exportCSV and all other filterUtils.js functions.

Build docs developers (and LLMs) love