Skip to content

Commit ff758db

Browse files
committed
TD-4154- Applied retry logic for the UPDATE statement when the process is busy with the previous execution. Added condition to show achievement only after passing any section.
1 parent c3e63fb commit ff758db

File tree

3 files changed

+92
-68
lines changed

3 files changed

+92
-68
lines changed

DigitalLearningSolutions.Data/DataServices/SessionDataService.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,29 @@ public void StopDelegateSession(int candidateId)
5757

5858
public int UpdateDelegateSessionDuration(int sessionId, DateTime currentUtcTime)
5959
{
60-
return connection.Execute(
61-
@"UPDATE Sessions SET Duration = DATEDIFF(minute, LoginTime, @currentUtcTime)
62-
WHERE [SessionID] = @sessionId AND Active = 1;",
63-
new { sessionId, currentUtcTime }
64-
);
60+
int retryCount = 3;
61+
bool success = false;
62+
var rowsCount = 0;
63+
while (retryCount > 0 && !success)
64+
{
65+
try
66+
{
67+
rowsCount = connection.Execute(
68+
@"UPDATE Sessions SET Duration = DATEDIFF(minute, LoginTime, @currentUtcTime)
69+
WHERE [SessionID] = @sessionId AND Active = 1;",
70+
new { sessionId, currentUtcTime });
71+
success = true;
72+
}
73+
catch (Exception)
74+
{
75+
retryCount--;
76+
if (retryCount == 0)
77+
{
78+
throw;
79+
}
80+
}
81+
}
82+
return rowsCount;
6583
}
6684

6785
public int StartAdminSession(int adminId)

DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/DelegateProgress/DownloadProgress.cshtml

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -254,32 +254,35 @@
254254
}
255255
</tbody>
256256
</table>
257-
<h2 class="heading2">Achievements</h2>
258-
<h4 class="heading4">The following post learning assessments have been passed:</h4>
259-
<br />
260-
<table role="table" class="table table-striped nhsuk-lede-text--small">
261-
<tr>
262-
<th align="left">
263-
Assessment
264-
</th>
265-
<th align="left">
266-
Outcome
267-
</th>
268-
</tr>
269-
<tbody>
270-
@foreach (var entry in Model.SectionDetails.Where(pass => pass.PLPassed))
271-
{
272-
<tr>
273-
<td>
274-
@entry.SectionName
275-
</td>
276-
<td style="color:#0e6935;font-weight:normal;">
277-
@("PASSED")
278-
</td>
279-
</tr>
280-
}
281-
</tbody>
282-
</table>
257+
@if (Model.SectionDetails.Where(pass => pass.PLPassed).Any())
258+
{
259+
<h2 class="heading2">Achievements</h2>
260+
<h4 class="heading4">The following post learning assessments have been passed:</h4>
261+
<br />
262+
<table role="table" class="table table-striped nhsuk-lede-text--small">
263+
<tr>
264+
<th align="left">
265+
Assessment
266+
</th>
267+
<th align="left">
268+
Outcome
269+
</th>
270+
</tr>
271+
<tbody>
272+
@foreach (var entry in Model.SectionDetails.Where(pass => pass.PLPassed))
273+
{
274+
<tr>
275+
<td>
276+
@entry.SectionName
277+
</td>
278+
<td style="color:#0e6935;font-weight:normal;">
279+
@("PASSED")
280+
</td>
281+
</tr>
282+
}
283+
</tbody>
284+
</table>
285+
}
283286
</div>
284287
</div>
285288
</div>

DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/DelegateProgress/ViewDelegateProgress.cshtml

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
}
4343
4444
/*.p-4 {
45-
padding: 1.5rem !important
46-
}
45+
padding: 1.5rem !important
46+
}
4747
48-
#Logo {
49-
max-width: 500px;
50-
max-height: 90px;
51-
height: auto;
52-
width: auto;
53-
}*/
48+
#Logo {
49+
max-width: 500px;
50+
max-height: 90px;
51+
height: auto;
52+
width: auto;
53+
}*/
5454
5555
.heading2 {
5656
font-size: 2rem;
@@ -212,36 +212,39 @@
212212
}
213213
</tbody>
214214
</table>
215-
<div style="height:20px"></div>
216-
<h2 class="heading2">Achievements</h2>
217-
<h4 class="heading4">The following post learning assessments have been passed:</h4>
218-
<table class="nhsuk-table-responsive">
219-
<thead class="nhsuk-table__head">
220-
<tr class="nhsuk-table__row" role="row">
221-
<th class="nhsuk-table__header" role="columnheader" scope="col">
222-
Assessment
223-
</th>
224-
<th class="nhsuk-table__header" role="columnheader" scope="col">
225-
Outcome
226-
</th>
227-
</tr>
228-
</thead>
229-
<tbody class="nhsuk-table__body">
230-
@foreach (var entry in Model.SectionDetails.Where(pass => pass.PLPassed))
231-
{
232-
<tr class="nhsuk-table__row">
233-
<td class="nhsuk-table__cell" data-label="Assessment" role="cell">
234-
<span class="nhsuk-table-responsive__heading">Assessment</span>
235-
@entry.SectionName
236-
</td>
237-
<td class="nhsuk-table__cell" data-label="Outcome" role="cell">
238-
<span class="nhsuk-table-responsive__heading">Outcome</span>
239-
<span style="color:#0e6935;font-weight:normal;">@("PASSED")</span>
240-
</td>
215+
@if (Model.SectionDetails.Where(pass => pass.PLPassed).Any())
216+
{
217+
<div style="height:20px"></div>
218+
<h2 class="heading2">Achievements</h2>
219+
<h4 class="heading4">The following post learning assessments have been passed:</h4>
220+
<table class="nhsuk-table-responsive">
221+
<thead class="nhsuk-table__head">
222+
<tr class="nhsuk-table__row" role="row">
223+
<th class="nhsuk-table__header" role="columnheader" scope="col">
224+
Assessment
225+
</th>
226+
<th class="nhsuk-table__header" role="columnheader" scope="col">
227+
Outcome
228+
</th>
241229
</tr>
242-
}
243-
</tbody>
244-
</table>
230+
</thead>
231+
<tbody class="nhsuk-table__body">
232+
@foreach (var entry in Model.SectionDetails.Where(pass => pass.PLPassed))
233+
{
234+
<tr class="nhsuk-table__row">
235+
<td class="nhsuk-table__cell" data-label="Assessment" role="cell">
236+
<span class="nhsuk-table-responsive__heading">Assessment</span>
237+
@entry.SectionName
238+
</td>
239+
<td class="nhsuk-table__cell" data-label="Outcome" role="cell">
240+
<span class="nhsuk-table-responsive__heading">Outcome</span>
241+
<span style="color:#0e6935;font-weight:normal;">@("PASSED")</span>
242+
</td>
243+
</tr>
244+
}
245+
</tbody>
246+
</table>
247+
}
245248
</div>
246249
</div>
247250
</div>

0 commit comments

Comments
 (0)