pull/733/head
Jamie.Rees 8 years ago
parent cb11267fd2
commit 9f41a511cd

@ -12,6 +12,6 @@ namespace PlexRequests.Core.Queue
IEnumerable<RequestQueue> GetQueue(); IEnumerable<RequestQueue> GetQueue();
Task<IEnumerable<RequestQueue>> GetQueueAsync(); Task<IEnumerable<RequestQueue>> GetQueueAsync();
void QueueItem(RequestedModel request, string id, RequestType type, FaultType faultType); void QueueItem(RequestedModel request, string id, RequestType type, FaultType faultType);
Task QueueItemAsync(RequestedModel request, string id, RequestType type, FaultType faultType); Task QueueItemAsync(RequestedModel request, string id, RequestType type, FaultType faultType, string message = null);
} }
} }

@ -74,7 +74,7 @@ namespace PlexRequests.Core.Queue
RequestQueue.Insert(queue); RequestQueue.Insert(queue);
} }
public async Task QueueItemAsync(RequestedModel request, string id, RequestType type, FaultType faultType) public async Task QueueItemAsync(RequestedModel request, string id, RequestType type, FaultType faultType, string description = null)
{ {
//Ensure there is not a duplicate queued item //Ensure there is not a duplicate queued item
var existingItem = await RequestQueue.CustomAsync(async connection => var existingItem = await RequestQueue.CustomAsync(async connection =>
@ -96,7 +96,8 @@ namespace PlexRequests.Core.Queue
Type = type, Type = type,
Content = ByteConverterHelper.ReturnBytes(request), Content = ByteConverterHelper.ReturnBytes(request),
PrimaryIdentifier = id, PrimaryIdentifier = id,
FaultType = faultType FaultType = faultType,
Message = description ?? string.Empty
}; };
await RequestQueue.InsertAsync(queue); await RequestQueue.InsertAsync(queue);
} }

@ -41,6 +41,7 @@ namespace PlexRequests.Store.Models
public FaultType FaultType { get; set; } public FaultType FaultType { get; set; }
public DateTime? LastRetry { get; set; } public DateTime? LastRetry { get; set; }
public string Message { get; set; }
} }
public enum FaultType public enum FaultType

@ -146,7 +146,8 @@ CREATE TABLE IF NOT EXISTS RequestFaultQueue
Type INTEGER NOT NULL, Type INTEGER NOT NULL,
FaultType INTEGER NOT NULL, FaultType INTEGER NOT NULL,
Content BLOB NOT NULL, Content BLOB NOT NULL,
LastRetry VARCHAR(100) LastRetry VARCHAR(100),
Description VARCHAR(100)
); );
CREATE UNIQUE INDEX IF NOT EXISTS PlexUsers_Id ON PlexUsers (Id); CREATE UNIQUE INDEX IF NOT EXISTS PlexUsers_Id ON PlexUsers (Id);

@ -39,6 +39,7 @@ namespace PlexRequests.UI.Models
public string Title { get; set; } public string Title { get; set; }
public FaultTypeViewModel FaultType { get; set; } public FaultTypeViewModel FaultType { get; set; }
public DateTime? LastRetry { get; set; } public DateTime? LastRetry { get; set; }
public string Message { get; set; }
} }
public enum RequestTypeViewModel public enum RequestTypeViewModel

@ -65,7 +65,8 @@ namespace PlexRequests.UI.Modules.Admin
Title = ByteConverterHelper.ReturnObject<RequestedModel>(r.Content).Title, Title = ByteConverterHelper.ReturnObject<RequestedModel>(r.Content).Title,
Id = r.Id, Id = r.Id,
PrimaryIdentifier = r.PrimaryIdentifier, PrimaryIdentifier = r.PrimaryIdentifier,
LastRetry = r.LastRetry LastRetry = r.LastRetry,
Message = r.Message
}).ToList(); }).ToList();
return View["RequestFaultQueue", model]; return View["RequestFaultQueue", model];

@ -595,7 +595,7 @@ namespace PlexRequests.UI.Modules
catch (Exception e) catch (Exception e)
{ {
Log.Fatal(e); Log.Fatal(e);
await FaultQueue.QueueItemAsync(model, movieInfo.Id.ToString(), RequestType.Movie, FaultType.RequestFault); await FaultQueue.QueueItemAsync(model, movieInfo.Id.ToString(), RequestType.Movie, FaultType.RequestFault, e.Message);
await NotificationService.Publish(new NotificationModel await NotificationService.Publish(new NotificationModel
{ {
@ -866,7 +866,7 @@ namespace PlexRequests.UI.Modules
if (showInfo.externals?.thetvdb == null) if (showInfo.externals?.thetvdb == null)
{ {
await FaultQueue.QueueItemAsync(model, showInfo.id.ToString(), RequestType.TvShow, FaultType.MissingInformation); await FaultQueue.QueueItemAsync(model, showInfo.id.ToString(), RequestType.TvShow, FaultType.MissingInformation, "We do not have a TheTVDBId from TVMaze");
await NotificationService.Publish(new NotificationModel await NotificationService.Publish(new NotificationModel
{ {
DateTime = DateTime.Now, DateTime = DateTime.Now,
@ -941,7 +941,7 @@ namespace PlexRequests.UI.Modules
} }
catch (Exception e) catch (Exception e)
{ {
await FaultQueue.QueueItemAsync(model, showInfo.id.ToString(), RequestType.TvShow, FaultType.RequestFault); await FaultQueue.QueueItemAsync(model, showInfo.id.ToString(), RequestType.TvShow, FaultType.RequestFault, e.Message);
await NotificationService.Publish(new NotificationModel await NotificationService.Publish(new NotificationModel
{ {
DateTime = DateTime.Now, DateTime = DateTime.Now,
@ -1116,7 +1116,7 @@ namespace PlexRequests.UI.Modules
catch (Exception e) catch (Exception e)
{ {
Log.Error(e); Log.Error(e);
await FaultQueue.QueueItemAsync(model, albumInfo.id, RequestType.Album, FaultType.RequestFault); await FaultQueue.QueueItemAsync(model, albumInfo.id, RequestType.Album, FaultType.RequestFault, e.Message);
await NotificationService.Publish(new NotificationModel await NotificationService.Publish(new NotificationModel
{ {

@ -20,6 +20,9 @@
<th> <th>
LastRetry LastRetry
</th> </th>
<th>
Error Description
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -39,6 +42,9 @@
<td> <td>
@m.LastRetry @m.LastRetry
</td> </td>
<td>
@m.Message
</td>
</tr> </tr>
} }
</tbody> </tbody>

Loading…
Cancel
Save