mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-03 18:48:40 +00:00
Add activity debug page and fix some bugs
This commit is contained in:
parent
7f1b1b2a43
commit
f2cfa6b093
5 changed files with 139 additions and 19 deletions
|
@ -0,0 +1,85 @@
|
||||||
|
@page "/debug/activity"
|
||||||
|
@using System.Globalization
|
||||||
|
@using LBPUnion.ProjectLighthouse.Types.Activity
|
||||||
|
@using LBPUnion.ProjectLighthouse.Types.Entities.Activity
|
||||||
|
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug.ActivityTestPage
|
||||||
|
|
||||||
|
@{
|
||||||
|
Layout = "Layouts/BaseLayout";
|
||||||
|
Model.Title = "Debug - Activity Test";
|
||||||
|
}
|
||||||
|
|
||||||
|
<a href="?groupByActor=false">
|
||||||
|
<div class="ui @(!Model.GroupByActor ? "blue" : "") button">Group By Activity</div>
|
||||||
|
</a>
|
||||||
|
<a href="?groupByActor=true">
|
||||||
|
<div class="ui @(Model.GroupByActor ? "blue" : "") button">Group By Actor</div>
|
||||||
|
</a>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
|
@foreach (OuterActivityGroup activity in Model.ActivityGroups)
|
||||||
|
{
|
||||||
|
<h4 class="ui top attached header">@activity.Key.GroupType, Timestamp: @activity.Key.Timestamp.ToString(CultureInfo.InvariantCulture)</h4>
|
||||||
|
<div class="ui attached segment">
|
||||||
|
|
||||||
|
@if (activity.Key.UserId != -1)
|
||||||
|
{
|
||||||
|
<p>UserId: @activity.Key.UserId</p>
|
||||||
|
}
|
||||||
|
@if ((activity.Key.TargetNewsId ?? -1) != -1)
|
||||||
|
{
|
||||||
|
<p>TargetNewsId?: @activity.Key.TargetNewsId (targetId=@activity.Key.TargetId)</p>
|
||||||
|
}
|
||||||
|
@if ((activity.Key.TargetPlaylistId ?? -1) != -1)
|
||||||
|
{
|
||||||
|
<p>TargetPlaylistId?: @activity.Key.TargetPlaylistId (targetId=@activity.Key.TargetId)</p>
|
||||||
|
}
|
||||||
|
@if ((activity.Key.TargetSlotId ?? -1) != -1)
|
||||||
|
{
|
||||||
|
<p>TargetSlotId?: @activity.Key.TargetSlotId (targetId=@activity.Key.TargetId)</p>
|
||||||
|
}
|
||||||
|
@if ((activity.Key.TargetTeamPickSlotId ?? -1) != -1)
|
||||||
|
{
|
||||||
|
<p>TargetTeamPickSlot?: @activity.Key.TargetTeamPickSlotId (targetId=@activity.Key.TargetId)</p>
|
||||||
|
}
|
||||||
|
@if ((activity.Key.TargetUserId ?? -1) != -1)
|
||||||
|
{
|
||||||
|
<p>TargetUserId?: @activity.Key.TargetUserId (targetId=@activity.Key.TargetId)</p>
|
||||||
|
}
|
||||||
|
<div class="ui segments">
|
||||||
|
|
||||||
|
@foreach (IGrouping<InnerActivityGroup, ActivityDto>? eventGroup in activity.Groups)
|
||||||
|
{
|
||||||
|
<div class="ui segment">
|
||||||
|
<h5>Nested Group Type: @eventGroup.Key.Type</h5>
|
||||||
|
|
||||||
|
@foreach (ActivityDto gameEvent in eventGroup.ToList())
|
||||||
|
{
|
||||||
|
<h5 class="ui top attached header" style="text-align: start">
|
||||||
|
@gameEvent.Activity.Type, Event Id: @gameEvent.Activity.ActivityId
|
||||||
|
</h5>
|
||||||
|
<div class="ui attached segment">
|
||||||
|
<p>Event Group Type: @gameEvent.GroupType</p>
|
||||||
|
<p>Event Target ID: @gameEvent.TargetId</p>
|
||||||
|
@if (gameEvent.Activity is LevelActivityEntity level)
|
||||||
|
{
|
||||||
|
<p>SlotId: @level.SlotId</p>
|
||||||
|
<p>SlotVersion: @gameEvent.TargetSlotGameVersion</p>
|
||||||
|
}
|
||||||
|
@if (gameEvent.Activity is ScoreActivityEntity score)
|
||||||
|
{
|
||||||
|
<p>ScoreId: @score.ScoreId</p>
|
||||||
|
<p>SlotId: @score.SlotId</p>
|
||||||
|
<p>SlotVersion: @gameEvent.TargetSlotGameVersion</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui bottom attached segment">
|
||||||
|
<p>Total events: @activity.Groups.Sum(g => g.ToList().Count)</p>
|
||||||
|
</div>
|
||||||
|
<div class="ui massive divider" style="background-color: #0e91f5"></div>
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
using LBPUnion.ProjectLighthouse.Database;
|
||||||
|
using LBPUnion.ProjectLighthouse.Extensions;
|
||||||
|
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Activity;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
|
||||||
|
|
||||||
|
public class ActivityTestPage : BaseLayout
|
||||||
|
{
|
||||||
|
public ActivityTestPage(DatabaseContext database) : base(database)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public List<OuterActivityGroup> ActivityGroups = [];
|
||||||
|
|
||||||
|
public bool GroupByActor { get; set; }
|
||||||
|
|
||||||
|
public async Task<IActionResult> OnGet(bool groupByActor = false)
|
||||||
|
{
|
||||||
|
Console.WriteLine(groupByActor);
|
||||||
|
List<OuterActivityGroup>? events = (await this.Database.Activities.ToActivityDto(true).ToActivityGroups(groupByActor).ToListAsync())
|
||||||
|
.ToOuterActivityGroups(groupByActor);
|
||||||
|
|
||||||
|
if (events == null) return this.Page();
|
||||||
|
|
||||||
|
this.GroupByActor = groupByActor;
|
||||||
|
|
||||||
|
this.ActivityGroups = events;
|
||||||
|
return this.Page();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -41,16 +41,17 @@ public static class ActivityQueryExtensions
|
||||||
{
|
{
|
||||||
Timestamp = dto.Activity.Timestamp.Date,
|
Timestamp = dto.Activity.Timestamp.Date,
|
||||||
UserId = dto.Activity.UserId,
|
UserId = dto.Activity.UserId,
|
||||||
TargetNewsId = dto.TargetNewsId ?? 0,
|
TargetNewsId = dto.TargetNewsId ?? -1,
|
||||||
TargetTeamPickSlotId = dto.TargetTeamPickId ?? 0,
|
TargetTeamPickSlotId = dto.TargetTeamPickId ?? -1,
|
||||||
})
|
})
|
||||||
: activityQuery.GroupBy(dto => new ActivityGroup
|
: activityQuery.GroupBy(dto => new ActivityGroup
|
||||||
{
|
{
|
||||||
Timestamp = dto.Activity.Timestamp.Date,
|
Timestamp = dto.Activity.Timestamp.Date,
|
||||||
TargetUserId = dto.TargetUserId ?? 0,
|
UserId = -1,
|
||||||
TargetSlotId = dto.TargetSlotId ?? 0,
|
TargetUserId = dto.TargetUserId ?? -1,
|
||||||
TargetPlaylistId = dto.TargetPlaylistId ?? 0,
|
TargetSlotId = dto.TargetSlotId ?? -1,
|
||||||
TargetNewsId = dto.TargetNewsId ?? 0,
|
TargetPlaylistId = dto.TargetPlaylistId ?? -1,
|
||||||
|
TargetNewsId = dto.TargetNewsId ?? -1,
|
||||||
});
|
});
|
||||||
|
|
||||||
public static List<OuterActivityGroup> ToOuterActivityGroups
|
public static List<OuterActivityGroup> ToOuterActivityGroups
|
||||||
|
|
|
@ -17,10 +17,10 @@ public class ActivityDto
|
||||||
public int TargetId =>
|
public int TargetId =>
|
||||||
this.GroupType switch
|
this.GroupType switch
|
||||||
{
|
{
|
||||||
ActivityGroupType.User => this.TargetUserId ?? 0,
|
ActivityGroupType.User => this.TargetUserId ?? -1,
|
||||||
ActivityGroupType.Level => this.TargetSlotId ?? 0,
|
ActivityGroupType.Level => this.TargetSlotId ?? -1,
|
||||||
ActivityGroupType.Playlist => this.TargetPlaylistId ?? 0,
|
ActivityGroupType.Playlist => this.TargetPlaylistId ?? -1,
|
||||||
ActivityGroupType.News => this.TargetNewsId ?? 0,
|
ActivityGroupType.News => this.TargetNewsId ?? -1,
|
||||||
_ => this.Activity.UserId,
|
_ => this.Activity.UserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,21 +19,21 @@ public struct ActivityGroup
|
||||||
this.GroupType switch
|
this.GroupType switch
|
||||||
{
|
{
|
||||||
ActivityGroupType.User => this.TargetUserId ?? this.UserId,
|
ActivityGroupType.User => this.TargetUserId ?? this.UserId,
|
||||||
ActivityGroupType.Level => this.TargetSlotId ?? 0,
|
ActivityGroupType.Level => this.TargetSlotId ?? -1,
|
||||||
ActivityGroupType.TeamPick => this.TargetTeamPickSlotId ?? 0,
|
ActivityGroupType.TeamPick => this.TargetTeamPickSlotId ?? -1,
|
||||||
ActivityGroupType.Playlist => this.TargetPlaylistId ?? 0,
|
ActivityGroupType.Playlist => this.TargetPlaylistId ?? -1,
|
||||||
ActivityGroupType.News => this.TargetNewsId ?? 0,
|
ActivityGroupType.News => this.TargetNewsId ?? -1,
|
||||||
_ => this.UserId,
|
_ => this.UserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
public ActivityGroupType GroupType =>
|
public ActivityGroupType GroupType =>
|
||||||
(this.TargetPlaylistId ?? 0) != 0
|
(this.TargetPlaylistId ?? -1) != -1
|
||||||
? ActivityGroupType.User
|
? ActivityGroupType.Playlist
|
||||||
: (this.TargetNewsId ?? 0) != 0
|
: (this.TargetNewsId ?? -1) != -1
|
||||||
? ActivityGroupType.News
|
? ActivityGroupType.News
|
||||||
: (this.TargetTeamPickSlotId ?? 0) != 0
|
: (this.TargetTeamPickSlotId ?? -1) != -1
|
||||||
? ActivityGroupType.TeamPick
|
? ActivityGroupType.TeamPick
|
||||||
: (this.TargetSlotId ?? 0) != 0
|
: (this.TargetSlotId ?? -1) != -1
|
||||||
? ActivityGroupType.Level
|
? ActivityGroupType.Level
|
||||||
: ActivityGroupType.User;
|
: ActivityGroupType.User;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue