a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/razor] Use DatabaseContext from AdminComponentBase for queue pages

authored by

pancakes and committed by
Laura Hausmann
96f7bbff b63c54ae

+16 -18
+14 -15
Iceshrimp.Backend/Pages/Queue/Queue.razor.cs
··· 1 1 using System.Collections.Immutable; 2 2 using Iceshrimp.Backend.Components.Helpers; 3 - using Iceshrimp.Backend.Core.Database; 4 3 using Iceshrimp.Backend.Core.Database.Tables; 5 4 using Iceshrimp.Backend.Core.Middleware; 6 5 using Iceshrimp.Backend.Core.Services; ··· 10 9 11 10 namespace Iceshrimp.Backend.Pages.Queue; 12 11 13 - public partial class Queue(DatabaseContext db, QueueService queueSvc, CacheService cache) : AdminComponentBase 12 + public partial class Queue(QueueService queueSvc, CacheService cache) : AdminComponentBase 14 13 { 15 14 [Parameter] public string? Name { get; set; } 16 15 [Parameter] public int? Pagination { get; set; } ··· 43 42 if (Name == null) 44 43 { 45 44 // Should be 15, but the table styles look more pleasing with even numbers 46 - Jobs = await db.Jobs.OrderByDescending(p => p.LastUpdatedAt).Take(16).ToListAsync(); 45 + Jobs = await Database.Jobs.OrderByDescending(p => p.LastUpdatedAt).Take(16).ToListAsync(); 47 46 if (Context.Request.Query.TryGetValue("last", out var last) && long.TryParse(last, out var parsed)) 48 47 Last = parsed; 49 48 50 49 //TODO: write an expression generator for the job count calculation 51 - QueueStatuses = await db.Jobs 50 + QueueStatuses = await Database.Jobs 52 51 .GroupBy(job => job.Queue) 53 52 .OrderBy(p => p.Key) 54 53 .Select(p => p.Key) ··· 58 57 JobCounts = new Dictionary<Job.JobStatus, int> 59 58 { 60 59 { 61 - Job.JobStatus.Queued, db.Jobs.Count(job => 60 + Job.JobStatus.Queued, Database.Jobs.Count(job => 62 61 job.Queue == queueName 63 62 && job.Status 64 63 == Job.JobStatus.Queued) 65 64 }, 66 65 { 67 - Job.JobStatus.Delayed, db.Jobs.Count(job => 66 + Job.JobStatus.Delayed, Database.Jobs.Count(job => 68 67 job.Queue == queueName && job.Status == Job.JobStatus.Delayed) 69 68 }, 70 69 { 71 - Job.JobStatus.Running, db.Jobs.Count(job => 70 + Job.JobStatus.Running, Database.Jobs.Count(job => 72 71 job.Queue == queueName && job.Status == Job.JobStatus.Running) 73 72 }, 74 73 { 75 - Job.JobStatus.Completed, db.Jobs.Count(job => 74 + Job.JobStatus.Completed, Database.Jobs.Count(job => 76 75 job.Queue == queueName 77 76 && job.Status == Job.JobStatus.Completed) 78 77 }, 79 78 { 80 - Job.JobStatus.Failed, db.Jobs.Count(job => 79 + Job.JobStatus.Failed, Database.Jobs.Count(job => 81 80 job.Queue == queueName 82 81 && job.Status 83 82 == Job.JobStatus.Failed) ··· 87 86 .ToListAsync(); 88 87 89 88 TopDelayed = await _cache.FetchAsync("top-delayed", TimeSpan.FromSeconds(60), 90 - () => db.GetDelayedDeliverTargets().ToListAsync()); 89 + () => Database.GetDelayedDeliverTargets().ToListAsync()); 91 90 92 91 return; 93 92 } ··· 98 97 if (Pagination is null or < 1) 99 98 Pagination = 1; 100 99 101 - var query = db.Jobs.Where(p => p.Queue == Name); 100 + var query = Database.Jobs.Where(p => p.Queue == Name); 102 101 if (Status is { Length: > 0 }) 103 102 { 104 103 if (!Enum.TryParse<Job.JobStatus>(Status, true, out var jobStatus)) ··· 114 113 115 114 if (Filter == null) 116 115 { 117 - TotalCount = await db.Jobs.CountAsync(p => p.Queue == Name); 118 - QueuedCount = await db.Jobs.CountAsync(p => p.Queue == Name && p.Status == Job.JobStatus.Queued); 119 - RunningCount = await db.Jobs.CountAsync(p => p.Queue == Name && p.Status == Job.JobStatus.Running); 120 - DelayedCount = await db.Jobs.CountAsync(p => p.Queue == Name && p.Status == Job.JobStatus.Delayed); 116 + TotalCount = await Database.Jobs.CountAsync(p => p.Queue == Name); 117 + QueuedCount = await Database.Jobs.CountAsync(p => p.Queue == Name && p.Status == Job.JobStatus.Queued); 118 + RunningCount = await Database.Jobs.CountAsync(p => p.Queue == Name && p.Status == Job.JobStatus.Running); 119 + DelayedCount = await Database.Jobs.CountAsync(p => p.Queue == Name && p.Status == Job.JobStatus.Delayed); 121 120 } 122 121 else 123 122 {
+2 -3
Iceshrimp.Backend/Pages/Queue/QueueJob.razor.cs
··· 1 1 using Iceshrimp.Backend.Components.Helpers; 2 - using Iceshrimp.Backend.Core.Database; 3 2 using Iceshrimp.Backend.Core.Database.Tables; 4 3 using Iceshrimp.Backend.Core.Middleware; 5 4 using Microsoft.AspNetCore.Components; ··· 7 6 8 7 namespace Iceshrimp.Backend.Pages.Queue; 9 8 10 - public partial class QueueJob(DatabaseContext db) : AdminComponentBase 9 + public partial class QueueJob : AdminComponentBase 11 10 { 12 11 [Parameter] public required Guid Id { get; set; } 13 12 ··· 22 21 23 22 protected override async Task OnInitializedAsync() 24 23 { 25 - JobDetails = await db.Jobs.FirstOrDefaultAsync(p => p.Id == Id) ?? 24 + JobDetails = await Database.Jobs.FirstOrDefaultAsync(p => p.Id == Id) ?? 26 25 throw GracefulException.NotFound($"Job {Id} not found"); 27 26 } 28 27 }