MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / New

Method New

inventory/task.go:91–118  ·  view source on GitHub ↗
(ctx context.Context, task *TaskArgs)

Source from the content-addressed store, hash-verified

89}
90
91func (c *taskClient) New(ctx context.Context, task *TaskArgs) (*ent.Task, error) {
92 stm := c.client.Task.
93 Create().
94 SetType(task.Type).
95 SetPublicState(task.PublicState)
96 if task.PrivateState != "" {
97 stm.SetPrivateState(task.PrivateState)
98 }
99
100 if task.OwnerID != 0 {
101 stm.SetUserID(task.OwnerID)
102 }
103
104 if task.Status != "" {
105 stm.SetStatus(task.Status)
106 }
107
108 if task.CorrelationID.String() != uuid.Nil.String() {
109 stm.SetCorrelationID(task.CorrelationID)
110 }
111
112 newTask, err := stm.Save(ctx)
113 if err != nil {
114 return nil, fmt.Errorf("failed to create task: %w", err)
115 }
116
117 return newTask, nil
118}
119
120func (c *taskClient) DeleteByIDs(ctx context.Context, ids ...int) error {
121 _, err := c.client.Task.Delete().Where(task.IDIn(ids...)).Exec(ctx)

Callers

nothing calls this directly

Calls 9

CreateMethod · 0.65
SetStatusMethod · 0.65
StringMethod · 0.65
SetPublicStateMethod · 0.45
SetTypeMethod · 0.45
SetPrivateStateMethod · 0.45
SetUserIDMethod · 0.45
SetCorrelationIDMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected