Add datasource versions to database
All checks were successful
Build and test / build (push) Successful in 7m56s

This commit is contained in:
2026-04-13 21:00:39 +09:00
parent cbaa9ec6b3
commit d13138f8a5
6 changed files with 92 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:collection';
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:jadb/_data_ingestion/jmdict/objects.dart';
@@ -84,6 +85,21 @@ Future<void> seedJMDictData(List<Entry> entries, Database db) async {
print(' [JMdict] Batch 1 - Kanji and readings');
Batch b = db.batch();
if (Platform.environment['JMDICT_VERSION'] != null &&
Platform.environment['JMDICT_DATE'] != null &&
Platform.environment['JMDICT_HASH'] != null) {
b.insert(JMdictTableNames.version, {
'version': Platform.environment['JMDICT_VERSION']!,
'date': Platform.environment['JMDICT_DATE']!,
'hash': Platform.environment['JMDICT_HASH']!,
});
} else {
print(
'WARNING: JMDICT version information not found in environment variables. '
'This may cause issues with future updates.',
);
}
for (final e in entries) {
b.insert(JMdictTableNames.entry, e.sqlValue);

View File

@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:jadb/table_names/kanjidic.dart';
import 'package:sqflite_common/sqlite_api.dart';
@@ -5,6 +7,22 @@ import 'objects.dart';
Future<void> seedKANJIDICData(List<Character> characters, Database db) async {
final b = db.batch();
if (Platform.environment['KANJIDIC_VERSION'] != null &&
Platform.environment['KANJIDIC_DATE'] != null &&
Platform.environment['KANJIDIC_HASH'] != null) {
b.insert(KANJIDICTableNames.version, {
'version': Platform.environment['KANJIDIC_VERSION']!,
'date': Platform.environment['KANJIDIC_DATE']!,
'hash': Platform.environment['KANJIDIC_HASH']!,
});
} else {
print(
'WARNING: KANJIDIC version information not found in environment variables. '
'This may cause issues with future updates.',
);
}
for (final c in characters) {
// if (c.dictionaryReferences.any((e) =>
// c.dictionaryReferences
@@ -30,10 +48,7 @@ Future<void> seedKANJIDICData(List<Character> characters, Database db) async {
}
if (c.jlpt != null) {
b.insert(KANJIDICTableNames.jlpt, {
'kanji': c.literal,
'jlpt': c.jlpt!,
});
b.insert(KANJIDICTableNames.jlpt, {'kanji': c.literal, 'jlpt': c.jlpt!});
}
for (final n in c.radicalName) {

View File

@@ -1,9 +1,26 @@
import 'dart:io';
import 'package:jadb/table_names/radkfile.dart';
import 'package:sqflite_common/sqlite_api.dart';
Future<void> seedRADKFILEData(Iterable<String> blocks, Database db) async {
final b = db.batch();
if (Platform.environment['RADKFILE_VERSION'] != null &&
Platform.environment['RADKFILE_DATE'] != null &&
Platform.environment['RADKFILE_HASH'] != null) {
b.insert(RADKFILETableNames.version, {
'version': Platform.environment['RADKFILE_VERSION']!,
'date': Platform.environment['RADKFILE_DATE']!,
'hash': Platform.environment['RADKFILE_HASH']!,
});
} else {
print(
'WARNING: RADKFILE version information not found in environment variables. '
'This may cause issues with future updates.',
);
}
for (final block in blocks) {
final String radical = block[1];
final List<String> kanjiList =

View File

@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:jadb/table_names/tanos_jlpt.dart';
import 'package:sqflite_common/sqlite_api.dart';
@@ -7,6 +9,21 @@ Future<void> seedTanosJLPTData(
) async {
final Batch b = db.batch();
if (Platform.environment['TANOS_JLPT_VERSION'] != null &&
Platform.environment['TANOS_JLPT_DATE'] != null &&
Platform.environment['TANOS_JLPT_HASH'] != null) {
b.insert(TanosJLPTTableNames.version, {
'version': Platform.environment['TANOS_JLPT_VERSION']!,
'date': Platform.environment['TANOS_JLPT_DATE']!,
'hash': Platform.environment['TANOS_JLPT_HASH']!,
});
} else {
print(
'WARNING: Tanos JLPT version information not found in environment variables. '
'This may cause issues with future updates.',
);
}
for (final jlptLevel in resolvedEntries.entries) {
final level = jlptLevel.key;
final entryIds = jlptLevel.value;