mirror of
https://github.com/datarhei/core.git
synced 2025-09-30 22:02:28 +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"`
|
Type string `json:"type" jsonschema:"enum=ffmpeg"`
|
||||||
Reference string `json:"reference"`
|
Reference string `json:"reference"`
|
||||||
CreatedAt int64 `json:"created_at" jsonschema:"minimum=0" format:"int64"`
|
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"`
|
Config *ProcessConfig `json:"config,omitempty"`
|
||||||
State *ProcessState `json:"state,omitempty"`
|
State *ProcessState `json:"state,omitempty"`
|
||||||
Report *ProcessReport `json:"report,omitempty"`
|
Report *ProcessReport `json:"report,omitempty"`
|
||||||
|
@@ -544,6 +544,7 @@ func (h *RestreamHandler) getProcess(id, filterString string) (api.Process, erro
|
|||||||
Reference: process.Reference,
|
Reference: process.Reference,
|
||||||
Type: "ffmpeg",
|
Type: "ffmpeg",
|
||||||
CreatedAt: process.CreatedAt,
|
CreatedAt: process.CreatedAt,
|
||||||
|
UpdatedAt: process.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if wants["config"] {
|
if wants["config"] {
|
||||||
|
@@ -106,6 +106,7 @@ type Process struct {
|
|||||||
Reference string `json:"reference"`
|
Reference string `json:"reference"`
|
||||||
Config *Config `json:"config"`
|
Config *Config `json:"config"`
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
|
UpdatedAt int64 `json:"updated_at"`
|
||||||
Order string `json:"order"`
|
Order string `json:"order"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +116,7 @@ func (process *Process) Clone() *Process {
|
|||||||
Reference: process.Reference,
|
Reference: process.Reference,
|
||||||
Config: process.Config.Clone(),
|
Config: process.Config.Clone(),
|
||||||
CreatedAt: process.CreatedAt,
|
CreatedAt: process.CreatedAt,
|
||||||
|
UpdatedAt: process.UpdatedAt,
|
||||||
Order: process.Order,
|
Order: process.Order,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -456,6 +456,8 @@ func (r *restream) createTask(config *app.Config) (*task, error) {
|
|||||||
CreatedAt: time.Now().Unix(),
|
CreatedAt: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.UpdatedAt = process.CreatedAt
|
||||||
|
|
||||||
if config.Autostart {
|
if config.Autostart {
|
||||||
process.Order = "start"
|
process.Order = "start"
|
||||||
}
|
}
|
||||||
@@ -867,6 +869,9 @@ func (r *restream) UpdateProcess(id string, config *app.Config) error {
|
|||||||
return ErrUnknownProcess
|
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)
|
task.parser.TransferReportHistory(t.parser)
|
||||||
t.process.Order = task.process.Order
|
t.process.Order = task.process.Order
|
||||||
|
|
||||||
|
@@ -216,6 +216,14 @@ func TestUpdateProcess(t *testing.T) {
|
|||||||
err = rs.AddProcess(process2)
|
err = rs.AddProcess(process2)
|
||||||
require.Equal(t, nil, err)
|
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()
|
process3 := getDummyProcess()
|
||||||
require.NotNil(t, process3)
|
require.NotNil(t, process3)
|
||||||
process3.ID = "process2"
|
process3.ID = "process2"
|
||||||
@@ -230,8 +238,11 @@ func TestUpdateProcess(t *testing.T) {
|
|||||||
_, err = rs.GetProcess(process1.ID)
|
_, err = rs.GetProcess(process1.ID)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
_, err = rs.GetProcess(process3.ID)
|
process, err = rs.GetProcess(process3.ID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
//require.Equal(t, createdAt, process.CreatedAt)
|
||||||
|
require.NotEqual(t, updatedAt, process.UpdatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetProcess(t *testing.T) {
|
func TestGetProcess(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user