From e477429a35526b21592bf12f148c4c0b5afdf15e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 6 Dec 2025 21:12:08 +0800 Subject: [PATCH] :necktie: Increase the chance of other type of activities show up :wastebasket: Remove debug include in timeline --- .../Timeline/TimelineController.cs | 11 ++----- .../Timeline/TimelineService.cs | 30 ++++++------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/DysonNetwork.Sphere/Timeline/TimelineController.cs b/DysonNetwork.Sphere/Timeline/TimelineController.cs index 6d2508d..9d50805 100644 --- a/DysonNetwork.Sphere/Timeline/TimelineController.cs +++ b/DysonNetwork.Sphere/Timeline/TimelineController.cs @@ -25,8 +25,7 @@ public class ActivityController(TimelineService acts) : ControllerBase public async Task>> ListEvents( [FromQuery] string? cursor, [FromQuery] string? filter, - [FromQuery] int take = 20, - [FromQuery] string? debugInclude = null + [FromQuery] int take = 20 ) { Instant? cursorTimestamp = null; @@ -42,13 +41,9 @@ public class ActivityController(TimelineService acts) : ControllerBase } } - var debugIncludeSet = debugInclude?.Split(',').ToHashSet() ?? new HashSet(); - HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); return currentUserValue is not Account currentUser - ? Ok(await acts.ListEventsForAnyone(take, cursorTimestamp, debugIncludeSet)) - : Ok( - await acts.ListEvents(take, cursorTimestamp, currentUser, filter, debugIncludeSet) - ); + ? Ok(await acts.ListEventsForAnyone(take, cursorTimestamp)) + : Ok(await acts.ListEvents(take, cursorTimestamp, currentUser, filter)); } } diff --git a/DysonNetwork.Sphere/Timeline/TimelineService.cs b/DysonNetwork.Sphere/Timeline/TimelineService.cs index 656b7b7..543dad2 100644 --- a/DysonNetwork.Sphere/Timeline/TimelineService.cs +++ b/DysonNetwork.Sphere/Timeline/TimelineService.cs @@ -32,14 +32,9 @@ public class TimelineService( return performanceWeight / Math.Pow(normalizedTime + 1.0, 1.2); } - public async Task> ListEventsForAnyone( - int take, - Instant? cursor, - HashSet? debugInclude = null - ) + public async Task> ListEventsForAnyone(int take, Instant? cursor) { var activities = new List(); - debugInclude ??= new HashSet(); // Get and process posts var publicRealms = await rs.GetPublicRealms(); @@ -60,7 +55,7 @@ public class TimelineService( // Randomly insert a discovery activity before some posts if (random.NextDouble() < 0.15) { - var discovery = await MaybeGetDiscoveryActivity(debugInclude, cursor: cursor); + var discovery = await MaybeGetDiscoveryActivity(cursor: cursor); if (discovery != null) interleaved.Add(discovery); } @@ -80,12 +75,10 @@ public class TimelineService( int take, Instant? cursor, Account currentUser, - string? filter = null, - HashSet? debugInclude = null + string? filter = null ) { var activities = new List(); - debugInclude ??= new HashSet(); // Get user's friends and publishers var friendsResponse = await accounts.ListFriendsAsync( @@ -126,7 +119,7 @@ public class TimelineService( { if (random.NextDouble() < 0.15) { - var discovery = await MaybeGetDiscoveryActivity(debugInclude, cursor: cursor); + var discovery = await MaybeGetDiscoveryActivity(cursor: cursor); if (discovery != null) interleaved.Add(discovery); } @@ -142,21 +135,16 @@ public class TimelineService( return activities; } - private async Task MaybeGetDiscoveryActivity( - HashSet debugInclude, - Instant? cursor - ) + private async Task MaybeGetDiscoveryActivity(Instant? cursor) { - if (cursor != null) - return null; var options = new List>>(); - if (debugInclude.Contains("realms") || Random.Shared.NextDouble() < 0.2) + if (Random.Shared.NextDouble() < 0.5) options.Add(() => GetRealmDiscoveryActivity()); - if (debugInclude.Contains("publishers") || Random.Shared.NextDouble() < 0.2) + if (Random.Shared.NextDouble() < 0.5) options.Add(() => GetPublisherDiscoveryActivity()); - if (debugInclude.Contains("articles") || Random.Shared.NextDouble() < 0.2) + if (Random.Shared.NextDouble() < 0.5) options.Add(() => GetArticleDiscoveryActivity()); - if (debugInclude.Contains("shuffledPosts") || Random.Shared.NextDouble() < 0.2) + if (Random.Shared.NextDouble() < 0.5) options.Add(() => GetShuffledPostsActivity()); if (options.Count == 0) return null;