2026-01-11 08:17:29 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
|
|
|
|
|
part 'sake_taste_stats.g.dart';
|
|
|
|
|
|
2026-01-29 15:54:22 +00:00
|
|
|
@HiveType(typeId: 21)
|
2026-01-11 08:17:29 +00:00
|
|
|
class SakeTasteStats extends HiveObject {
|
|
|
|
|
@HiveField(0)
|
|
|
|
|
final double aroma; // 香り
|
|
|
|
|
|
|
|
|
|
@HiveField(1)
|
2026-01-29 15:54:22 +00:00
|
|
|
final double bitterness; // キレ (苦味) - Old: richness
|
2026-01-11 08:17:29 +00:00
|
|
|
|
|
|
|
|
@HiveField(2)
|
|
|
|
|
final double sweetness; // 甘み
|
|
|
|
|
|
|
|
|
|
@HiveField(3)
|
2026-01-29 15:54:22 +00:00
|
|
|
final double acidity; // 酸味 - Old: alcoholFeeling
|
2026-01-11 08:17:29 +00:00
|
|
|
|
|
|
|
|
@HiveField(4)
|
2026-01-29 15:54:22 +00:00
|
|
|
final double body; // コク - Old: fruitiness
|
2026-01-11 08:17:29 +00:00
|
|
|
|
|
|
|
|
SakeTasteStats({
|
|
|
|
|
required this.aroma,
|
2026-01-29 15:54:22 +00:00
|
|
|
required this.bitterness,
|
2026-01-11 08:17:29 +00:00
|
|
|
required this.sweetness,
|
2026-01-29 15:54:22 +00:00
|
|
|
required this.acidity,
|
|
|
|
|
required this.body,
|
2026-01-11 08:17:29 +00:00
|
|
|
});
|
|
|
|
|
|
2026-01-29 15:54:22 +00:00
|
|
|
// Factory to convert from Map (Handles Schema Migration)
|
2026-01-11 08:17:29 +00:00
|
|
|
factory SakeTasteStats.fromMap(Map<String, int> map) {
|
|
|
|
|
return SakeTasteStats(
|
|
|
|
|
aroma: (map['aroma'] ?? 0).toDouble(),
|
|
|
|
|
sweetness: (map['sweetness'] ?? 0).toDouble(),
|
2026-01-29 15:54:22 +00:00
|
|
|
|
|
|
|
|
// Fallback Logic: New Key -> Old Key -> Default
|
|
|
|
|
// Gemini now returns 'acidity', 'bitterness', 'body'
|
|
|
|
|
acidity: (map['acidity'] ?? map['alcohol'] ?? map['alcoholFeeling'] ?? 0).toDouble(),
|
|
|
|
|
bitterness: (map['bitterness'] ?? map['richness'] ?? 0).toDouble(),
|
|
|
|
|
body: (map['body'] ?? map['fruitiness'] ?? 0).toDouble(),
|
2026-01-11 08:17:29 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|