💥 Update activity data format
This commit is contained in:
parent
c63d6e0fbc
commit
b7263b9804
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
using DysonNetwork.Sphere.Account;
|
using DysonNetwork.Sphere.Account;
|
||||||
using DysonNetwork.Sphere.Discovery;
|
using DysonNetwork.Sphere.Discovery;
|
||||||
using DysonNetwork.Sphere.Post;
|
using DysonNetwork.Sphere.Post;
|
||||||
@ -12,9 +11,14 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DysonNetwork.Sphere.Activity;
|
namespace DysonNetwork.Sphere.Activity;
|
||||||
|
|
||||||
public class ActivityService(AppDatabase db, PublisherService pub, RelationshipService rels, PostService ps, DiscoveryService ds)
|
public class ActivityService(
|
||||||
|
AppDatabase db,
|
||||||
|
PublisherService pub,
|
||||||
|
RelationshipService rels,
|
||||||
|
PostService ps,
|
||||||
|
DiscoveryService ds)
|
||||||
{
|
{
|
||||||
private double CalculateHotRank(Post.Post post, Instant now)
|
private static double CalculateHotRank(Post.Post post, Instant now)
|
||||||
{
|
{
|
||||||
var score = post.Upvotes - post.Downvotes;
|
var score = post.Upvotes - post.Downvotes;
|
||||||
var postTime = post.PublishedAt ?? post.CreatedAt;
|
var postTime = post.PublishedAt ?? post.CreatedAt;
|
||||||
@ -32,7 +36,9 @@ public class ActivityService(AppDatabase db, PublisherService pub, RelationshipS
|
|||||||
var realms = await ds.GetPublicRealmsAsync(null, null, 5, 0, true);
|
var realms = await ds.GetPublicRealmsAsync(null, null, 5, 0, true);
|
||||||
if (realms.Count > 0)
|
if (realms.Count > 0)
|
||||||
{
|
{
|
||||||
activities.Add(new DiscoveryActivity("Explore Realms", realms.Cast<object>().ToList()).ToActivity());
|
activities.Add(new DiscoveryActivity(
|
||||||
|
realms.Select(x => new DiscoveryItem("realm", x)).ToList()
|
||||||
|
).ToActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +98,9 @@ public class ActivityService(AppDatabase db, PublisherService pub, RelationshipS
|
|||||||
var realms = await ds.GetPublicRealmsAsync(null, null, 5, 0, true);
|
var realms = await ds.GetPublicRealmsAsync(null, null, 5, 0, true);
|
||||||
if (realms.Count > 0)
|
if (realms.Count > 0)
|
||||||
{
|
{
|
||||||
activities.Add(new DiscoveryActivity("Explore Realms", realms.Cast<object>().ToList()).ToActivity());
|
activities.Add(new DiscoveryActivity(
|
||||||
|
realms.Select(x => new DiscoveryItem("realm", x)).ToList()
|
||||||
|
).ToActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,18 +2,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NodaTime;
|
using NodaTime;
|
||||||
|
|
||||||
namespace DysonNetwork.Sphere.Activity
|
namespace DysonNetwork.Sphere.Activity;
|
||||||
{
|
|
||||||
public class DiscoveryActivity : IActivity
|
|
||||||
{
|
|
||||||
public string Title { get; set; }
|
|
||||||
public List<object> Items { get; set; }
|
|
||||||
|
|
||||||
public DiscoveryActivity(string title, List<object> items)
|
public class DiscoveryActivity(List<DiscoveryItem> items) : IActivity
|
||||||
{
|
{
|
||||||
Title = title;
|
public List<DiscoveryItem> Items { get; set; } = items;
|
||||||
Items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Activity ToActivity()
|
public Activity ToActivity()
|
||||||
{
|
{
|
||||||
@ -29,4 +22,5 @@ namespace DysonNetwork.Sphere.Activity
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public record DiscoveryItem(string Type, object Data);
|
Loading…
x
Reference in New Issue
Block a user