Skip to content

Commit

Permalink
Search Optimizations (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Jan 3, 2024
1 parent 6bdbbdd commit 68a552c
Show file tree
Hide file tree
Showing 46 changed files with 276 additions and 30,807 deletions.
Binary file removed assets/models/english_bert_30.tflite
Binary file not shown.
Binary file modified assets/videos/token-tutorial.mp4
Binary file not shown.
30 changes: 0 additions & 30 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,6 @@ PODS:
- sqflite (0.0.3):
- Flutter
- FMDB (>= 2.7.5)
- TensorFlowLiteC (2.12.0):
- TensorFlowLiteC/Core (= 2.12.0)
- TensorFlowLiteC/Core (2.12.0)
- TensorFlowLiteC/CoreML (2.12.0):
- TensorFlowLiteC/Core
- TensorFlowLiteC/Metal (2.12.0):
- TensorFlowLiteC/Core
- TensorFlowLiteSwift (2.12.0):
- TensorFlowLiteSwift/Core (= 2.12.0)
- TensorFlowLiteSwift/Core (2.12.0):
- TensorFlowLiteC (= 2.12.0)
- TensorFlowLiteSwift/CoreML (2.12.0):
- TensorFlowLiteC/CoreML (= 2.12.0)
- TensorFlowLiteSwift/Core (= 2.12.0)
- TensorFlowLiteSwift/Metal (2.12.0):
- TensorFlowLiteC/Metal (= 2.12.0)
- TensorFlowLiteSwift/Core (= 2.12.0)
- tflite_flutter (0.0.1):
- Flutter
- TensorFlowLiteSwift (= 2.12.0)
- TensorFlowLiteSwift/CoreML (= 2.12.0)
- TensorFlowLiteSwift/Metal (= 2.12.0)
- url_launcher_ios (0.0.1):
- Flutter
- video_player_avfoundation (0.0.1):
Expand All @@ -137,7 +115,6 @@ DEPENDENCIES:
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- tflite_flutter (from `.symlinks/plugins/tflite_flutter/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)

Expand All @@ -157,8 +134,6 @@ SPEC REPOS:
- nanopb
- PromisesObjC
- PromisesSwift
- TensorFlowLiteC
- TensorFlowLiteSwift

EXTERNAL SOURCES:
device_info_plus:
Expand Down Expand Up @@ -189,8 +164,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
tflite_flutter:
:path: ".symlinks/plugins/tflite_flutter/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
video_player_avfoundation:
Expand Down Expand Up @@ -225,9 +198,6 @@ SPEC CHECKSUMS:
PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
TensorFlowLiteC: 20785a69299185a379ba9852b6625f00afd7984a
TensorFlowLiteSwift: 3a4928286e9e35bdd3e17970f48e53c80d25e793
tflite_flutter: 9433d086a3060431bbc9f3c7c20d017db0e72d08
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
video_player_avfoundation: e9e6f9cae7d7a6d9b43519b0aab382bca60fcfd1

Expand Down
2 changes: 1 addition & 1 deletion ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ platform :ios do
skip_certificate_matching: true
)

previous_build_number = latest_testflight_build_number(initial_build_number: 0)
previous_build_number = latest_testflight_build_number(version: get_version_number, initial_build_number: 0)

current_build_number = previous_build_number + 1

Expand Down
35 changes: 6 additions & 29 deletions lib/base/enums/search_category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,16 @@ import 'package:campus_flutter/base/extensions/context.dart';
import 'package:flutter/cupertino.dart';

enum SearchCategory {
/// enums that exist in the Text Classification Model
cafeterias,
calendar,
grade,
movie,
news,
studyRoom,
unknown,

/// enums that are not classified but shown in searches
persons,
rooms,
calendar,
lectures,
personalLectures,
persons,
rooms;

factory SearchCategory.fromString(String category) {
switch (category) {
case "cafeterias":
return SearchCategory.cafeterias;
case "calendar":
return SearchCategory.calendar;
case "grade":
return SearchCategory.grade;
case "movie":
return SearchCategory.movie;
case "news":
return SearchCategory.news;
case "studyroom":
return SearchCategory.studyRoom;
default:
return SearchCategory.unknown;
}
}
grade,
movie,
news;
}

extension SearchCategoryExtension on SearchCategory {
Expand Down
10 changes: 10 additions & 0 deletions lib/base/helpers/read_list_value.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
List<dynamic> readListValue(Map<dynamic, dynamic> data, String key) {
final relevantData = data[key];
if (relevantData is List<dynamic>) {
return relevantData;
} else if (relevantData is Map<String, dynamic>) {
return [relevantData];
} else {
return [];
}
}
4 changes: 3 additions & 1 deletion lib/base/localization/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,7 @@
"selectTokenManagement":"2. Token-Verwaltung auswählen\n",
"activateToken":"3. Aktivieren Sie den neu erstellten Token und\n aktivieren Sie die gewünschten Berechtigungen",
"location":"Standort",
"locationOnboarding":"Aktiviere Standorte, um personalisierte Erlebnisse zu erreichen und Deinen Standort auf Raumfinder-Karten zu sehen."
"locationOnboarding":"Aktiviere Standorte, um personalisierte Erlebnisse zu erreichen und Deinen Standort auf Raumfinder-Karten zu sehen.",
"continueOnboarding":"Weiter",
"showMore":"Mehr Anzeigen"
}
4 changes: 3 additions & 1 deletion lib/base/localization/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,7 @@
"selectTokenManagement":"2. Select Token-Management\n",
"activateToken":"3. Activate the newly created token \nand enable your desired permissions",
"location":"Location",
"locationOnboarding":"Enable locations to access personalized experiences and your location on the room finder maps."
"locationOnboarding":"Enable locations to access personalized experiences and your location on the room finder maps.",
"continueOnboarding":"Continue",
"showMore":"Show More"
}
5 changes: 5 additions & 0 deletions lib/base/networking/apis/tumdev/campus_backend.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1443,9 +1443,11 @@ class GetDishRatingsReply extends $pb.GeneratedMessage {
static GetDishRatingsReply getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<GetDishRatingsReply>(create);
static GetDishRatingsReply? _defaultInstance;

/// a number of actual ratings
@$pb.TagNumber(1)
$core.List<SingleRatingReply> get rating => $_getList(0);

/// average rating for all dish rating tags which were used to rate this dish in this cafeteria
@$pb.TagNumber(2)
$core.double get avg => $_getN(1);
@$pb.TagNumber(2)
Expand All @@ -1455,6 +1457,7 @@ class GetDishRatingsReply extends $pb.GeneratedMessage {
@$pb.TagNumber(2)
void clearAvg() => clearField(2);

/// std of all dish rating tags which were used to rate this dish in this cafeteria
@$pb.TagNumber(3)
$core.double get std => $_getN(2);
@$pb.TagNumber(3)
Expand All @@ -1464,6 +1467,7 @@ class GetDishRatingsReply extends $pb.GeneratedMessage {
@$pb.TagNumber(3)
void clearStd() => clearField(3);

/// minimum of all dish rating tags which were used to rate this dish in this cafeteria
@$pb.TagNumber(4)
$core.int get min => $_getIZ(3);
@$pb.TagNumber(4)
Expand All @@ -1473,6 +1477,7 @@ class GetDishRatingsReply extends $pb.GeneratedMessage {
@$pb.TagNumber(4)
void clearMin() => clearField(4);

/// maximum of all dish rating tags which were used to rate this dish in this cafeteria
@$pb.TagNumber(5)
$core.int get max => $_getIZ(4);
@$pb.TagNumber(5)
Expand Down
22 changes: 11 additions & 11 deletions lib/base/networking/base/rest_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ class RESTClient {
}

log("${response.statusCode}: ${response.realUri}");
try {
return ApiResponse<T>.fromJson(
jsonDecode(response.data.toString()),
response.headers,
createObject,
);
} catch (e) {
log(e.toString());
rethrow;
}

return ApiResponse<T>.fromJson(
jsonDecode(response.data.toString()),
response.headers,
createObject,
);
} catch (e) {
log("${endpoint.asURL().toString()}: ${e.toString()}");
if (e is Error) {
log("${endpoint.asURL().toString()}: ${e.stackTrace.toString()}");
} else {
log("${endpoint.asURL().toString()}: ${e.toString()}");
}
rethrow;
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/departuresComponent/model/mvv_response.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:campus_flutter/base/helpers/read_list_value.dart';
import 'package:campus_flutter/departuresComponent/model/departure.dart';
import 'package:json_annotation/json_annotation.dart';

part 'mvv_response.g.dart';

@JsonSerializable()
class MvvResponse {
@JsonKey(name: "departureList")
final List<Departure>? departures;
@JsonKey(name: "departureList", readValue: readListValue)
final List<Departure> departures;

MvvResponse({this.departures});
MvvResponse({required this.departures});

factory MvvResponse.fromJson(Map<String, dynamic> json) =>
_$MvvResponseFromJson(json);
Expand Down
4 changes: 2 additions & 2 deletions lib/departuresComponent/model/mvv_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/departuresComponent/viewModel/departures_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class DeparturesViewModel {
void sortDepartures(({DateTime? saved, MvvResponse data}) response) {
lastFetched.add(response.saved);

response.data.departures?.sort((departure1, departure2) {
response.data.departures.sort((departure1, departure2) {
if (departure1.realDateTime != null && departure2.realDateTime != null) {
return departure1.realDateTime!.compareTo(departure2.realDateTime!);
} else if (departure1.realDateTime != null) {
Expand All @@ -143,7 +143,7 @@ class DeparturesViewModel {
}
});

departures.add(response.data.departures ?? []);
departures.add(response.data.departures);
setTimerForRefresh();
}

Expand Down
1 change: 0 additions & 1 deletion lib/lectureComponent/views/lecture_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:campus_flutter/base/extensions/context.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

// TODO: stateless?
class LectureDetailsView extends ConsumerStatefulWidget {
const LectureDetailsView({
super.key,
Expand Down
10 changes: 7 additions & 3 deletions lib/loginComponent/views/permission_check_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ class _PermissionCheckViewState extends ConsumerState<PermissionCheckView> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
backgroundColor: widget.isSettingsView
? Theme.of(context).colorScheme.surface
: Theme.of(context).brightness == Brightness.dark
? Theme.of(context).canvasColor
: Colors.white,
appBar: AppBar(
leading: const BackButton(),
leading: widget.isSettingsView ? const BackButton() : null,
title: Text(context.localizations.checkPermissions),
),
body: Padding(
Expand Down Expand Up @@ -93,7 +97,7 @@ class _PermissionCheckViewState extends ConsumerState<PermissionCheckView> {
);
}
},
child: Text(context.localizations.done),
child: Text(context.localizations.continueOnboarding),
),
),
const Spacer(flex: 3),
Expand Down
64 changes: 33 additions & 31 deletions lib/loginComponent/views/permission_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,40 @@ class PermissionView extends StatelessWidget {
: Colors.white;
return Scaffold(
backgroundColor: backgroundColor,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Spacer(
flex: 2,
),
Image.asset(
imagePath,
height: 150,
),
const Spacer(),
Text(
title,
style: Theme.of(context).textTheme.headlineMedium?.apply(
color: Theme.of(context).primaryColor,
),
),
Padding(
padding: EdgeInsets.all(context.padding),
child: Text(
description,
textAlign: TextAlign.center,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Spacer(
flex: 2,
),
),
const Spacer(),
ElevatedButton(
onPressed: onButtonPress,
child: const Text("Okay"),
),
const Spacer(),
],
Image.asset(
imagePath,
height: 150,
),
const Spacer(),
Text(
title,
style: Theme.of(context).textTheme.headlineMedium?.apply(
color: Theme.of(context).primaryColor,
),
),
Padding(
padding: EdgeInsets.all(context.padding),
child: Text(
description,
textAlign: TextAlign.center,
),
),
const Spacer(),
ElevatedButton(
onPressed: onButtonPress,
child: const Text("Okay"),
),
const Spacer(),
],
),
),
);
}
Expand Down
5 changes: 0 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import 'package:campus_flutter/base/networking/base/rest_client.dart';
import 'package:campus_flutter/base/theme/dark_theme.dart';
import 'package:campus_flutter/base/theme/light_theme.dart';
import 'package:campus_flutter/calendarComponent/services/calendar_view_service.dart';
import 'package:campus_flutter/loginComponent/views/confirm_view.dart';
import 'package:campus_flutter/navigation_service.dart';
import 'package:campus_flutter/placesComponent/services/map_theme_service.dart';
import 'package:campus_flutter/routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -93,9 +91,6 @@ class CampusApp extends ConsumerWidget {
locale: ref.watch(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
routes: {
confirm: (context) => const ConfirmView(),
},
home: const AuthenticationRouter(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/placesComponent/services/cafeterias_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CafeteriasService {
forcedRefresh,
);

// TODO(Jakob): add fetching of queue status
// TODO(Jakob): add fetching of queue status?

return (response.saved, response.data.cafeterias);
}
Expand Down
Loading

0 comments on commit 68a552c

Please sign in to comment.