mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-01-24 15:03:27 +01:00
Mock time (#2)
This commit is contained in:
@@ -5,13 +5,13 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/database/busdb"
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/time"
|
||||
)
|
||||
|
||||
func (db *Database) TaskGet(ctx context.Context, id int64, playbookID string, taskID string) (*models.TicketWithTickets, *models.PlaybookResponse, *models.TaskWithContext, error) {
|
||||
@@ -65,13 +65,14 @@ func (db *Database) TaskComplete(ctx context.Context, id int64, playbookID strin
|
||||
LET newplaybook = MERGE(playbook, {"tasks": newtasks})
|
||||
LET newplaybooks = MERGE(d.playbooks, { @playbookID: newplaybook } )
|
||||
|
||||
UPDATE d WITH { "modified": DATE_ISO8601(DATE_NOW()), "playbooks": newplaybooks } IN @@collection
|
||||
UPDATE d WITH { "modified": @now, "playbooks": newplaybooks } IN @@collection
|
||||
RETURN NEW`
|
||||
ticket, err := db.ticketGetQuery(ctx, id, query, mergeMaps(map[string]interface{}{
|
||||
"playbookID": playbookID,
|
||||
"taskID": taskID,
|
||||
"data": data,
|
||||
"closed": time.Now().UTC(),
|
||||
"now": time.Now().UTC(),
|
||||
}, ticketFilterVars), &busdb.Operation{
|
||||
OperationType: busdb.Update,
|
||||
Ids: []driver.DocumentID{
|
||||
@@ -118,6 +119,8 @@ func (db *Database) TaskUpdate(ctx context.Context, id int64, playbookID string,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
task.Created = time.Now().UTC()
|
||||
|
||||
query := `LET d = DOCUMENT(@@collection, @ID)
|
||||
` + ticketFilterQuery + `
|
||||
LET playbook = d.playbooks[@playbookID]
|
||||
@@ -125,12 +128,13 @@ func (db *Database) TaskUpdate(ctx context.Context, id int64, playbookID string,
|
||||
LET newplaybook = MERGE(playbook, {"tasks": newtasks})
|
||||
LET newplaybooks = MERGE(d.playbooks, { @playbookID: newplaybook } )
|
||||
|
||||
UPDATE d WITH { "modified": DATE_ISO8601(DATE_NOW()), "playbooks": newplaybooks } IN @@collection
|
||||
UPDATE d WITH { "modified": @now, "playbooks": newplaybooks } IN @@collection
|
||||
RETURN NEW`
|
||||
ticket, err := db.ticketGetQuery(ctx, id, query, mergeMaps(map[string]interface{}{
|
||||
"playbookID": playbookID,
|
||||
"taskID": taskID,
|
||||
"task": task,
|
||||
"now": time.Now().UTC(),
|
||||
}, ticketFilterVars), &busdb.Operation{
|
||||
OperationType: busdb.Update,
|
||||
Ids: []driver.DocumentID{
|
||||
|
||||
Reference in New Issue
Block a user