Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration_test/helpers/screenshot_test_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class ScreenshotTestDataSeeder {
exitTime: Value(
diveTimestamp + durationMs,
), // exit = entry + duration
duration: Value(durationSeconds * 60), // duration in seconds
bottomTime: Value(durationSeconds * 60), // duration in seconds
maxDepth: Value(maxDepth),
avgDepth: Value(avgDepth),
waterTemp: Value(waterTemp),
Expand Down
6 changes: 3 additions & 3 deletions integration_test/helpers/uddf_screenshot_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ class UddfScreenshotImporter {
dateTime: dateTime,
entryTime: entryTime,
exitTime: exitTime,
duration: diveData['duration'] as Duration?,
bottomTime: diveData['duration'] as Duration?,
runtime: runtime,
maxDepth: diveData['maxDepth'] as double?,
avgDepth: diveData['avgDepth'] as double?,
Expand Down Expand Up @@ -695,10 +695,10 @@ class UddfScreenshotImporter {
);

// Auto-calculate bottom time from profile if not set and profile exists
if (dive.duration == null && dive.profile.isNotEmpty) {
if (dive.bottomTime == null && dive.profile.isNotEmpty) {
final calculatedDuration = dive.calculateBottomTimeFromProfile();
if (calculatedDuration != null) {
dive = dive.copyWith(duration: calculatedDuration);
dive = dive.copyWith(bottomTime: calculatedDuration);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/core/constants/card_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ double? getCardColorValue(DiveSummary dive, CardColorAttribute attribute) {
return switch (attribute) {
CardColorAttribute.none => null,
CardColorAttribute.depth => dive.maxDepth,
CardColorAttribute.duration => dive.duration?.inMinutes.toDouble(),
CardColorAttribute.duration => dive.bottomTime?.inMinutes.toDouble(),
CardColorAttribute.temperature => dive.waterTemp,
};
}
Expand All @@ -76,7 +76,7 @@ double? getCardColorValueFromDive(Dive dive, CardColorAttribute attribute) {
return switch (attribute) {
CardColorAttribute.none => null,
CardColorAttribute.depth => dive.maxDepth,
CardColorAttribute.duration => dive.duration?.inMinutes.toDouble(),
CardColorAttribute.duration => dive.bottomTime?.inMinutes.toDouble(),
CardColorAttribute.temperature => dive.waterTemp,
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/constants/sort_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum DiveSortField {
date('Date', Icons.calendar_today),
site('Site', Icons.place),
depth('Max Depth', Icons.vertical_align_bottom),
duration('Duration', Icons.timer),
bottomTime('Bottom Time', Icons.timer),
rating('Rating', Icons.star),
diveNumber('Dive Number', Icons.tag);

Expand Down
9 changes: 7 additions & 2 deletions lib/core/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Dives extends Table {
integer().nullable()(); // Unix timestamp - when diver entered water
IntColumn get exitTime =>
integer().nullable()(); // Unix timestamp - when diver exited water
IntColumn get duration => integer().nullable()(); // seconds (bottom time)
IntColumn get bottomTime => integer().nullable()(); // seconds (bottom time)
IntColumn get runtime => integer().nullable()(); // seconds (total runtime)
RealColumn get maxDepth => real().nullable()();
RealColumn get avgDepth => real().nullable()();
Expand Down Expand Up @@ -1238,7 +1238,7 @@ class AppDatabase extends _$AppDatabase {

/// The current schema version as a static constant so that pre-open checks
/// (e.g. version-mismatch guard) can reference it without an instance.
static const int currentSchemaVersion = 55;
static const int currentSchemaVersion = 56;

@override
int get schemaVersion => currentSchemaVersion;
Expand Down Expand Up @@ -2470,6 +2470,11 @@ class AppDatabase extends _$AppDatabase {
'ALTER TABLE diver_settings ADD COLUMN show_data_source_badges INTEGER NOT NULL DEFAULT 1',
);
}
if (from < 56) {
await m.database.customStatement(
'ALTER TABLE dives RENAME COLUMN duration TO bottom_time',
);
}
},
beforeOpen: (details) async {
// Enable foreign keys
Expand Down
2 changes: 1 addition & 1 deletion lib/core/services/export/csv/csv_export_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class CsvExportService {
dive.site?.locationString ?? '',
dive.maxDepth?.toStringAsFixed(1) ?? '',
dive.avgDepth?.toStringAsFixed(1) ?? '',
dive.duration?.inMinutes ?? '',
dive.bottomTime?.inMinutes ?? '',
dive.runtime?.inMinutes ?? '',
dive.waterTemp?.toStringAsFixed(0) ?? '',
dive.airTemp?.toStringAsFixed(0) ?? '',
Expand Down
14 changes: 8 additions & 6 deletions lib/core/services/export/excel/excel_export_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class ExcelExportService {
dive.site?.locationString ?? '',
convertDepth(dive.maxDepth, depthUnit),
convertDepth(dive.avgDepth, depthUnit),
dive.duration?.inMinutes ?? '',
dive.bottomTime?.inMinutes ?? '',
dive.runtime?.inMinutes ?? '',
convertTemperature(dive.waterTemp, temperatureUnit),
convertTemperature(dive.airTemp, temperatureUnit),
Expand Down Expand Up @@ -437,7 +437,7 @@ class ExcelExportService {
if (dives.isNotEmpty) {
final totalMinutes = dives.fold<int>(
0,
(sum, d) => sum + (d.duration?.inMinutes ?? 0),
(sum, d) => sum + (d.bottomTime?.inMinutes ?? 0),
);
final hours = totalMinutes ~/ 60;
final mins = totalMinutes % 60;
Expand All @@ -458,10 +458,12 @@ class ExcelExportService {

final longestDive = dives.reduce(
(a, b) =>
(a.duration?.inMinutes ?? 0) > (b.duration?.inMinutes ?? 0) ? a : b,
(a.bottomTime?.inMinutes ?? 0) > (b.bottomTime?.inMinutes ?? 0)
? a
: b,
);
if (longestDive.duration != null) {
addStat('Longest Dive', '${longestDive.duration!.inMinutes} min');
if (longestDive.bottomTime != null) {
addStat('Longest Dive', '${longestDive.bottomTime!.inMinutes} min');
}

final divesWithTemp = dives.where((d) => d.waterTemp != null).toList();
Expand Down Expand Up @@ -496,7 +498,7 @@ class ExcelExportService {
final yearDives = divesByYear[year]!;
final yearMinutes = yearDives.fold<int>(
0,
(sum, d) => sum + (d.duration?.inMinutes ?? 0),
(sum, d) => sum + (d.bottomTime?.inMinutes ?? 0),
);
final yearHours = yearMinutes ~/ 60;
final yearMins = yearMinutes % 60;
Expand Down
4 changes: 2 additions & 2 deletions lib/core/services/export/kml/kml_export_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ class KmlExportService {
final depth = dive.maxDepth != null
? '${convertDepth(dive.maxDepth, depthUnit)}${depthUnit.symbol}'
: '?';
final duration = dive.duration != null
? '${dive.duration!.inMinutes}min'
final duration = dive.bottomTime != null
? '${dive.bottomTime!.inMinutes}min'
: '?';
buffer.writeln('<li><b>$dateStr</b> - $depth, $duration</li>');
}
Expand Down
6 changes: 3 additions & 3 deletions lib/core/services/export/pdf/pdf_course_export_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PdfCourseExportService {
// Calculate summary statistics
final totalBottomTime = trainingDives.fold<Duration>(
Duration.zero,
(sum, dive) => sum + (dive.duration ?? Duration.zero),
(sum, dive) => sum + (dive.bottomTime ?? Duration.zero),
);
final maxDepth = trainingDives.fold<double?>(
null,
Expand Down Expand Up @@ -298,9 +298,9 @@ class PdfCourseExportService {
'Max Depth',
'${dive.maxDepth!.toStringAsFixed(1)} m',
),
if (dive.duration != null) ...[
if (dive.bottomTime != null) ...[
pw.SizedBox(width: 20),
_buildInfoChip('Duration', '${dive.duration!.inMinutes} min'),
_buildInfoChip('Duration', '${dive.bottomTime!.inMinutes} min'),
],
if (dive.waterTemp != null) ...[
pw.SizedBox(width: 20),
Expand Down
10 changes: 5 additions & 5 deletions lib/core/services/export/pdf/pdf_export_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class PdfExportService {
pw.Text(
'Max Depth: ${dive.maxDepth!.toStringAsFixed(1)} m',
),
if (dive.duration != null)
pw.Text('Duration: ${dive.duration!.inMinutes} min'),
if (dive.bottomTime != null)
pw.Text('Duration: ${dive.bottomTime!.inMinutes} min'),
],
),
if (dive.waterTemp != null)
Expand Down Expand Up @@ -270,8 +270,8 @@ class PdfExportService {
// Summary page
if (dives.isNotEmpty) {
final totalDiveTime = dives
.where((d) => d.duration != null)
.fold<Duration>(Duration.zero, (sum, d) => sum + d.duration!);
.where((d) => d.bottomTime != null)
.fold<Duration>(Duration.zero, (sum, d) => sum + d.bottomTime!);
final maxDepth = dives
.where((d) => d.maxDepth != null)
.map((d) => d.maxDepth!)
Expand Down Expand Up @@ -414,7 +414,7 @@ class PdfExportService {
pw.SizedBox(width: 16),
_buildPdfInfoChip(
'Duration',
'${dive.duration?.inMinutes ?? '-'} min',
'${dive.bottomTime?.inMinutes ?? '-'} min',
),
pw.SizedBox(width: 16),
_buildPdfInfoChip(
Expand Down
6 changes: 3 additions & 3 deletions lib/core/services/export/uddf/uddf_export_builders.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class UddfExportBuilders {
);
}
} else {
final durationSecs = dive.duration?.inSeconds ?? 0;
final durationSecs = dive.bottomTime?.inSeconds ?? 0;
if (dive.maxDepth != null && durationSecs > 0) {
final descentTime = (durationSecs * 0.2).toInt();
builder.element(
Expand Down Expand Up @@ -548,10 +548,10 @@ class UddfExportBuilders {
if (dive.avgDepth != null) {
builder.element('averagedepth', nest: dive.avgDepth.toString());
}
if (dive.duration != null) {
if (dive.bottomTime != null) {
builder.element(
'diveduration',
nest: dive.duration!.inSeconds.toString(),
nest: dive.bottomTime!.inSeconds.toString(),
);
}
if (dive.runtime != null) {
Expand Down
6 changes: 3 additions & 3 deletions lib/core/services/export/uddf/uddf_export_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class UddfExportService {
} else {
// Generate basic profile from dive data
final durationSecs =
dive.duration?.inSeconds ?? 0;
dive.bottomTime?.inSeconds ?? 0;
if (dive.maxDepth != null && durationSecs > 0) {
// Descent to max depth (assume 1/5 of dive)
final descentTime = (durationSecs * 0.2)
Expand Down Expand Up @@ -373,10 +373,10 @@ class UddfExportService {
nest: dive.avgDepth.toString(),
);
}
if (dive.duration != null) {
if (dive.bottomTime != null) {
builder.element(
'diveduration',
nest: dive.duration!.inSeconds.toString(),
nest: dive.bottomTime!.inSeconds.toString(),
);
}
if (dive.waterTemp != null) {
Expand Down
4 changes: 2 additions & 2 deletions lib/core/services/pdf_templates/pdf_shared_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ class PdfSharedComponents {
}

final totalDiveTime = dives
.where((d) => d.duration != null)
.fold<Duration>(Duration.zero, (sum, d) => sum + d.duration!);
.where((d) => d.bottomTime != null)
.fold<Duration>(Duration.zero, (sum, d) => sum + d.bottomTime!);
final maxDepth = dives
.where((d) => d.maxDepth != null)
.map((d) => d.maxDepth!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class PdfTemplateDetailed extends PdfTemplateBuilder {
pw.SizedBox(width: 16),
PdfSharedComponents.buildInfoChip(
'Duration',
'${dive.duration?.inMinutes ?? '-'} min',
'${dive.bottomTime?.inMinutes ?? '-'} min',
),
pw.SizedBox(width: 16),
PdfSharedComponents.buildInfoChip(
Expand Down
6 changes: 3 additions & 3 deletions lib/core/services/pdf_templates/pdf_template_naui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class PdfTemplateNaui extends PdfTemplateBuilder {
}) {
// Calculate summary stats
final totalBottomTime = dives
.where((d) => d.duration != null)
.fold<Duration>(Duration.zero, (sum, d) => sum + d.duration!);
.where((d) => d.bottomTime != null)
.fold<Duration>(Duration.zero, (sum, d) => sum + d.bottomTime!);
final maxDepth = dives
.where((d) => d.maxDepth != null)
.map((d) => d.maxDepth!)
Expand Down Expand Up @@ -319,7 +319,7 @@ class PdfTemplateNaui extends PdfTemplateBuilder {
),
_buildNauiField(
'Time',
'${dive.duration?.inMinutes ?? '-'}min',
'${dive.bottomTime?.inMinutes ?? '-'}min',
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/core/services/pdf_templates/pdf_template_padi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class PdfTemplatePadi extends PdfTemplateBuilder {
),
_buildPadiField(
'Time',
'${dive.duration?.inMinutes ?? '-'}min',
'${dive.bottomTime?.inMinutes ?? '-'}min',
),
_buildPadiField(
'Temp',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ class PdfTemplateProfessional extends PdfTemplateBuilder {
),
_buildMetricRow(
'Duration',
dive.duration != null
? '${dive.duration!.inMinutes} min'
dive.bottomTime != null
? '${dive.bottomTime!.inMinutes} min'
: '-',
),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/core/services/pdf_templates/pdf_template_simple.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class PdfTemplateSimple extends PdfTemplateBuilder {
cellStyle,
),
_buildCell(
dive.duration != null
? '${dive.duration!.inMinutes}min'
dive.bottomTime != null
? '${dive.bottomTime!.inMinutes}min'
: '-',
cellStyle,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/core/services/sync/sync_data_serializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ class SyncDataSerializer {
'diveDateTime': r.diveDateTime,
'entryTime': r.entryTime,
'exitTime': r.exitTime,
'duration': r.duration,
'duration': r.bottomTime,
'runtime': r.runtime,
'maxDepth': r.maxDepth,
'avgDepth': r.avgDepth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,9 @@ class _BuddyDetailContent extends ConsumerWidget {
fontWeight: FontWeight.w500,
),
),
if (dive.duration != null)
if (dive.bottomTime != null)
Text(
'${dive.duration!.inMinutes}min',
'${dive.bottomTime!.inMinutes}min',
style: theme.textTheme.bodySmall
?.copyWith(
color: theme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ final personalRecordsProvider = FutureProvider<PersonalRecords>((ref) async {
Dive? longestDive;
int maxDuration = 0;
for (final dive in allDives) {
if (dive.duration != null && dive.duration!.inMinutes > maxDuration) {
maxDuration = dive.duration!.inMinutes;
if (dive.bottomTime != null && dive.bottomTime!.inMinutes > maxDuration) {
maxDuration = dive.bottomTime!.inMinutes;
longestDive = dive;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PersonalRecordsCard extends ConsumerWidget {
_RecordChip(
icon: Icons.timer,
label: context.l10n.dashboard_personalRecords_longest,
value: '${records.longestDive!.duration!.inMinutes}min',
value: '${records.longestDive!.bottomTime!.inMinutes}min',
subtitle: records.longestDive!.site?.name,
color: Colors.teal,
onTap: () => context.push('/dives/${records.longestDive!.id}'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class RecentDivesCard extends ConsumerWidget {
siteName: dive.site?.name,
siteLocation: dive.site?.locationString,
maxDepth: dive.maxDepth,
duration: dive.runtime ?? dive.duration,
duration: dive.runtime ?? dive.bottomTime,
waterTemp: dive.waterTemp,
rating: dive.rating,
isFavorite: dive.isFavorite,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ class UddfDuplicateChecker {
if (dive.exitTime != null && dive.entryTime != null) {
return dive.exitTime!.difference(dive.entryTime!).inSeconds;
}
if (dive.duration != null) return dive.duration!.inSeconds;
if (dive.bottomTime != null) return dive.bottomTime!.inSeconds;
return 0;
}

Expand Down
Loading
Loading