Skip to content

Commit

Permalink
Merge pull request #60 from DevKor-github/54-change-preparation-order…
Browse files Browse the repository at this point in the history
…-to-linked-list

feat: change preparation order to linked list
  • Loading branch information
jjoonleo authored Dec 1, 2024
2 parents 3fc21bb + 717b900 commit 58061f2
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 82 deletions.
22 changes: 1 addition & 21 deletions lib/data/daos/preparation_schedule_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,10 @@ class PreparationScheduleDao extends DatabaseAccessor<AppDatabase>
id: preparationSchedule.id,
preparationName: preparationSchedule.preparationName,
preparationTime: preparationSchedule.preparationTime,
order: preparationSchedule.order,
nextPreparationId: preparationSchedule.nextPreparationId,
);
}).toList();

// await Future.forEach(
// query,
// (preparationSchedule) async {
// final schedule = await (select(db.schedules)
// ..where((tbl) => tbl.id.equals(preparationSchedule.scheduleId)))
// .getSingle();
// final user = await (select(db.users)
// ..where((tbl) => tbl.id.equals(schedule.userId)))
// .getSingle();
// final place = await (select(db.places)
// ..where((tbl) => tbl.id.equals(schedule.placeId)))
// .getSingle();

// preparationScheduleList.add(
// PreparationEntity.fromModel(
// preparationSchedule, schedule, user, place),
// );
// },
// );

