multi: allow querying actions by group ID

This commit is contained in:
Elle Mouton 2023-06-19 16:02:59 +02:00
parent 3c837a9bc6
commit bd9a99c5d4
No known key found for this signature in database
GPG key ID: D7D916376026F177
5 changed files with 108 additions and 58 deletions

View file

@ -35,9 +35,9 @@ var listActionsCommand = cli.Command{
},
cli.StringFlag{
Name: "session_id",
Usage: "The session ID to filter the actions by. If " +
"left empty, then all actions will be " +
"returned.",
Usage: "The hex encoded session ID to filter the " +
"actions by. If left empty, then all actions " +
"will be returned.",
},
cli.Uint64Flag{
Name: "start_timestamp",
@ -84,6 +84,16 @@ var listActionsCommand = cli.Command{
"index_offset is the index of the action in " +
"the db regardless of filter.",
},
cli.StringFlag{
Name: "group_id",
Usage: "The hex encoded group ID to filter the " +
"actions by. The group ID is the same for " +
"all sessions that have been linked. If a " +
"session has no linked sessions then the " +
"group ID will be the same as the " +
"session ID. This flag will be ignored if " +
"the `session_id` flag is set.",
},
},
}
@ -109,6 +119,14 @@ func listActions(ctx *cli.Context) error {
}
}
var groupID []byte
if ctx.String("group_id") != "" {
groupID, err = hex.DecodeString(ctx.String("group_id"))
if err != nil {
return err
}
}
resp, err := client.ListActions(
ctxb, &litrpc.ListActionsRequest{
SessionId: sessionID,
@ -122,6 +140,7 @@ func listActions(ctx *cli.Context) error {
CountTotal: ctx.Bool("count_total"),
StartTimestamp: ctx.Uint64("start_timestamp"),
EndTimestamp: ctx.Uint64("end_timestamp"),
GroupId: groupID,
},
)
if err != nil {