Bug Fix #4: Only reference jobs where device held
This commit is contained in:
@@ -9,6 +9,6 @@ namespace Disco.Models.Services.Jobs.JobLists
|
|||||||
public class JobLocationReference
|
public class JobLocationReference
|
||||||
{
|
{
|
||||||
public string Location { get; set; }
|
public string Location { get; set; }
|
||||||
public List<JobTableItemModel> References { get; set; }
|
public List<JobTableStatusItemModel> References { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,9 +259,9 @@ namespace Disco.Services
|
|||||||
return queueItems.Where(qi => usersQueues.ContainsKey(qi.QueueId));
|
return queueItems.Where(qi => usersQueues.ContainsKey(qi.QueueId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<JobLocationReference> JobLocationReferences(this IEnumerable<JobTableItemModel> Items, IEnumerable<string> IncludeLocations)
|
public static IEnumerable<JobLocationReference> JobLocationReferences(this IEnumerable<JobTableStatusItemModel> Items, IEnumerable<string> IncludeLocations)
|
||||||
{
|
{
|
||||||
var innerItems = Items.Where(i => !string.IsNullOrWhiteSpace(i.DeviceHeldLocation));
|
var innerItems = Items.Where(i => !string.IsNullOrWhiteSpace(i.DeviceHeldLocation) && i.DeviceHeld.HasValue && !i.DeviceReturnedDate.HasValue);
|
||||||
|
|
||||||
return IncludeLocations.GroupJoin(innerItems, o => o, i => i.DeviceHeldLocation,
|
return IncludeLocations.GroupJoin(innerItems, o => o, i => i.DeviceHeldLocation,
|
||||||
(i, o) => new JobLocationReference
|
(i, o) => new JobLocationReference
|
||||||
@@ -271,9 +271,9 @@ namespace Disco.Services
|
|||||||
},
|
},
|
||||||
StringComparer.InvariantCultureIgnoreCase);
|
StringComparer.InvariantCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
public static IEnumerable<JobLocationReference> JobLocationReferences(this IEnumerable<JobTableItemModel> Items)
|
public static IEnumerable<JobLocationReference> JobLocationReferences(this IEnumerable<JobTableStatusItemModel> Items)
|
||||||
{
|
{
|
||||||
return Items.Where(i => !string.IsNullOrWhiteSpace(i.DeviceHeldLocation))
|
return Items.Where(i => !string.IsNullOrWhiteSpace(i.DeviceHeldLocation) && i.DeviceHeld.HasValue && !i.DeviceReturnedDate.HasValue)
|
||||||
.GroupBy(i => i.DeviceHeldLocation, StringComparer.InvariantCultureIgnoreCase)
|
.GroupBy(i => i.DeviceHeldLocation, StringComparer.InvariantCultureIgnoreCase)
|
||||||
.Select(i => new JobLocationReference()
|
.Select(i => new JobLocationReference()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2158,13 +2158,13 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
throw new InvalidOperationException("Unknown Location Mode Configured");
|
throw new InvalidOperationException("Unknown Location Mode Configured");
|
||||||
}
|
}
|
||||||
|
|
||||||
var locationReferences = ManagedJobList.OpenJobsTable(j => j).Items.JobLocationReferences(locations);
|
var locationReferences = ManagedJobList.OpenJobsTable(j => j).Items.Cast<JobTableStatusItemModel>().JobLocationReferences(locations);
|
||||||
|
|
||||||
var results = locationReferences.Select(locRef =>
|
var results = locationReferences.Select(locRef =>
|
||||||
{
|
{
|
||||||
string reference = null;
|
string reference = null;
|
||||||
|
|
||||||
if (locRef.References == null && locRef.References.Count > 0)
|
if (locRef.References != null && locRef.References.Count > 0)
|
||||||
{
|
{
|
||||||
if (locRef.References.Count == 1)
|
if (locRef.References.Count == 1)
|
||||||
reference = string.Format("Job {0}", locRef.References[0].JobId);
|
reference = string.Format("Job {0}", locRef.References[0].JobId);
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ namespace Disco.Web.Controllers
|
|||||||
{
|
{
|
||||||
m.LocationMode = Database.DiscoConfiguration.JobPreferences.LocationMode;
|
m.LocationMode = Database.DiscoConfiguration.JobPreferences.LocationMode;
|
||||||
if (m.LocationMode == LocationModes.RestrictedList)
|
if (m.LocationMode == LocationModes.RestrictedList)
|
||||||
m.LocationOptions = ManagedJobList.OpenJobsTable(j => j).Items.JobLocationReferences(Database.DiscoConfiguration.JobPreferences.LocationList).ToList();
|
m.LocationOptions = ManagedJobList.OpenJobsTable(j => j).Items.Cast<JobTableStatusItemModel>().JobLocationReferences(Database.DiscoConfiguration.JobPreferences.LocationList).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Extensions
|
// UI Extensions
|
||||||
|
|||||||
Reference in New Issue
Block a user