Fix queue storage in the db
This commit is contained in:
@@ -51,11 +51,30 @@ namespace Step.Database.Controllers
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
public void UpdateReps(int processId, int id, int reps)
|
||||
{
|
||||
QueueItemsModel item = dbCtx.Queue.Where(x => x.Id == id && x.Process == processId).FirstOrDefault();
|
||||
// Update reps
|
||||
item.Reps = reps;
|
||||
item.RemainingReps = reps;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public void DeleteItem(int processId, int id)
|
||||
{
|
||||
QueueItemsModel item = dbCtx.Queue.Where(x => x.Id == id && x.Process == processId).FirstOrDefault();
|
||||
|
||||
dbCtx.Queue.Remove(item);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public void ReadAndPopulateQueue()
|
||||
{
|
||||
var dbQueue = dbCtx.Queue.ToList();
|
||||
|
||||
bool foundData = false;
|
||||
foreach(var entity in dbQueue)
|
||||
{
|
||||
// Check if process queue exists
|
||||
@@ -73,7 +92,13 @@ namespace Step.Database.Controllers
|
||||
Status = (QUEUE_ITEM_STATUS)entity.Status
|
||||
});
|
||||
|
||||
if((QUEUE_ITEM_STATUS)entity.Status == QUEUE_ITEM_STATUS.RUNNING)
|
||||
if ((QUEUE_ITEM_STATUS)entity.Status != QUEUE_ITEM_STATUS.FINISHED && !foundData)
|
||||
{
|
||||
QueueRunningIndexes[entity.Process] = entity.Id - 1;
|
||||
foundData = true;
|
||||
}
|
||||
|
||||
if ((QUEUE_ITEM_STATUS)entity.Status == QUEUE_ITEM_STATUS.RUNNING)
|
||||
QueueRunningIndexes[entity.Process] = entity.Id - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user