mirror of
https://github.com/datarhei/core.git
synced 2025-09-26 20:11:29 +08:00
Add updated_at field in process infos
This commit is contained in:
@@ -106,6 +106,7 @@ type Process struct {
|
||||
Reference string `json:"reference"`
|
||||
Config *Config `json:"config"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
Order string `json:"order"`
|
||||
}
|
||||
|
||||
@@ -115,6 +116,7 @@ func (process *Process) Clone() *Process {
|
||||
Reference: process.Reference,
|
||||
Config: process.Config.Clone(),
|
||||
CreatedAt: process.CreatedAt,
|
||||
UpdatedAt: process.UpdatedAt,
|
||||
Order: process.Order,
|
||||
}
|
||||
|
||||
|
@@ -456,6 +456,8 @@ func (r *restream) createTask(config *app.Config) (*task, error) {
|
||||
CreatedAt: time.Now().Unix(),
|
||||
}
|
||||
|
||||
process.UpdatedAt = process.CreatedAt
|
||||
|
||||
if config.Autostart {
|
||||
process.Order = "start"
|
||||
}
|
||||
@@ -867,6 +869,9 @@ func (r *restream) UpdateProcess(id string, config *app.Config) error {
|
||||
return ErrUnknownProcess
|
||||
}
|
||||
|
||||
// This would require a major version jump
|
||||
//t.process.CreatedAt = task.process.CreatedAt
|
||||
t.process.UpdatedAt = time.Now().Unix()
|
||||
task.parser.TransferReportHistory(t.parser)
|
||||
t.process.Order = task.process.Order
|
||||
|
||||
|
@@ -216,6 +216,14 @@ func TestUpdateProcess(t *testing.T) {
|
||||
err = rs.AddProcess(process2)
|
||||
require.Equal(t, nil, err)
|
||||
|
||||
process, err := rs.GetProcess(process2.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
//createdAt := process.CreatedAt
|
||||
updatedAt := process.UpdatedAt
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
process3 := getDummyProcess()
|
||||
require.NotNil(t, process3)
|
||||
process3.ID = "process2"
|
||||
@@ -230,8 +238,11 @@ func TestUpdateProcess(t *testing.T) {
|
||||
_, err = rs.GetProcess(process1.ID)
|
||||
require.Error(t, err)
|
||||
|
||||
_, err = rs.GetProcess(process3.ID)
|
||||
process, err = rs.GetProcess(process3.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
//require.Equal(t, createdAt, process.CreatedAt)
|
||||
require.NotEqual(t, updatedAt, process.UpdatedAt)
|
||||
}
|
||||
|
||||
func TestGetProcess(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user