chore: bump to v1.5.9 - clickable sidebar items

This commit is contained in:
2026-06-17 10:20:11 +10:00
parent 18093516ed
commit 64251d0ca9
+3 -19
View File
@@ -9,12 +9,8 @@ namespace Disco.Plugins.ServiceTracker.Services
{ {
public class ServiceTrackerService public class ServiceTrackerService
{ {
public const string PluginVersion = "1.5.8"; public const string PluginVersion = "1.5.9";
/// <summary>
/// Status values that mean a ticket is closed/done. Checked against the saved StatusOverride
/// for NTT tickets so that manually resolved/dismissed sheet jobs don't reappear.
/// </summary>
private static readonly string[] ClosedStatusKeywords = new[] { "resolved", "dismissed", "complete", "closed", "done", "cancel", "finished" }; private static readonly string[] ClosedStatusKeywords = new[] { "resolved", "dismissed", "complete", "closed", "done", "cancel", "finished" };
private readonly DiscoDataContext _database; private readonly DiscoDataContext _database;
@@ -25,12 +21,10 @@ namespace Disco.Plugins.ServiceTracker.Services
public DashboardViewModel BuildDashboard(string filterPriority = null, string filterLocation = null, string filterStatus = null, string filterTech = null, string sortBy = "newest") public DashboardViewModel BuildDashboard(string filterPriority = null, string filterLocation = null, string filterStatus = null, string filterTech = null, string sortBy = "newest")
{ {
// --- Cache check: return cached model if data files haven't changed ---
var filterKey = (filterPriority ?? "") + "|" + (filterLocation ?? "") + "|" + (filterStatus ?? "") + "|" + (filterTech ?? ""); var filterKey = (filterPriority ?? "") + "|" + (filterLocation ?? "") + "|" + (filterStatus ?? "") + "|" + (filterTech ?? "");
var cached = DashboardCache.GetIfValid(_dataStore.DataDirectory, sortBy, filterKey); var cached = DashboardCache.GetIfValid(_dataStore.DataDirectory, sortBy, filterKey);
if (cached != null) return cached; if (cached != null) return cached;
// --- Full rebuild ---
var tiles = new List<DashboardTile>(); string sheetError = null; var tiles = new List<DashboardTile>(); string sheetError = null;
var openJobs = _database.Jobs.Include("Device").Include("Device.DeviceModel").Include("User").Include("OpenedTechUser").Include("JobType").Include("JobSubTypes").Where(j => j.ClosedDate == null).ToList(); var openJobs = _database.Jobs.Include("Device").Include("Device.DeviceModel").Include("User").Include("OpenedTechUser").Include("JobType").Include("JobSubTypes").Where(j => j.ClosedDate == null).ToList();
var allTickets = _dataStore.LoadAllTickets(); var ticketLookup = allTickets.ToDictionary(t => t.JobId, t => t); var allTickets = _dataStore.LoadAllTickets(); var ticketLookup = allTickets.ToDictionary(t => t.JobId, t => t);
@@ -50,9 +44,6 @@ namespace Disco.Plugins.ServiceTracker.Services
foreach (var e in sr.Tickets) foreach (var e in sr.Tickets)
{ {
ServiceTicket st; el.TryGetValue(e.InternalId, out st); ServiceTicket st; el.TryGetValue(e.InternalId, out st);
// Skip if the ticket has been manually closed/resolved/dismissed in the tracker,
// even if the sheet row still appears open.
if (st != null && !string.IsNullOrEmpty(st.StatusOverride)) if (st != null && !string.IsNullOrEmpty(st.StatusOverride))
{ {
var ov = st.StatusOverride.ToLower().Trim(); var ov = st.StatusOverride.ToLower().Trim();
@@ -60,7 +51,6 @@ namespace Disco.Plugins.ServiceTracker.Services
foreach (var kw in ClosedStatusKeywords) { if (ov.Contains(kw)) { manuallyClosed = true; break; } } foreach (var kw in ClosedStatusKeywords) { if (ov.Contains(kw)) { manuallyClosed = true; break; } }
if (manuallyClosed) continue; if (manuallyClosed) continue;
} }
if (st == null) if (st == null)
{ st = new ServiceTicket { JobId = e.InternalId, Source = "ntt", PriorityId = GoogleSheetService.MapPriority(e.RawPriority), LocationId = _config.DefaultLocationId, AssignedTechId = ResolveSheetTech(e.AssignedTo), Summary = e.IssueDescription, EstimatedCompletion = e.PreferredDate, CreatedDate = e.Timestamp, LastModifiedDate = DateTime.Now }; _dataStore.SaveExternalTicket(st); el[e.InternalId] = st; } { st = new ServiceTicket { JobId = e.InternalId, Source = "ntt", PriorityId = GoogleSheetService.MapPriority(e.RawPriority), LocationId = _config.DefaultLocationId, AssignedTechId = ResolveSheetTech(e.AssignedTo), Summary = e.IssueDescription, EstimatedCompletion = e.PreferredDate, CreatedDate = e.Timestamp, LastModifiedDate = DateTime.Now }; _dataStore.SaveExternalTicket(st); el[e.InternalId] = st; }
tiles.Add(BuildSheetTile(e, st)); sheetCount++; tiles.Add(BuildSheetTile(e, st)); sheetCount++;
@@ -88,8 +78,6 @@ namespace Disco.Plugins.ServiceTracker.Services
} }
var stats = BuildStats(main); stats.FromGoogleSheet = sheetCount; var stats = BuildStats(main); stats.FromGoogleSheet = sheetCount;
var result = new DashboardViewModel { Tiles = main, ReadyForReturn = rfr, OnHold = onHold, AwaitingVendor = awaitingVendor, AwaitingParts = awaitingParts, Stats = stats, Config = _config, CurrentFilter = filterPriority ?? filterLocation ?? filterStatus ?? "", SortBy = sortBy, GoogleSheetError = sheetError }; var result = new DashboardViewModel { Tiles = main, ReadyForReturn = rfr, OnHold = onHold, AwaitingVendor = awaitingVendor, AwaitingParts = awaitingParts, Stats = stats, Config = _config, CurrentFilter = filterPriority ?? filterLocation ?? filterStatus ?? "", SortBy = sortBy, GoogleSheetError = sheetError };
// --- Store in cache ---
DashboardCache.Store(result, _dataStore.DataDirectory, sortBy, filterKey); DashboardCache.Store(result, _dataStore.DataDirectory, sortBy, filterKey);
return result; return result;
} }
@@ -121,20 +109,16 @@ namespace Disco.Plugins.ServiceTracker.Services
var now = DateTime.Now; var now = DateTime.Now;
var pid = st != null ? st.PriorityId : GoogleSheetService.MapPriority(ext.RawPriority); var pid = st != null ? st.PriorityId : GoogleSheetService.MapPriority(ext.RawPriority);
var pri = _config.Priorities.FirstOrDefault(p => p.Id == pid) ?? _config.Priorities.FirstOrDefault(); var pri = _config.Priorities.FirstOrDefault(p => p.Id == pid) ?? _config.Priorities.FirstOrDefault();
var lid = st != null ? st.LocationId : null; var lid = st != null ? st.LocationId : null;
string rawSheetLocation = null; string rawSheetLocation = null;
if (string.IsNullOrEmpty(lid) && !string.IsNullOrEmpty(ext.Location)) if (string.IsNullOrEmpty(lid) && !string.IsNullOrEmpty(ext.Location))
{ {
var matched = MatchSheetLocation(ext.Location); var matched = MatchSheetLocation(ext.Location);
if (matched != null) if (matched != null) lid = matched.Id;
lid = matched.Id; else rawSheetLocation = ext.Location;
else
rawSheetLocation = ext.Location;
} }
if (string.IsNullOrEmpty(lid)) lid = _config.DefaultLocationId; if (string.IsNullOrEmpty(lid)) lid = _config.DefaultLocationId;
var loc = _config.Locations.FirstOrDefault(l => l.Id == lid) ?? _config.Locations.FirstOrDefault(); var loc = _config.Locations.FirstOrDefault(l => l.Id == lid) ?? _config.Locations.FirstOrDefault();
int age = ext.Timestamp > DateTime.MinValue ? (int)(now - ext.Timestamp).TotalDays : 0; int age = ext.Timestamp > DateTime.MinValue ? (int)(now - ext.Timestamp).TotalDays : 0;
var tid = st != null ? st.AssignedTechId : ResolveSheetTech(ext.AssignedTo); var tid = st != null ? st.AssignedTechId : ResolveSheetTech(ext.AssignedTo);
string ln = null; int nc = 0; string ln = null; int nc = 0;