Skip to content

Commit 75425dd

Browse files
removed the unsupported createdAt and last used search sort options
1 parent 41a1f43 commit 75425dd

5 files changed

Lines changed: 8 additions & 122 deletions

File tree

DotNet/Automation.UI/Controllers/RunsController.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,7 @@ public async Task<IActionResult> Start(StartScenarioRequest request, Cancellatio
166166

167167
// Build the run request from the complete persisted scenario rather than
168168
// relying on the default hidden values submitted by the Quick Launch form.
169-
var scenarioRequest = StartScenarioRequest.FromScenario(scenario);
170-
171-
// Do not update LastUsedAt until the run has been accepted successfully.
172-
await runManager.StartAsync(scenarioRequest, cancellationToken);
173-
174-
try
175-
{
176-
scenario.LastUsedAt = DateTimeOffset.UtcNow;
177-
178-
// LastUsedAt is usage metadata, so preserve UpdatedAt. Launching a
179-
// scenario should not make it appear as recently modified.
180-
await scenarioStore.UpsertAsync(scenario, cancellationToken);
181-
}
182-
catch (Exception ex)
183-
{
184-
// The run has already started. A usage-tracking failure should not
185-
// cause the UI to report that launching the run failed.
186-
logger.LogWarning(
187-
ex,
188-
"Run started successfully, but LastUsedAt could not be updated for scenario {ScenarioId}",
189-
scenarioId);
190-
}
169+
await runManager.StartAsync(StartScenarioRequest.FromScenario(scenario), cancellationToken);
191170

192171
return RedirectToAction(nameof(Index));
193172
}

DotNet/Automation.UI/Controllers/ScenariosController.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,8 @@ public async Task<IActionResult> SaveInline([FromBody] TestScenarioDefinition mo
7878
model.NhsnOrganizationId = string.IsNullOrWhiteSpace(model.NhsnOrganizationId)
7979
? GenerateRandomNhsnOrganizationId()
8080
: model.NhsnOrganizationId.Trim();
81-
var now = DateTimeOffset.UtcNow;
82-
83-
// Preserve the original creation timestamp during edits.
84-
// Existing documents created before CreatedAt was introduced fall back to
85-
// their current UpdatedAt value.
86-
if (existing != null)
87-
{
88-
model.CreatedAt = existing.CreatedAt != default
89-
? existing.CreatedAt
90-
: existing.UpdatedAt;
91-
92-
// Last-used information is operational metadata and should not be
93-
// overwritten by an editor payload that does not include it.
94-
model.LastUsedAt = existing.LastUsedAt;
95-
}
96-
else
97-
{
98-
model.CreatedAt = now;
99-
}
100-
101-
model.UpdatedAt = now;
81+
82+
model.UpdatedAt = DateTimeOffset.UtcNow;
10283

10384
await scenarioStore.UpsertAsync(model, ct);
10485
return Json(new { id = model.Id });
@@ -473,9 +454,7 @@ public async Task<IActionResult> CloneInline([FromBody] IdRequest request, Cance
473454
DetectedClinicalScenarioId = p.DetectedClinicalScenarioId
474455
})
475456
.ToList(),
476-
CreatedAt = DateTimeOffset.UtcNow,
477-
UpdatedAt = DateTimeOffset.UtcNow,
478-
LastUsedAt = null
457+
UpdatedAt = DateTimeOffset.UtcNow
479458
};
480459

481460
await scenarioStore.UpsertAsync(clone, ct);

DotNet/Automation.UI/Models/TestScenarioDefinition.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,6 @@ public class TestScenarioDefinition
124124
/// </summary>
125125
public List<ImportedPatientInput> ImportedPatientBundles { get; set; } = [];
126126

127-
/// <summary>When the scenario was originally created.</summary>
128-
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
129-
130-
131127
/// <summary>When the scenario was created or last updated.</summary>
132128
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
133-
134-
/// <summary>
135-
/// When the scenario was most recently launched.
136-
/// Null means it has never been used.
137-
/// </summary>
138-
public DateTimeOffset? LastUsedAt { get; set; }
139129
}

