Skip to content

Commit

Permalink
shift normal schedules to supabase
Browse files Browse the repository at this point in the history
implements sqflite caching for offline use.

(minor changes)
  • Loading branch information
opxdelwin committed Dec 1, 2024
1 parent d0fdb58 commit 21d42e3
Show file tree
Hide file tree
Showing 31 changed files with 1,874 additions and 218 deletions.
93 changes: 49 additions & 44 deletions client-app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,81 @@ PODS:
- connectivity_plus (0.0.1):
- Flutter
- FlutterMacOS
- Firebase/Analytics (10.22.0):
- Firebase/Analytics (10.25.0):
- Firebase/Core
- Firebase/Auth (10.22.0):
- Firebase/Auth (10.25.0):
- Firebase/CoreOnly
- FirebaseAuth (~> 10.22.0)
- Firebase/Core (10.22.0):
- FirebaseAuth (~> 10.25.0)
- Firebase/Core (10.25.0):
- Firebase/CoreOnly
- FirebaseAnalytics (~> 10.22.0)
- Firebase/CoreOnly (10.22.0):
- FirebaseCore (= 10.22.0)
- Firebase/Crashlytics (10.22.0):
- FirebaseAnalytics (~> 10.25.0)
- Firebase/CoreOnly (10.25.0):
- FirebaseCore (= 10.25.0)
- Firebase/Crashlytics (10.25.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 10.22.0)
- Firebase/RemoteConfig (10.22.0):
- FirebaseCrashlytics (~> 10.25.0)
- Firebase/RemoteConfig (10.25.0):
- Firebase/CoreOnly
- FirebaseRemoteConfig (~> 10.22.0)
- FirebaseRemoteConfig (~> 10.25.0)
- firebase_analytics (10.8.9):
- Firebase/Analytics (= 10.22.0)
- Firebase/Analytics (= 10.25.0)
- firebase_core
- Flutter
- firebase_auth (4.17.8):
- Firebase/Auth (= 10.22.0)
- Firebase/Auth (= 10.25.0)
- firebase_core
- Flutter
- firebase_core (2.27.0):
- Firebase/CoreOnly (= 10.22.0)
- firebase_core (2.32.0):
- Firebase/CoreOnly (= 10.25.0)
- Flutter
- firebase_crashlytics (3.4.18):
- Firebase/Crashlytics (= 10.22.0)
- Firebase/Crashlytics (= 10.25.0)
- firebase_core
- Flutter
- firebase_remote_config (4.3.17):
- Firebase/RemoteConfig (= 10.22.0)
- Firebase/RemoteConfig (= 10.25.0)
- firebase_core
- Flutter
- FirebaseABTesting (10.29.0):
- FirebaseCore (~> 10.0)
- FirebaseAnalytics (10.22.0):
- FirebaseAnalytics/AdIdSupport (= 10.22.0)
- FirebaseAnalytics (10.25.0):
- FirebaseAnalytics/AdIdSupport (= 10.25.0)
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- FirebaseAnalytics/AdIdSupport (10.22.0):
- FirebaseAnalytics/AdIdSupport (10.25.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleAppMeasurement (= 10.22.0)
- GoogleAppMeasurement (= 10.25.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- FirebaseAppCheckInterop (10.29.0)
- FirebaseAuth (10.22.0):
- FirebaseAuth (10.25.0):
- FirebaseAppCheckInterop (~> 10.17)
- FirebaseCore (~> 10.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/Environment (~> 7.8)
- GTMSessionFetcher/Core (< 4.0, >= 2.1)
- RecaptchaInterop (~> 100.0)
- FirebaseCore (10.22.0):
- FirebaseCore (10.25.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
- GoogleUtilities/Logger (~> 7.12)
- FirebaseCoreExtension (10.29.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreInternal (10.29.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseCrashlytics (10.22.0):
- FirebaseCrashlytics (10.25.0):
- FirebaseCore (~> 10.5)
- FirebaseInstallations (~> 10.0)
- FirebaseRemoteConfigInterop (~> 10.23)
- FirebaseSessions (~> 10.5)
- GoogleDataTransport (~> 9.2)
- GoogleUtilities/Environment (~> 7.8)
Expand All @@ -94,13 +95,15 @@ PODS:
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseRemoteConfig (10.22.0):
- FirebaseRemoteConfig (10.25.0):
- FirebaseABTesting (~> 10.0)
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- FirebaseRemoteConfigInterop (~> 10.23)
- FirebaseSharedSwift (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseRemoteConfigInterop (10.29.0)
- FirebaseSessions (10.29.0):
- FirebaseCore (~> 10.5)
- FirebaseCoreExtension (~> 10.0)
Expand All @@ -120,21 +123,21 @@ PODS:
- FlutterMacOS
- GoogleSignIn (~> 7.1)
- GTMSessionFetcher (>= 3.4.0)
- GoogleAppMeasurement (10.22.0):
- GoogleAppMeasurement/AdIdSupport (= 10.22.0)
- GoogleAppMeasurement (10.25.0):
- GoogleAppMeasurement/AdIdSupport (= 10.25.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- GoogleAppMeasurement/AdIdSupport (10.22.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.22.0)
- GoogleAppMeasurement/AdIdSupport (10.25.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.25.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- GoogleAppMeasurement/WithoutAdIdSupport (10.22.0):
- GoogleAppMeasurement/WithoutAdIdSupport (10.25.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
Expand Down Expand Up @@ -244,6 +247,7 @@ SPEC REPOS:
- FirebaseCrashlytics
- FirebaseInstallations
- FirebaseRemoteConfig
- FirebaseRemoteConfigInterop
- FirebaseSessions
- FirebaseSharedSwift
- GoogleAppMeasurement
Expand Down Expand Up @@ -296,36 +300,37 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
app_links: e7a6750a915a9e161c58d91bc610e8cd1d4d0ad0
AppAuth: 501c04eda8a8d11f179dbe8637b7a91bb7e5d2fa
connectivity_plus: ddd7f30999e1faaef5967c23d5b6d503d10434db
Firebase: 797fd7297b7e1be954432743a0b3f90038e45a71
firebase_analytics: b9ce200bfc2c54629076bb22d6a510f31c296ab8
firebase_auth: 4cf9d126dc9629a77dbcbd23723e903d8277ff5a
firebase_core: 100945864b4aedce3cfef0c62ab864858bf013cf
firebase_crashlytics: 2b9ca6246501a03427eb43280be7615027e32142
firebase_remote_config: 5ebb1bf2503404f6b24e64f117dc6c22c0498d4c
connectivity_plus: 4c41c08fc6d7c91f63bc7aec70ffe3730b04f563
Firebase: 0312a2352584f782ea56f66d91606891d4607f06
firebase_analytics: 7b4b7901be0b51530f3db7f1d4fcd7927502f800
firebase_auth: e6074b92cd18da0dce5a25a7645c27d0a5a7131c
firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197
firebase_crashlytics: bf3c9532d6a2fcae59f67995b6a1225a77265d91
firebase_remote_config: e60e480a8bc8e080f725e0019e5712d47aee2a60
FirebaseABTesting: d87f56707159bae64e269757a6e963d490f2eebe
FirebaseAnalytics: 8d0ff929c63b7f72260f332b86ccf569776b75d3
FirebaseAnalytics: ec00fe8b93b41dc6fe4a28784b8e51da0647a248
FirebaseAppCheckInterop: 6a1757cfd4067d8e00fccd14fcc1b8fd78cfac07
FirebaseAuth: bbe4c68f958504ba9e54aee181adbdf5b664fbc6
FirebaseCore: 0326ec9b05fbed8f8716cddbf0e36894a13837f7
FirebaseAuth: c0f93dcc570c9da2bffb576969d793e95c344fbb
FirebaseCore: 7ec4d0484817f12c3373955bc87762d96842d483
FirebaseCoreExtension: 705ca5b14bf71d2564a0ddc677df1fc86ffa600f
FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934
FirebaseCrashlytics: e568d68ce89117c80cddb04073ab9018725fbb8c
FirebaseCrashlytics: 4b96efb0ce73b38b2a85e8b8bd1bd8f63f09d015
FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd
FirebaseRemoteConfig: e1b992a94d3674dddbcaf5d0d31a0312156ceb1c
FirebaseRemoteConfig: 9f3935cefecd85d5b312192117f444957de24a75
FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
google_sign_in_ios: 07375bfbf2620bc93a602c0e27160d6afc6ead38
GoogleAppMeasurement: ccefe3eac9b0aa27f96066809fb1a7fe4b462626
GoogleAppMeasurement: 9abf64b682732fed36da827aa2a68f0221fd2356
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleSignIn: d4281ab6cf21542b1cfaff85c191f230b399d2db
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de
GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
Expand Down
20 changes: 18 additions & 2 deletions client-app/lib/backend/models/timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import 'package:plan_sync/backend/models/timetable_meta.dart';
import 'package:plan_sync/backend/models/timetable_schedule_entry.dart';
import 'dart:convert';

import 'package:plan_sync/backend/supabase_models/student_schedule.dart';
import 'package:plan_sync/util/extensions.dart';

class Timetable {
final TimetableMeta meta;
final Map<String, List<ScheduleEntry>> data;
Expand All @@ -13,13 +16,15 @@ class Timetable {
this.isFresh = true,
});

//TODO: (fixme) This should no longer be used.
// migrate after electives are migrated to supabase
factory Timetable.fromJson({
required Map<String, dynamic> json,
required Map json,
bool isFresh = true,
}) {
return Timetable(
isFresh: isFresh,
meta: TimetableMeta.fromJson(json['meta']),
meta: TimetableMeta(),
data: (json['data'] as Map<String, dynamic>).map(
(key, value) => MapEntry(
key,
Expand All @@ -31,6 +36,17 @@ class Timetable {
);
}

factory Timetable.fromStudentScheduleModel({
required List<StudentSchedule> scheduleList,
bool isFresh = true,
}) {
//TODO: Figure out a way to add existing
// metadata to the timetable, as supabase
// isn't configured with the metadata.

return scheduleList.toTimetable(isFresh: isFresh);
}

Map<String, dynamic> toJson() {
return {
'meta': meta.toJson(),
Expand Down
5 changes: 5 additions & 0 deletions client-app/lib/backend/models/timetable_schedule_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ class ScheduleEntry {
'time': time,
};
}

@override
String toString() {
return 'ScheduleEntry(subject: $subject, room: $room, time: $time)';
}
}
40 changes: 40 additions & 0 deletions client-app/lib/backend/supabase_models/branches.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Branches {
final int id;
final DateTime createdAt;
final String branchName;
final String program;
final String authority;

Branches({
required this.id,
required this.createdAt,
required this.branchName,
required this.program,
required this.authority,
});

factory Branches.fromJson(Map<String, dynamic> json) {
return Branches(
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
branchName: json['branch_name'],
program: json['program'],
authority: json['authority'],
);
}

Map<String, dynamic> toJson() {
return {
'id': id,
'created_at': createdAt.toIso8601String(),
'branch_name': branchName,
'program': program,
'authority': authority,
};
}

@override
String toString() {
return 'Branches{id: $id, createdAt: $createdAt, branchName: $branchName, program: $program, authority: $authority}';
}
}
41 changes: 41 additions & 0 deletions client-app/lib/backend/supabase_models/programs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Program {
final int? id;
final DateTime? createdAt;
final String name;
final String authority;

Program({
this.id,
this.createdAt,
required this.name,
this.authority = '',
});

// Convert a Program object into a Map (to insert into the database)
Map<String, dynamic> toJson() {
return {
'id': id,
'created_at': createdAt?.toIso8601String(),
'name': name,
'authority': authority,
};
}

// Convert a Map object (retrieved from the database) into a Program object
factory Program.fromJson(Map<String, dynamic> map) {
return Program(
id: map['id'] as int?,
createdAt: map['created_at'] != null
? DateTime.parse(map['created_at'] as String)
: null,
name: map['name'] as String,
authority: map['authority'] as String? ?? '',
);
}

// Override toString for easy debugging
@override
String toString() {
return 'Program(id: $id, createdAt: $createdAt, name: $name, authority: $authority)';
}
}
Loading

0 comments on commit 21d42e3

Please sign in to comment.