Skip to content

Commit cccda29

Browse files
committed
Fix group query in calendar item
1 parent a7ac425 commit cccda29

File tree

13 files changed

+309
-301
lines changed

13 files changed

+309
-301
lines changed

api/lib/models/event/item/database.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CalendarItemDatabaseService extends CalendarItemService
4747
Future<List<ConnectedModel<CalendarItem, Event?>>> getCalendarItems(
4848
{List<EventStatus>? status,
4949
Uint8List? eventId,
50-
Uint8List? groupId,
50+
List<Uint8List>? groupIds,
5151
List<Uint8List>? resourceIds,
5252
bool pending = false,
5353
int offset = 0,
@@ -98,18 +98,23 @@ class CalendarItemDatabaseService extends CalendarItemService
9898
: '$where AND (name LIKE ? OR description LIKE ?)';
9999
whereArgs = [...?whereArgs, '%$search%', '%$search%'];
100100
}
101-
if (groupId != null) {
102-
final statement = "(groupId = ? OR events.groupId = ?)";
101+
if (groupIds != null) {
102+
final placeholders = List.filled(groupIds.length, '?').join(', ');
103+
final statement =
104+
"(calendarItems.id IN (SELECT itemId FROM groupResources WHERE groupId IN ($placeholders)) OR "
105+
"calendarItems.eventId IN (SELECT eventId FROM eventResources WHERE groupId IN ($placeholders)))";
103106
where = where == null ? statement : '$where AND $statement';
104-
whereArgs = [...?whereArgs, groupId, groupId];
107+
whereArgs = [...?whereArgs, ...groupIds, ...groupIds];
105108
}
106109
if (eventId != null) {
107110
where = where == null ? 'eventId = ?' : '$where AND eventId = ?';
108111
whereArgs = [...?whereArgs, eventId];
109112
}
110113
if (resourceIds != null) {
114+
final placeholders = List.filled(resourceIds.length, '?').join(', ');
111115
final statement =
112-
"(calendarItems.id IN (SELECT itemId FROM calendarItemResources WHERE resourceId IN (${List.filled(resourceIds.length, '?').join(', ')})) OR events.id IN (SELECT eventId FROM eventResources WHERE resourceId IN (${List.filled(resourceIds.length, '?').join(', ')})))";
116+
"(calendarItems.id IN (SELECT itemId FROM calendarItemResources WHERE resourceId IN ($placeholders)) OR "
117+
"calendarItems.eventId IN (SELECT eventId FROM eventResources WHERE resourceId IN ($placeholders)))";
113118
where = where == null ? statement : '$where AND $statement';
114119
whereArgs = [...?whereArgs, ...resourceIds, ...resourceIds];
115120
}
@@ -204,7 +209,7 @@ abstract class CalendarItemDatabaseServiceLinker extends CalendarItemService
204209
FutureOr<List<ConnectedModel<CalendarItem, Event?>>> getCalendarItems({
205210
List<EventStatus>? status,
206211
Uint8List? eventId,
207-
Uint8List? groupId,
212+
List<Uint8List>? groupIds,
208213
List<Uint8List>? resourceIds,
209214
bool pending = false,
210215
int offset = 0,
@@ -217,7 +222,7 @@ abstract class CalendarItemDatabaseServiceLinker extends CalendarItemService
217222
service.getCalendarItems(
218223
status: status,
219224
eventId: eventId,
220-
groupId: groupId,
225+
groupIds: groupIds,
221226
resourceIds: resourceIds,
222227
pending: pending,
223228
offset: offset,

api/lib/models/event/item/service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class CalendarItemService extends ModelService {
1111
FutureOr<List<ConnectedModel<CalendarItem, Event?>>> getCalendarItems({
1212
List<EventStatus>? status,
1313
Uint8List? eventId,
14-
Uint8List? groupId,
14+
List<Uint8List>? groupIds,
1515
List<Uint8List>? resourceIds,
1616
bool pending = false,
1717
int offset = 0,

api/pubspec.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ packages:
109109
dependency: transitive
110110
description:
111111
name: built_value
112-
sha256: "28a712df2576b63c6c005c465989a348604960c0958d28be5303ba9baa841ac2"
112+
sha256: "8b158ab94ec6913e480dc3f752418348b5ae099eb75868b5f4775f0572999c61"
113113
url: "https://pub.dev"
114114
source: hosted
115-
version: "8.9.3"
115+
version: "8.9.4"
116116
checked_yaml:
117117
dependency: transitive
118118
description:
@@ -558,10 +558,10 @@ packages:
558558
dependency: transitive
559559
description:
560560
name: web
561-
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
561+
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
562562
url: "https://pub.dev"
563563
source: hosted
564-
version: "1.1.0"
564+
version: "1.1.1"
565565
web_socket:
566566
dependency: transitive
567567
description:

app/lib/l10n/app_en.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dashboard": "Dashboard",
3+
"translate": "Translate",
34
"calendar": "Calendar",
45
"resources": "Resources",
56
"users": "Users",

app/lib/pages/calendar/day.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class _CalendarDayViewState extends State<CalendarDayView> {
6464
.where((element) => !widget.filter.hiddenStatuses.contains(element))
6565
.toList(),
6666
search: widget.search,
67-
groupId: widget.filter.group,
67+
groupIds: widget.filter.groups,
6868
eventId: widget.filter.event,
6969
resourceIds: widget.filter.resources,
7070
);

app/lib/pages/calendar/filter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class CalendarFilter with CalendarFilterMappable {
3434
});
3535

3636
List<Uint8List>? get resources => resource != null ? [resource!] : null;
37+
List<Uint8List>? get groups => group != null ? [group!] : null;
3738

3839
SourcedModel<Uint8List>? get sourceEvent => event != null && source != null
3940
? SourcedModel<Uint8List>(source!, event!)

app/lib/pages/calendar/list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class _CalendarListViewState extends State<CalendarListView> {
114114
!widget.filter.hiddenStatuses.contains(element))
115115
.toList(),
116116
search: widget.search,
117-
groupId: widget.filter.group,
117+
groupIds: widget.filter.groups,
118118
eventId: widget.filter.event,
119119
offset: source.value * _pageSize,
120120
limit: _pageSize,

app/lib/pages/calendar/month.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
8888
.toList(),
8989
search: widget.search,
9090
eventId: widget.filter.event,
91-
groupId: widget.filter.group,
91+
groupIds: widget.filter.groups,
9292
resourceIds: widget.filter.resources,
9393
);
9494
if (fetchedDay == null) continue;

app/lib/pages/calendar/week.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class _CalendarWeekViewState extends State<CalendarWeekView> {
7878
.toList(),
7979
search: widget.search,
8080
eventId: widget.filter.event,
81-
groupId: widget.filter.group,
81+
groupIds: widget.filter.groups,
8282
resourceIds: widget.filter.resources,
8383
);
8484
if (fetchedDay == null) continue;

app/lib/pages/settings/contents/information.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class InformationSettingsView extends StatelessWidget {
3737
onTap: () => launchUrl(Uri.https("go.linwood.dev", "matrix")),
3838
),
3939
ListTile(
40-
title: const Text("Crowdin"),
40+
title: Text(AppLocalizations.of(context).translate),
4141
leading: const PhosphorIcon(PhosphorIconsLight.translate),
42-
onTap: () => launchUrl(Uri.https("go.linwood.dev", "flow/crowdin")),
42+
onTap: () => launchUrl(Uri.https("go.linwood.dev", "flow/translate")),
4343
),
4444
ListTile(
4545
title: Text(AppLocalizations.of(context).source),

0 commit comments

Comments
 (0)