mirror of
https://github.com/datarhei/core.git
synced 2025-09-27 04:16:25 +08:00
Add updated_at field in process infos
This commit is contained in:
@@ -14,6 +14,7 @@ type Process struct {
|
||||
Type string `json:"type" jsonschema:"enum=ffmpeg"`
|
||||
Reference string `json:"reference"`
|
||||
CreatedAt int64 `json:"created_at" jsonschema:"minimum=0" format:"int64"`
|
||||
UpdatedAt int64 `json:"updated_at" jsonschema:"minimum=0" format:"int64"`
|
||||
Config *ProcessConfig `json:"config,omitempty"`
|
||||
State *ProcessState `json:"state,omitempty"`
|
||||
Report *ProcessReport `json:"report,omitempty"`
|
||||
|
@@ -544,6 +544,7 @@ func (h *RestreamHandler) getProcess(id, filterString string) (api.Process, erro
|
||||
Reference: process.Reference,
|
||||
Type: "ffmpeg",
|
||||
CreatedAt: process.CreatedAt,
|
||||
UpdatedAt: process.UpdatedAt,
|
||||
}
|
||||
|
||||
if wants["config"] {
|
||||
|
@@ -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