Merge branch 'claude/cool-swanson-81a747': expand species catalog to ~1200 edible species

# Conflicts:
#	apps/app_seeds/assets/catalog/species.json
#	apps/app_seeds/lib/data/species_repository.dart
This commit is contained in:
vjrj 2026-07-10 02:04:51 +02:00
commit 46ba85dad0
9 changed files with 68482 additions and 175 deletions

View file

@ -40,12 +40,14 @@ void main() {
'parseSpeciesCatalog reads scientific name, family and common names',
() {
const json = '''
{"version":1,"species":[
{"scientific_name":"Zea mays","family":"Poaceae","common":{"en":["Maize"],"es":["Maíz"]}}
{"version":3,"species":[
{"scientific_name":"Zea mays","family":"Poaceae","wikidata_qid":"Q11575","gbif_key":2703077,"common":{"en":["Maize"],"es":["Maíz"]}}
]}''';
final seeds = parseSpeciesCatalog(json);
expect(seeds.single.scientificName, 'Zea mays');
expect(seeds.single.family, 'Poaceae');
expect(seeds.single.wikidataQid, 'Q11575');
expect(seeds.single.gbifKey, 2703077);
expect(seeds.single.commonNames['es'], ['Maíz']);
},
);
@ -140,4 +142,86 @@ void main() {
await repo.seedBundled(_seeds);
expect(await repo.search(' '), isEmpty);
});
test('seedBundled stores wikidata id and gbif key', () async {
await repo.seedBundled(const [
SpeciesSeed(
scientificName: 'Solanum lycopersicum',
family: 'Solanaceae',
wikidataQid: 'Q13223',
gbifKey: 2930137,
commonNames: {
'en': ['Tomato'],
},
),
]);
final row = await db.select(db.species).getSingle();
expect(row.wikidataQid, 'Q13223');
expect(row.gbifKey, 2930137);
});
test('seedBundled backfills reference fields added later', () async {
// First seed lacks the enrichment fields (an older catalog).
await repo.seedBundled(const [
SpeciesSeed(
scientificName: 'Allium cepa',
commonNames: {
'en': ['Onion'],
},
),
]);
// A later catalog carries them; identity is preserved, fields are filled.
await repo.seedBundled(const [
SpeciesSeed(
scientificName: 'Allium cepa',
wikidataQid: 'Q23485',
gbifKey: 2857697,
viabilityYears: 1,
commonNames: {
'en': ['Onion'],
},
),
]);
final rows = await db.select(db.species).get();
expect(rows.length, 1);
expect(rows.single.wikidataQid, 'Q23485');
expect(rows.single.gbifKey, 2857697);
expect(rows.single.viabilityYears, 1);
});
test('search matches a non-Latin common name', () async {
await repo.seedBundled(const [
SpeciesSeed(
scientificName: 'Solanum lycopersicum',
commonNames: {
'ar': ['طماطم'],
'zh': ['番茄'],
},
),
]);
final ar = await repo.search('طماطم', languageCode: 'ar');
expect(ar.single.scientificName, 'Solanum lycopersicum');
expect(ar.single.commonName, 'طماطم');
final zh = await repo.search('番茄', languageCode: 'zh');
expect(zh.single.commonName, '番茄');
});
test('search respects the limit', () async {
final many = [
for (var i = 0; i < 20; i++)
SpeciesSeed(
scientificName: 'Genus species$i',
commonNames: const {
'en': ['Plant'],
},
),
];
await repo.seedBundled(many);
final results = await repo.search('Genus', limit: 5);
expect(results.length, 5);
});
}