updates for sub-space analytics
This commit is contained in:
parent
9138940e35
commit
47246cd392
5 changed files with 36 additions and 22 deletions
|
|
@ -97,11 +97,9 @@ class AnalyticsController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
final List<String> spaceChildrenIds = space.spaceChildren
|
||||
.map((e) => e.roomId)
|
||||
.where((e) => e != null)
|
||||
.cast<String>()
|
||||
.toList();
|
||||
final resp = await space.client.getSpaceHierarchy(space.id);
|
||||
final List<String> spaceChildrenIds =
|
||||
resp.rooms.map((room) => room.roomId).toList();
|
||||
|
||||
final List<SummaryAnalyticsEvent> allAnalyticsEvents = [];
|
||||
for (final analyticsEvent in analyticsEvents) {
|
||||
|
|
@ -180,6 +178,14 @@ class AnalyticsController extends BaseController {
|
|||
String? roomID,
|
||||
) {
|
||||
List<SummaryAnalyticsEvent> filtered = [...unfiltered];
|
||||
Room? room;
|
||||
if (roomID != null) {
|
||||
room = _pangeaController.matrixState.client.getRoomById(roomID);
|
||||
if (room?.isSpace == true) {
|
||||
return filterSpaceAnalytics(unfiltered, roomID);
|
||||
}
|
||||
}
|
||||
|
||||
filtered = filtered
|
||||
.where(
|
||||
(e) => (e.content).messages.any((u) => u.chatId == roomID),
|
||||
|
|
@ -229,9 +235,10 @@ class AnalyticsController extends BaseController {
|
|||
|
||||
List<SummaryAnalyticsEvent> filtered =
|
||||
List<SummaryAnalyticsEvent>.from(unfiltered);
|
||||
|
||||
filtered = filtered
|
||||
.where(
|
||||
(e) => (e.content).messages.any((u) => chatIds.contains(u.chatId)),
|
||||
(e) => e.content.messages.any((u) => chatIds.contains(u.chatId)),
|
||||
)
|
||||
.toList();
|
||||
|
||||
|
|
@ -429,11 +436,9 @@ class AnalyticsController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
final List<String> spaceChildrenIds = space.spaceChildren
|
||||
.map((e) => e.roomId)
|
||||
.where((e) => e != null)
|
||||
.cast<String>()
|
||||
.toList();
|
||||
final resp = await space.client.getSpaceHierarchy(space.id);
|
||||
final List<String> spaceChildrenIds =
|
||||
resp.rooms.map((room) => room.roomId).toList();
|
||||
|
||||
final List<ConstructAnalyticsEvent> allConstructs = [];
|
||||
for (final constructEvent in constructEvents) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class AnalyticsListTile extends StatefulWidget {
|
|||
required this.onTap,
|
||||
required this.pangeaController,
|
||||
// this.isEnabled = true,
|
||||
this.showSpaceAnalytics = true,
|
||||
// this.showSpaceAnalytics = true,
|
||||
this.refreshStream,
|
||||
});
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ class AnalyticsListTile extends StatefulWidget {
|
|||
final bool allowNavigateOnSelect;
|
||||
final bool isSelected;
|
||||
// final bool isEnabled;
|
||||
final bool showSpaceAnalytics;
|
||||
// final bool showSpaceAnalytics;
|
||||
|
||||
final PangeaController pangeaController;
|
||||
final StreamController? refreshStream;
|
||||
|
|
@ -128,11 +128,9 @@ class AnalyticsListTileState extends State<AnalyticsListTile> {
|
|||
),
|
||||
],
|
||||
),
|
||||
subtitle: widget.showSpaceAnalytics || !(room?.isSpace ?? false)
|
||||
? ListSummaryAnalytics(
|
||||
chartAnalytics: tileData,
|
||||
)
|
||||
: null,
|
||||
subtitle: ListSummaryAnalytics(
|
||||
chartAnalytics: tileData,
|
||||
),
|
||||
selected: widget.isSelected,
|
||||
onTap: () {
|
||||
(room?.isSpace ?? false) && widget.allowNavigateOnSelect
|
||||
|
|
|
|||
|
|
@ -50,10 +50,22 @@ class BaseAnalyticsController extends State<BaseAnalyticsPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
runFirstRefresh();
|
||||
if (widget.defaultSelected.type == AnalyticsEntryType.student) {
|
||||
runFirstRefresh();
|
||||
}
|
||||
setChartData();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant BaseAnalyticsPage oldWidget) {
|
||||
// when a user is a parent space's analytics and clicks on a subspace
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.defaultSelected.id != widget.defaultSelected.id) {
|
||||
setChartData();
|
||||
refreshStream.add(false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> runFirstRefresh() async {
|
||||
final analyticsRooms =
|
||||
pangeaController.matrixState.client.allMyAnalyticsRooms;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ class BaseAnalyticsView extends StatelessWidget {
|
|||
),
|
||||
isSelected:
|
||||
controller.isSelected(item.id),
|
||||
showSpaceAnalytics: false,
|
||||
onTap: (_) =>
|
||||
controller.toggleSelection(
|
||||
AnalyticsSelected(
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class ClassAnalyticsV2Controller extends State<ClassAnalyticsPage> {
|
|||
_classRoom = classId != null
|
||||
? Matrix.of(context).client.getRoomById(classId!)
|
||||
: null;
|
||||
getChatAndStudents();
|
||||
}
|
||||
return _classRoom;
|
||||
}
|
||||
|
|
@ -47,6 +48,7 @@ class ClassAnalyticsV2Controller extends State<ClassAnalyticsPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
debugPrint("init class analytics");
|
||||
Future.delayed(Duration.zero, () async {
|
||||
if (classRoom == null || (!(classRoom?.isSpace ?? false))) {
|
||||
context.go('/rooms');
|
||||
|
|
@ -62,9 +64,7 @@ class ClassAnalyticsV2Controller extends State<ClassAnalyticsPage> {
|
|||
if (classRoom != null) {
|
||||
final response = await Matrix.of(context).client.getSpaceHierarchy(
|
||||
classRoom!.id,
|
||||
maxDepth: 1,
|
||||
);
|
||||
|
||||
students = classRoom!.students;
|
||||
chats = response.rooms
|
||||
.where(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue