Bump version to 1.0.51
This commit is contained in:
@@ -85,6 +85,19 @@ func (r *JobLogRepository) DeleteBefore(before time.Time) (int64, error) {
|
||||
return res.RowsAffected()
|
||||
}
|
||||
|
||||
func (r *JobLogRepository) TruncateKeepingHeaderTail(jobID int64, head, tail int) error {
|
||||
_, err := r.db.Exec(`
|
||||
DELETE FROM job_logs
|
||||
WHERE job_id = ?
|
||||
AND id NOT IN (
|
||||
SELECT id FROM job_logs WHERE job_id = ? ORDER BY id ASC LIMIT ?
|
||||
UNION ALL
|
||||
SELECT id FROM job_logs WHERE job_id = ? ORDER BY id DESC LIMIT ?
|
||||
)`,
|
||||
jobID, jobID, head, jobID, tail)
|
||||
return err
|
||||
}
|
||||
|
||||
type JobWithStats struct {
|
||||
Job
|
||||
DurationSeconds *int64 `db:"duration_seconds" json:"duration_seconds"`
|
||||
@@ -125,7 +138,7 @@ func (r *JobLogRepository) GetAllFiltered(limit, offset int, syncPairID *int64,
|
||||
SELECT
|
||||
j.id, j.sync_pair_id, j.trigger_type, j.status,
|
||||
j.started_at, j.finished_at, j.log_file,
|
||||
j.error_message, j.error_code, j.created_at,
|
||||
j.error_message, j.error_code, j.total_size_bytes, j.sent_bytes, j.created_at,
|
||||
CASE WHEN j.finished_at IS NOT NULL AND j.started_at IS NOT NULL
|
||||
THEN (j.finished_at - j.started_at) ELSE NULL END as duration_seconds,
|
||||
(SELECT COUNT(*) FROM job_logs WHERE job_id = j.id) as log_line_count
|
||||
@@ -148,7 +161,7 @@ func (r *JobLogRepository) GetAllFiltered(limit, offset int, syncPairID *int64,
|
||||
var durationSeconds sql.NullInt64
|
||||
if err := rows.Scan(&j.ID, &j.SyncPairID, &j.TriggerType, &j.Status,
|
||||
&started, &finished, &logFile,
|
||||
&errMsg, &errCode, &j.CreatedAt,
|
||||
&errMsg, &errCode, &j.TotalSizeBytes, &j.SentBytes, &j.CreatedAt,
|
||||
&durationSeconds, &j.LogLineCount); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user