Bump version to 1.0.51
This commit is contained in:
+28
-16
@@ -6,16 +6,18 @@ import (
|
||||
)
|
||||
|
||||
type Job struct {
|
||||
ID int64 `db:"id" json:"id"`
|
||||
SyncPairID int64 `db:"sync_pair_id" json:"sync_pair_id"`
|
||||
TriggerType string `db:"trigger_type" json:"trigger_type"`
|
||||
Status string `db:"status" json:"status"`
|
||||
StartedAt *time.Time `db:"started_at" json:"started_at"`
|
||||
FinishedAt *time.Time `db:"finished_at" json:"finished_at"`
|
||||
LogFile *string `db:"log_file" json:"log_file"`
|
||||
ErrorMessage *string `db:"error_message" json:"error_message,omitempty"`
|
||||
ErrorCode *string `db:"error_code" json:"error_code,omitempty"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
ID int64 `db:"id" json:"id"`
|
||||
SyncPairID int64 `db:"sync_pair_id" json:"sync_pair_id"`
|
||||
TriggerType string `db:"trigger_type" json:"trigger_type"`
|
||||
Status string `db:"status" json:"status"`
|
||||
StartedAt *time.Time `db:"started_at" json:"started_at"`
|
||||
FinishedAt *time.Time `db:"finished_at" json:"finished_at"`
|
||||
LogFile *string `db:"log_file" json:"log_file"`
|
||||
ErrorMessage *string `db:"error_message" json:"error_message,omitempty"`
|
||||
ErrorCode *string `db:"error_code" json:"error_code,omitempty"`
|
||||
TotalSizeBytes int64 `db:"total_size_bytes" json:"total_size_bytes,omitempty"`
|
||||
SentBytes int64 `db:"sent_bytes" json:"sent_bytes,omitempty"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
}
|
||||
|
||||
type JobRepository struct {
|
||||
@@ -43,9 +45,10 @@ func (r *JobRepository) GetByID(id int64) (*Job, error) {
|
||||
var logFile, errMsg, errCode sql.NullString
|
||||
err := r.db.QueryRow(`
|
||||
SELECT id, sync_pair_id, trigger_type, status, started_at, finished_at,
|
||||
log_file, error_message, error_code, created_at FROM jobs WHERE id = ?`, id).Scan(
|
||||
log_file, error_message, error_code, total_size_bytes, sent_bytes, created_at
|
||||
FROM jobs WHERE id = ?`, id).Scan(
|
||||
&j.ID, &j.SyncPairID, &j.TriggerType, &j.Status, &started, &finished,
|
||||
&logFile, &errMsg, &errCode, &j.CreatedAt)
|
||||
&logFile, &errMsg, &errCode, &j.TotalSizeBytes, &j.SentBytes, &j.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -70,7 +73,7 @@ func (r *JobRepository) GetByID(id int64) (*Job, error) {
|
||||
func (r *JobRepository) GetAll(limit, offset int) ([]Job, error) {
|
||||
rows, err := r.db.Query(`
|
||||
SELECT id, sync_pair_id, trigger_type, status, started_at, finished_at,
|
||||
log_file, error_message, error_code, created_at
|
||||
log_file, error_message, error_code, total_size_bytes, sent_bytes, created_at
|
||||
FROM jobs ORDER BY created_at DESC LIMIT ? OFFSET ?`,
|
||||
limit, offset)
|
||||
if err != nil {
|
||||
@@ -84,7 +87,8 @@ func (r *JobRepository) GetAll(limit, offset int) ([]Job, error) {
|
||||
var started, finished sql.NullTime
|
||||
var logFile, errMsg, errCode sql.NullString
|
||||
if err := rows.Scan(&j.ID, &j.SyncPairID, &j.TriggerType, &j.Status,
|
||||
&started, &finished, &logFile, &errMsg, &errCode, &j.CreatedAt); err != nil {
|
||||
&started, &finished, &logFile, &errMsg, &errCode,
|
||||
&j.TotalSizeBytes, &j.SentBytes, &j.CreatedAt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if started.Valid {
|
||||
@@ -144,11 +148,11 @@ func (r *JobRepository) GetRunningBySyncPair(syncPairID int64) (*Job, error) {
|
||||
var logFile, errMsg, errCode sql.NullString
|
||||
err := r.db.QueryRow(`
|
||||
SELECT id, sync_pair_id, trigger_type, status, started_at, finished_at,
|
||||
log_file, error_message, error_code, created_at FROM jobs
|
||||
log_file, error_message, error_code, total_size_bytes, sent_bytes, created_at FROM jobs
|
||||
WHERE sync_pair_id = ? AND status IN ('queued','waking_up','running')
|
||||
ORDER BY created_at DESC LIMIT 1`, syncPairID).Scan(
|
||||
&j.ID, &j.SyncPairID, &j.TriggerType, &j.Status, &started,
|
||||
&j.FinishedAt, &logFile, &errMsg, &errCode, &j.CreatedAt)
|
||||
&j.FinishedAt, &logFile, &errMsg, &errCode, &j.TotalSizeBytes, &j.SentBytes, &j.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -180,3 +184,11 @@ func (r *JobRepository) DeleteFinishedBefore(before time.Time) (int64, error) {
|
||||
}
|
||||
return res.RowsAffected()
|
||||
}
|
||||
|
||||
func (r *JobRepository) SetTotals(id int64, totalSize, sentBytes int64) error {
|
||||
_, err := r.db.Exec(
|
||||
"UPDATE jobs SET total_size_bytes = ?, sent_bytes = ? WHERE id = ?",
|
||||
totalSize, sentBytes, id,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user