Add error reason for failed updates
This commit is contained in:
parent
95ec14e77e
commit
6a2ba3f5b0
@ -93,9 +93,13 @@
|
||||
target_id INTEGER,
|
||||
queued_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
processed_at TIMESTAMP,
|
||||
status TEXT DEFAULT 'queued'
|
||||
status TEXT DEFAULT 'queued',
|
||||
error_reason TEXT
|
||||
)
|
||||
</cfquery>
|
||||
<cfquery datasource="#request.DS#">
|
||||
ALTER TABLE #request.logTableName# ADD COLUMN IF NOT EXISTS error_reason TEXT
|
||||
</cfquery>
|
||||
<cfquery datasource="#request.DS#">
|
||||
UPDATE #request.logTableName#
|
||||
SET processed_at = NOW(), status = 'done'
|
||||
@ -117,6 +121,16 @@
|
||||
SELECT 1 FROM #request.tableName# WHERE id = target_id
|
||||
)
|
||||
</cfquery>
|
||||
<cfquery datasource="#request.DS#">
|
||||
UPDATE #request.logTableName#
|
||||
SET status = 'failed', error_reason = 'target not found'
|
||||
WHERE status = 'queued'
|
||||
AND action = 'update'
|
||||
AND target_id IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM #request.tableName# WHERE id = target_id
|
||||
)
|
||||
</cfquery>
|
||||
<cfcatch><cfset request.db_error = cfcatch.message /></cfcatch>
|
||||
</cftry>
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
<cfset nodeworkerUrl = request.nodeworkerUrl>
|
||||
|
||||
<cfquery name="qLog" datasource="#request.DS#">
|
||||
SELECT id, action, text, request_id, target_id, queued_at, processed_at, status
|
||||
SELECT id, action, text, request_id, target_id, queued_at, processed_at, status, error_reason
|
||||
FROM #request.logTableName#
|
||||
ORDER BY id DESC
|
||||
LIMIT 20
|
||||
@ -129,9 +129,11 @@
|
||||
<th>ID</th>
|
||||
<th>Действие</th>
|
||||
<th>Текст</th>
|
||||
<th>Target</th>
|
||||
<th class="col-queued">Queued</th>
|
||||
<th class="col-processed">Processed</th>
|
||||
<th class="col-status">Статус</th>
|
||||
<th>Причина</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -140,11 +142,13 @@
|
||||
<td class="id-cell">#id#</td>
|
||||
<td>#uCase(action)#</td>
|
||||
<td>#HTMLEditFormat(text)#</td>
|
||||
<td><cfif len(target_id)>#target_id#<cfelse>-</cfif></td>
|
||||
<td>#dateTimeFormat(queued_at, "yyyy-mm-dd HH:nn:ss")#</td>
|
||||
<td><cfif len(processed_at)>#dateTimeFormat(processed_at, "yyyy-mm-dd HH:nn:ss")#<cfelse>-</cfif></td>
|
||||
<td>
|
||||
<span class="badge <cfif status EQ 'done'>badge-done<cfelse>badge-queued</cfif>">#status#</span>
|
||||
</td>
|
||||
<td><cfif len(error_reason)>#HTMLEditFormat(error_reason)#<cfelse>-</cfif></td>
|
||||
</tr>
|
||||
</cfoutput>
|
||||
</tbody>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user