Initial framework for recent activity

This commit is contained in:
Slendy 2023-07-14 15:27:33 -05:00
commit 605f9e68c5
No known key found for this signature in database
GPG key ID: 7288D68361B91428
10 changed files with 151 additions and 0 deletions

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Types.Entities.Activity;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Maintenance;
@ -26,6 +27,10 @@ public partial class DatabaseContext : DbContext
public DbSet<WebTokenEntity> WebTokens { get; set; }
#endregion
#region Activity
public DbSet<ActivityEntity> Activities { get; set; }
#endregion
#region Users
public DbSet<CommentEntity> Comments { get; set; }
public DbSet<LastContactEntity> LastContacts { get; set; }
@ -81,6 +86,16 @@ public partial class DatabaseContext : DbContext
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options)
{ }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<LevelActivityEntity>().UseTpcMappingStrategy();
modelBuilder.Entity<PhotoActivityEntity>().UseTpcMappingStrategy();
modelBuilder.Entity<PlaylistActivityEntity>().UseTpcMappingStrategy();
modelBuilder.Entity<ScoreActivityEntity>().UseTpcMappingStrategy();
modelBuilder.Entity<UserActivityEntity>().UseTpcMappingStrategy();
base.OnModelCreating(modelBuilder);
}
public static DatabaseContext CreateNewInstance()
{
DbContextOptionsBuilder<DatabaseContext> builder = new();

View file

@ -0,0 +1,26 @@
namespace LBPUnion.ProjectLighthouse.Types.Activity;
public enum EventType
{
HeartLevel,
UnheartLevel,
HeartUser,
UnheartUser,
PlayLevel,
RateLevel,
TagLevel,
CommentOnLevel,
DeleteLevelComment,
UploadPhoto,
PublishLevel,
UnpublishLevel,
Score,
NewsPost,
MMPickLevel,
DpadRateLevel,
ReviewLevel,
CommentOnUser,
CreatePlaylist,
HeartPlaylist,
AddLevelToPlaylist,
}

View file

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using LBPUnion.ProjectLighthouse.Types.Activity;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
public class ActivityEntity
{
[Key]
public int ActivityId { get; set; }
public long Timestamp { get; set; }
public int UserId { get; set; }
[ForeignKey(nameof(UserId))]
public UserEntity User { get; set; }
public EventType Type { get; set; }
}

View file

@ -0,0 +1,9 @@
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
/// <summary>
/// Supported event types: CommentOnUser, CommentOnLevel, DeleteLevelComment
/// </summary>
public class CommentActivityEntry
{
}

View file

@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
/// <summary>
/// Supported event types: play_level, heart_level, publish_level,
/// </summary>
public class LevelActivityEntity : ActivityEntity
{
public int SlotId { get; set; }
[ForeignKey(nameof(SlotId))]
public SlotEntity Slot { get; set; }
}

View file

@ -0,0 +1,11 @@
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
/// <summary>
/// Supported event types: NewsPost
/// </summary>
public class NewsActivityEntity : ActivityEntity
{
public string Title { get; set; } = "";
public string Body { get; set; } = "";
}

View file

@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations.Schema;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
/// <summary>
/// Supported event types: UploadPhoto
/// </summary>
public class PhotoActivityEntity : ActivityEntity
{
public int PhotoId { get; set; }
[ForeignKey(nameof(PhotoId))]
public PhotoEntity Photo { get; set; }
}

View file

@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations.Schema;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
public class PlaylistActivityEntity : ActivityEntity
{
public int PlaylistId { get; set; }
[ForeignKey(nameof(PlaylistId))]
public PlaylistEntity Playlist { get; set; }
}

View file

@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
/// <summary>
/// Supported event types: Score
/// </summary>
public class ScoreActivityEntity : ActivityEntity
{
public int ScoreId { get; set; }
[ForeignKey(nameof(ScoreId))]
public ScoreEntity Score { get; set; }
}

View file

@ -0,0 +1,9 @@
namespace LBPUnion.ProjectLighthouse.Types.Entities.Activity;
/// <summary>
/// Supported event types: HeartUser, UnheartUser
/// </summary>
public class UserActivityEntity : ActivityEntity
{
}