using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using EntityFrameworkCore.Projectables; using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Core.Database.Tables; [Table("instance")] [Index("CaughtAt")] [Index("IsSuspended")] [Index("Host", IsUnique = true)] public class Instance { [Key] [Column("id")] [StringLength(32)] public string Id { get; set; } = null!; /// /// The caught date of the Instance. /// [Column("caughtAt")] public DateTime CaughtAt { get; set; } /// /// The host of the Instance. /// [Column("host")] [StringLength(512)] public string Host { get; set; } = null!; /// /// The count of the users of the Instance. /// [Column("usersCount")] public int UsersCount { get; set; } /// /// The count of the notes of the Instance. /// [Column("notesCount")] public int NotesCount { get; set; } [Column("incomingFollows")] public int IncomingFollows { get; set; } [Column("outgoingFollows")] public int OutgoingFollows { get; set; } [Column("latestRequestSentAt")] public DateTime? LatestRequestSentAt { get; set; } [Column("latestStatus")] public int? LatestStatus { get; set; } [Column("latestRequestReceivedAt")] public DateTime? LatestRequestReceivedAt { get; set; } [Column("lastCommunicatedAt")] public DateTime LastCommunicatedAt { get; set; } [Column("isNotResponding")] public bool IsNotResponding { get; set; } /// /// The software of the Instance. /// [Column("softwareName")] [StringLength(64)] public string? SoftwareName { get; set; } [Column("softwareVersion")] [StringLength(64)] public string? SoftwareVersion { get; set; } [Column("openRegistrations")] public bool? OpenRegistrations { get; set; } [Column("name")] [StringLength(256)] public string? Name { get; set; } [Column("description")] [StringLength(4096)] public string? Description { get; set; } [Column("maintainerName")] [StringLength(128)] public string? MaintainerName { get; set; } [Column("maintainerEmail")] [StringLength(256)] public string? MaintainerEmail { get; set; } [Column("infoUpdatedAt")] public DateTime? InfoUpdatedAt { get; set; } [Column("isSuspended")] public bool IsSuspended { get; set; } [Column("iconUrl")] [StringLength(4096)] public string? IconUrl { get; set; } [Column("themeColor")] [StringLength(64)] public string? ThemeColor { get; set; } [Column("faviconUrl")] [StringLength(4096)] public string? FaviconUrl { get; set; } [NotMapped] [Projectable] public bool NeedsUpdate => InfoUpdatedAt == null || InfoUpdatedAt < DateTime.Now - TimeSpan.FromHours(24); }