From 29e52ef7ef8456227e20e90ef14534c71c713cd8 Mon Sep 17 00:00:00 2001 From: Frederik St-Onge Date: Sun, 26 Jan 2025 10:04:26 -0500 Subject: [PATCH] Start migrating pacings repository --- drift_schemas/mon_pacing/drift_schema_v1.json | 1 + lib/bootstrapper.dart | 1 + lib/models/improvisation_model.dart | 19 ++++++++++ lib/models/pacing_model.dart | 20 ++++++++++ lib/repositories/pacings_repository.dart | 37 +++++++++++++++++-- 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 drift_schemas/mon_pacing/drift_schema_v1.json diff --git a/drift_schemas/mon_pacing/drift_schema_v1.json b/drift_schemas/mon_pacing/drift_schema_v1.json new file mode 100644 index 0000000..754a68c --- /dev/null +++ b/drift_schemas/mon_pacing/drift_schema_v1.json @@ -0,0 +1 @@ +{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"pacing_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"default_number_of_teams","getter_name":"defaultNumberOfTeams","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('2')","default_client_dart":null,"dsl_features":[]},{"name":"integration_id","getter_name":"integrationId","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_entity_id","getter_name":"integrationEntityId","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_additional_data","getter_name":"integrationAdditionalData","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[],"type":"table","data":{"name":"match_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"enable_statistics","getter_name":"enableStatistics","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"enable_statistics\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"enable_statistics\" IN (0, 1))"},"default_dart":"const CustomExpression('1')","default_client_dart":null,"dsl_features":[]},{"name":"enable_penalties_impact_points","getter_name":"enablePenaltiesImpactPoints","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"enable_penalties_impact_points\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"enable_penalties_impact_points\" IN (0, 1))"},"default_dart":"const CustomExpression('1')","default_client_dart":null,"dsl_features":[]},{"name":"penalties_impact_type","getter_name":"penaltiesImpactType","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumIndexConverter(PenaltiesImpactType.values)","dart_type_name":"PenaltiesImpactType"}},{"name":"penalties_required_to_impact_points","getter_name":"penaltiesRequiredToImpactPoints","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('3')","default_client_dart":null,"dsl_features":[]},{"name":"enable_match_expulsion","getter_name":"enableMatchExpulsion","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"enable_match_expulsion\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"enable_match_expulsion\" IN (0, 1))"},"default_dart":"const CustomExpression('1')","default_client_dart":null,"dsl_features":[]},{"name":"penalties_required_to_expel","getter_name":"penaltiesRequiredToExpel","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('3')","default_client_dart":null,"dsl_features":[]},{"name":"integration_id","getter_name":"integrationId","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_entity_id","getter_name":"integrationEntityId","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_additional_data","getter_name":"integrationAdditionalData","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_restrict_maximum_point_per_improvisation","getter_name":"integrationRestrictMaximumPointPerImprovisation","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_min_number_of_improvisations","getter_name":"integrationMinNumberOfImprovisations","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_max_number_of_improvisations","getter_name":"integrationMaxNumberOfImprovisations","moor_type":"int","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_penalty_types","getter_name":"integrationPenaltyTypes","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const StringListConverter()","dart_type_name":"List"}}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":2,"references":[],"type":"table","data":{"name":"team_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"color","getter_name":"color","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":3,"references":[0,1],"type":"table","data":{"name":"improvisation_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const EnumIndexConverter(ImprovisationType.values)","dart_type_name":"ImprovisationType"}},{"name":"category","getter_name":"category","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"theme","getter_name":"theme","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"durations_in_seconds","getter_name":"durationsInSeconds","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"IntListConverter()","dart_type_name":"List"}},{"name":"performers","getter_name":"performers","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"notes","getter_name":"notes","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"time_buffer_in_seconds","getter_name":"timeBufferInSeconds","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"huddle_timer_in_seconds","getter_name":"huddleTimerInSeconds","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_entity_id","getter_name":"integrationEntityId","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_additional_data","getter_name":"integrationAdditionalData","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"pacing","getter_name":"pacing","moor_type":"int","nullable":true,"customConstraints":null,"defaultConstraints":"REFERENCES pacing_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES pacing_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"match","getter_name":"match","moor_type":"int","nullable":true,"customConstraints":null,"defaultConstraints":"REFERENCES match_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES match_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":4,"references":[2],"type":"table","data":{"name":"performer_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"team","getter_name":"team","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES team_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES team_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"integration_entity_id","getter_name":"integrationEntityId","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"integration_additional_data","getter_name":"integrationAdditionalData","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":5,"references":[4,2,3],"type":"table","data":{"name":"penalty_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"major","getter_name":"major","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"major\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"major\" IN (0, 1))"},"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"performer","getter_name":"performer","moor_type":"int","nullable":true,"customConstraints":null,"defaultConstraints":"REFERENCES performer_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES performer_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"team","getter_name":"team","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES team_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES team_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"improvisation","getter_name":"improvisation","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES improvisation_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES improvisation_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":6,"references":[2,3],"type":"table","data":{"name":"point_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"value","getter_name":"value","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"team","getter_name":"team","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES team_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES team_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"improvisation","getter_name":"improvisation","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES improvisation_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES improvisation_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":7,"references":[4,2],"type":"table","data":{"name":"star_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"performer","getter_name":"performer","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES performer_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES performer_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"team","getter_name":"team","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES team_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES team_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":8,"references":[],"type":"table","data":{"name":"tag_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":9,"references":[8,0],"type":"table","data":{"name":"pacing_tag_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"tag","getter_name":"tag","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES tag_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES tag_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"pacing","getter_name":"pacing","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES pacing_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES pacing_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":10,"references":[8,1],"type":"table","data":{"name":"match_tag_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"tag","getter_name":"tag","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES tag_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES tag_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"match","getter_name":"match","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES match_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES match_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":11,"references":[8,2],"type":"table","data":{"name":"team_tag_entity","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"created_date","getter_name":"createdDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"modified_date","getter_name":"modifiedDate","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('1737858784')","default_client_dart":null,"dsl_features":[]},{"name":"tag","getter_name":"tag","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES tag_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES tag_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"team","getter_name":"team","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"REFERENCES team_entity (id)","dialectAwareDefaultConstraints":{"sqlite":"REFERENCES team_entity (id)"},"default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}}]} \ No newline at end of file diff --git a/lib/bootstrapper.dart b/lib/bootstrapper.dart index 6e70cfc..26a995e 100644 --- a/lib/bootstrapper.dart +++ b/lib/bootstrapper.dart @@ -83,6 +83,7 @@ class Bootstrapper extends StatelessWidget { create: (repositoryContext) => _createOrGetOverride( () => PacingsRepository( databaseRepository: repositoryContext.read(), + appDatabase: repositoryContext.read(), ), ), ), diff --git a/lib/models/improvisation_model.dart b/lib/models/improvisation_model.dart index f5a20f9..c2d8931 100644 --- a/lib/models/improvisation_model.dart +++ b/lib/models/improvisation_model.dart @@ -1,6 +1,7 @@ import 'package:dart_mappable/dart_mappable.dart'; import 'package:isar/isar.dart'; +import '../repositories/app_database.dart'; import 'improvisation_type.dart'; part 'improvisation_model.mapper.dart'; @@ -34,4 +35,22 @@ class ImprovisationModel with ImprovisationModelMappable { this.integrationEntityId, this.integrationAdditionalData, }); + + factory ImprovisationModel.fromEntity( + ImprovisationEntityData improvisation, + ) { + return ImprovisationModel( + id: improvisation.id, + type: improvisation.type, + category: improvisation.category, + theme: improvisation.theme, + durationsInSeconds: improvisation.durationsInSeconds, + performers: improvisation.performers, + notes: improvisation.notes, + timeBufferInSeconds: improvisation.timeBufferInSeconds, + huddleTimerInSeconds: improvisation.huddleTimerInSeconds, + integrationEntityId: improvisation.integrationEntityId, + integrationAdditionalData: improvisation.integrationAdditionalData, + ); + } } diff --git a/lib/models/pacing_model.dart b/lib/models/pacing_model.dart index d75a82f..a314078 100644 --- a/lib/models/pacing_model.dart +++ b/lib/models/pacing_model.dart @@ -3,6 +3,7 @@ import 'package:dart_mappable/dart_mappable.dart'; import 'package:isar/isar.dart'; +import '../repositories/app_database.dart'; import 'improvisation_model.dart'; import 'improvisation_type.dart'; @@ -42,4 +43,23 @@ class PacingModel with PacingModelMappable { List get categories => improvisations.where((e) => e.category.isNotEmpty).map((e) => e.category).toList(); List get themes => improvisations.where((e) => e.theme.isNotEmpty).map((e) => e.theme).toList(); + + factory PacingModel.fromEntity( + PacingEntityData pacing, + List improvisations, + List tags, + ) { + return PacingModel( + id: pacing.id, + name: pacing.name, + createdDate: pacing.createdDate, + modifiedDate: pacing.modifiedDate, + improvisations: improvisations.map((e) => ImprovisationModel.fromEntity(e)).toList(), + defaultNumberOfTeams: pacing.defaultNumberOfTeams, + tags: tags.map((e) => e.name).toList(), + integrationId: pacing.integrationId, + integrationEntityId: pacing.integrationEntityId, + integrationAdditionalData: pacing.integrationAdditionalData, + ); + } } diff --git a/lib/repositories/pacings_repository.dart b/lib/repositories/pacings_repository.dart index e655ed6..dd18056 100644 --- a/lib/repositories/pacings_repository.dart +++ b/lib/repositories/pacings_repository.dart @@ -2,13 +2,16 @@ import 'package:isar/isar.dart'; import '../extensions/iterable_extensions.dart'; import '../models/pacing_model.dart'; +import 'app_database.dart'; import 'legacy_database_repository.dart'; class PacingsRepository { final LegacyDatabaseRepository databaseRepository; + final AppDatabase appDatabase; const PacingsRepository({ required this.databaseRepository, + required this.appDatabase, }); Future add(PacingModel entity) async { @@ -32,13 +35,39 @@ class PacingsRepository { } Future get(int id) async { - final db = await databaseRepository.database; - return await db.pacingModels.getAsync(id); + final response = await appDatabase.managers.pacingEntity + .withReferences((p) => p(improvisationEntityRefs: true)) + .filter((p) => p.id.equals(id)) + .getSingleOrNull(); + + final pacing = response?.$1; + final improvisations = response?.$2.improvisationEntityRefs.prefetchedData; + + final pacingTags = await response?.$2.pacingTagEntityRefs.withReferences((p) => p(tag: true)).get(); + final tags = pacingTags?.map((t) => t.$2.tag.prefetchedData).selectMany((t) => t ?? []); + + if (pacing == null || improvisations == null || tags == null) return null; + return PacingModel.fromEntity(pacing, improvisations, tags.toList()); } Future> getList(int skip, int take) async { - final db = await databaseRepository.database; - return await db.pacingModels.where().sortByCreatedDateDesc().findAllAsync(offset: skip, limit: take); + final List pacings = []; + final response = await appDatabase.managers.pacingEntity + .withReferences((p) => p(improvisationEntityRefs: true)) + .orderBy((p) => p.createdDate.desc()) + .get(offset: skip, limit: take); + + for (final pacingResponse in response) { + final pacing = pacingResponse.$1; + final improvisations = pacingResponse.$2.improvisationEntityRefs.prefetchedData ?? []; + + final pacingTags = await pacingResponse.$2.pacingTagEntityRefs.withReferences((p) => p(tag: true)).get(); + final tags = pacingTags.map((t) => t.$2.tag.prefetchedData).selectMany((t) => t ?? []); + + pacings.add(PacingModel.fromEntity(pacing, improvisations, tags.toList())); + } + + return pacings; } Future> search(String search, List selectedTags) async {