DotNet/Automation.UI/Views/Runs/Index.cshtml

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@
165165
<select id="quickLaunchSort"
166166
class="form-select form-select-sm">
167167
<option value="name">Alphabetical</option>
168-
<option value="lastUsed">Recently Used</option>
169168
<option value="updated">Recently Modified</option>
170-
<option value="created">Created Date</option>
171169
</select>
172170
</div>
173171
</div>
@@ -197,9 +195,7 @@
197195
data-method="@s.ReportMethod"
198196
data-type="Custom"
199197
data-measures="@string.Join(" ", s.SelectedMeasures.Select(ProfiledMeasureCatalog.GetDisplayName))"
200-
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()"
201-
data-created="@((s.CreatedAt != default ? s.CreatedAt : s.UpdatedAt).ToUnixTimeMilliseconds())"
202-
data-last-used="@(s.LastUsedAt?.ToUnixTimeMilliseconds() ?? 0)">
198+
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()">
203199
@s.Name
204200
</button>
205201
}
@@ -218,9 +214,7 @@
218214
data-method="@s.ReportMethod"
219215
data-type="System"
220216
data-measures="@string.Join(" ", s.SelectedMeasures.Select(ProfiledMeasureCatalog.GetDisplayName))"
221-
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()"
222-
data-created="@((s.CreatedAt != default ? s.CreatedAt : s.UpdatedAt).ToUnixTimeMilliseconds())"
223-
data-last-used="@(s.LastUsedAt?.ToUnixTimeMilliseconds() ?? 0)">
217+
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()">
224218
@s.Name <span class="text-muted">[System]</span>
225219
</button>
226220
}
@@ -239,9 +233,7 @@
239233
data-method="@s.ReportMethod"
240234
data-type="@(s.IsSystemScenario ? "System" : "Custom")"
241235
data-measures="@string.Join(" ", s.SelectedMeasures.Select(ProfiledMeasureCatalog.GetDisplayName))"
242-
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()"
243-
data-created="@((s.CreatedAt != default ? s.CreatedAt : s.UpdatedAt).ToUnixTimeMilliseconds())"
244-
data-last-used="@(s.LastUsedAt?.ToUnixTimeMilliseconds() ?? 0)">
236+
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()">
245237
@s.Name@(s.IsSystemScenario ? " [System]" : "")
246238
</option>
247239
}
@@ -851,8 +843,6 @@
851843
if (hiddenOption) {
852844
hiddenOption.textContent = label;
853845
hiddenOption.dataset.name = label;
854-
855-
// Editing changes only the modification timestamp.
856846
hiddenOption.dataset.updated = now;
857847
} else if (selector) {
858848
hiddenOption = document.createElement('option');
@@ -863,9 +853,7 @@
863853
hiddenOption.dataset.method = '';
864854
hiddenOption.dataset.type = 'Custom';
865855
hiddenOption.dataset.measures = '';
866-
hiddenOption.dataset.created = now;
867856
hiddenOption.dataset.updated = now;
868-
hiddenOption.dataset.lastUsed = '0';
869857
870858
selector.appendChild(hiddenOption);
871859
}
@@ -877,8 +865,6 @@
877865
878866
if (visibleOption) {
879867
visibleOption.dataset.name = label;
880-
881-
// Editing changes only the modification timestamp.
882868
visibleOption.dataset.updated = now;
883869
visibleOption.textContent = label;
884870
} else {
@@ -897,9 +883,7 @@
897883
visibleOption.dataset.method = '';
898884
visibleOption.dataset.type = 'Custom';
899885
visibleOption.dataset.measures = '';
900-
visibleOption.dataset.created = now;
901886
visibleOption.dataset.updated = now;
902-
visibleOption.dataset.lastUsed = '0';
903887
visibleOption.textContent = label;
904888
905889
customGroup.appendChild(visibleOption);
@@ -930,31 +914,11 @@
930914
);
931915
932916
options.sort(function (a, b) {
933-
if (sortValue === 'lastUsed') {
934-
var aLastUsed = Number(a.dataset.lastUsed || 0);
935-
var bLastUsed = Number(b.dataset.lastUsed || 0);
936-
937-
if (aLastUsed !== bLastUsed) {
938-
return bLastUsed - aLastUsed;
939-
}
940-
941-
return (a.dataset.name || '').localeCompare(
942-
b.dataset.name || '',
943-
undefined,
944-
{ sensitivity: 'base' }
945-
);
946-
}
947-
948917
if (sortValue === 'updated') {
949918
return Number(b.dataset.updated || 0) -
950919
Number(a.dataset.updated || 0);
951920
}
952921
953-
if (sortValue === 'created') {
954-
return Number(b.dataset.created || 0) -
955-
Number(a.dataset.created || 0);
956-
}
957-
958922
return (a.dataset.name || '').localeCompare(
959923
b.dataset.name || '',
960924
undefined,

DotNet/Automation.UI/Views/Scenarios/Index.cshtml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
<label class="form-label" for="scenarioSort">Sort by</label>
3939
<select id="scenarioSort" class="form-select">
4040
<option value="name">Alphabetical (A–Z)</option>
41-
<option value="lastUsed">Recently Used</option>
4241
<option value="updated">Recently Modified</option>
43-
<option value="created">Created Date</option>
4442
</select>
4543
</div>
4644
</div>
@@ -84,9 +82,7 @@
8482
data-seed="@s.Seed"
8583
data-patients="@patientCount"
8684
data-resources="@resourceRange"
87-
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()"
88-
data-created="@((s.CreatedAt != default ? s.CreatedAt : s.UpdatedAt).ToUnixTimeMilliseconds())"
89-
data-last-used="@(s.LastUsedAt?.ToUnixTimeMilliseconds() ?? 0)">
85+
data-updated="@s.UpdatedAt.ToUnixTimeMilliseconds()">
9086
<td>
9187
<strong>@s.Name</strong>
9288
@if (!string.IsNullOrWhiteSpace(s.Description))
@@ -212,33 +208,11 @@
212208
});
213209
214210
rows.sort(function (a, b) {
215-
if (sortValue === 'lastUsed') {
216-
var aLastUsed = Number(a.dataset.lastUsed || 0);
217-
var bLastUsed = Number(b.dataset.lastUsed || 0);
218-
219-
// Used scenarios first, newest usage first.
220-
// Never-used scenarios are sorted alphabetically afterward.
221-
if (aLastUsed !== bLastUsed) {
222-
return bLastUsed - aLastUsed;
223-
}
224-
225-
return (a.dataset.name || '').localeCompare(
226-
b.dataset.name || '',
227-
undefined,
228-
{ sensitivity: 'base' }
229-
);
230-
}
231-
232211
if (sortValue === 'updated') {
233212
return Number(b.dataset.updated || 0) -
234213
Number(a.dataset.updated || 0);
235214
}
236215
237-
if (sortValue === 'created') {
238-
return Number(b.dataset.created || 0) -
239-
Number(a.dataset.created || 0);
240-
}
241-
242216
return (a.dataset.name || '').localeCompare(
243217
b.dataset.name || '',
244218
undefined,

0 commit comments

Comments
 (0)