return [PreparationEntity(preparationStepList: stepEntities)];
}
}
2 changes: 1 addition & 1 deletion lib/data/daos/preparation_user_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PreparationUserDao extends DatabaseAccessor<AppDatabase>
id: preparationUser.id,
preparationName: preparationUser.preparationName,
preparationTime: preparationUser.preparationTime,
order: preparationUser.order,
nextPreparationId: preparationUser.nextPreparationId,
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/data/tables/preparation_schedule_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class PreparationSchedules extends Table {
TextColumn get scheduleId => text().references(Schedules, #id)();
TextColumn get preparationName => text().withLength(min: 1, max: 30)();
IntColumn get preparationTime => integer()();
IntColumn get order => integer()();
TextColumn get nextPreparationId =>
text().nullable().references(PreparationSchedules, #id)();

@override
Set<Column> get primaryKey => {id};
Expand Down
3 changes: 2 additions & 1 deletion lib/data/tables/preparation_user_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class PreparationUsers extends Table {
TextColumn get userId => text().references(Users, #id)();
TextColumn get preparationName => text().withLength(min: 1, max: 30)();
IntColumn get preparationTime => integer()();
IntColumn get order => integer()();
TextColumn get nextPreparationId =>
text().nullable().references(PreparationUsers, #id)();

@override
Set<Column> get primaryKey => {id};
Expand Down
10 changes: 5 additions & 5 deletions lib/domain/entities/preparation_step_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class PreparationStepEntity {
final String id;
final String preparationName;
final int preparationTime;
final int order;
final String? nextPreparationId;

PreparationStepEntity({
required this.id,
required this.preparationName,
required this.preparationTime,
required this.order,
required this.nextPreparationId,
});

PreparationUser toPreparationUserModel(String userId) {
Expand All @@ -19,7 +19,7 @@ class PreparationStepEntity {
userId: userId,
preparationName: preparationName,
preparationTime: preparationTime,
order: order,
nextPreparationId: nextPreparationId,
);
}

Expand All @@ -29,12 +29,12 @@ class PreparationStepEntity {
scheduleId: scheduleId,
preparationName: preparationName,
preparationTime: preparationTime,
order: order,
nextPreparationId: nextPreparationId,
);
}

@override
String toString() {
return 'PreparationStepEntity(id: $id, preparationName: $preparationName, preparationTime: $preparationTime, order: $order)';
return 'PreparationStepEntity(id: $id, preparationName: $preparationName, preparationTime: $preparationTime, nextPreparationId: $nextPreparationId)';
}
}
48 changes: 24 additions & 24 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834
sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab"
url: "https://pub.dev"
source: hosted
version: "72.0.0"
version: "76.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.2"
version: "0.3.3"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139
sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e"
url: "https://pub.dev"
source: hosted
version: "6.7.0"
version: "6.11.0"
analyzer_plugin:
dependency: transitive
description:
Expand Down Expand Up @@ -194,10 +194,10 @@ packages:
dependency: "direct main"
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.19.0"
commitlint_cli:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -258,10 +258,10 @@ packages:
dependency: transitive
description:
name: custom_lint_visitor
sha256: "8aeb3b6ae2bb765e7716b93d1d10e8356d04e0ff6d7592de6ee04e0dd7d6587d"
sha256: bfe9b7a09c4775a587b58d10ebb871d4fe618237639b1e84d5ec62d7dfef25f9
url: "https://pub.dev"
source: hosted
version: "1.0.0+6.7.0"
version: "1.0.0+6.11.0"
dart_style:
dependency: transitive
description:
Expand Down Expand Up @@ -484,18 +484,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
url: "https://pub.dev"
source: hosted
version: "10.0.5"
version: "10.0.8"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
url: "https://pub.dev"
source: hosted
version: "3.0.5"
version: "3.0.9"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -524,10 +524,10 @@ packages:
dependency: transitive
description:
name: macros
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
url: "https://pub.dev"
source: hosted
version: "0.1.2-main.4"
version: "0.1.3-main.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -764,7 +764,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
version: "0.0.0"
source_gen:
dependency: transitive
description:
Expand Down Expand Up @@ -817,10 +817,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
version: "1.12.0"
state_notifier:
dependency: transitive
description:
Expand Down Expand Up @@ -849,10 +849,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.0"
term_glyph:
dependency: transitive
description:
Expand All @@ -865,10 +865,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.7.3"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -937,10 +937,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
source: hosted
version: "14.2.5"
version: "14.3.0"
watcher:
dependency: transitive
description:
Expand Down
30 changes: 23 additions & 7 deletions test/data/repositories/preparation_repository_impl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,66 @@ void main() {
final preparationStepEntityId = uuid.v7();
final userEntityId = uuid.v7();

// 첫 번째 단계: 리스트의 각 항목을 생성
final tPreparationStepList = [
PreparationStepEntity(
id: uuid.v7(),
preparationName: 'Meeting A Friend',
preparationTime: 30,
order: 1,
nextPreparationId: null, // 이후에 설정
),
PreparationStepEntity(
id: uuid.v7(),
preparationName: 'Museum Tour',
preparationTime: 40,
order: 2,
nextPreparationId: null, // 이후에 설정
),
];

// 두 번째 단계: 각 항목의 nextPreparationId 설정
tPreparationStepList[0] = PreparationStepEntity(
id: tPreparationStepList[0].id,
preparationName: tPreparationStepList[0].preparationName,
preparationTime: tPreparationStepList[0].preparationTime,
nextPreparationId: tPreparationStepList[1].id,
);

final tLocalPreparationStepList = [
PreparationStepEntity(
id: uuid.v7(),
preparationName: 'Meeting A Friend Local',
preparationTime: 10,
order: 1,
nextPreparationId: null, // 이후에 설정
),
PreparationStepEntity(
id: uuid.v7(),
preparationName: 'Museum Tour Local',
preparationTime: 30,
order: 2,
nextPreparationId: null, // 이후에 설정
),
];

// 두 번째 단계: 각 항목의 nextPreparationId 설정
tLocalPreparationStepList[0] = PreparationStepEntity(
id: tLocalPreparationStepList[0].id,
preparationName: tLocalPreparationStepList[0].preparationName,
preparationTime: tLocalPreparationStepList[0].preparationTime,
nextPreparationId: tLocalPreparationStepList[1].id,
);

final tPreparationStep = PreparationStepEntity(
id: uuid.v7(),
preparationName: 'Dress Up',
preparationTime: 10,
order: 1,
nextPreparationId: null, // 단일 항목이므로 다음 단계 없음
);

final tLocalPreparationStep = PreparationStepEntity(
id: uuid.v7(),
preparationName: 'Dress Up Local',
preparationTime: 15,
order: 1,
nextPreparationId: null, // 단일 항목이므로 다음 단계 없음
);

// final tPreparationEntity =
// PreparationEntity(preparationStepList: tPreparationStepList);

Expand Down
Loading

0 comments on commit 58061f2

Please sign in to comment.