stash/pkg/models/stash_ids.go
stg-annon 3660bf2d1a
Support filtering by StashID endpoint (#3005)
* Add endpoint to stash_id filter in UI

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2022-11-17 10:08:15 +11:00

30 lines
886 B
Go

package models
type StashID struct {
StashID string `db:"stash_id" json:"stash_id"`
Endpoint string `db:"endpoint" json:"endpoint"`
}
type UpdateStashIDs struct {
StashIDs []StashID `json:"stash_ids"`
Mode RelationshipUpdateMode `json:"mode"`
}
// AddUnique adds the stash id to the list, only if the endpoint/stashid pair does not already exist in the list.
func (u *UpdateStashIDs) AddUnique(v StashID) {
for _, vv := range u.StashIDs {
if vv.StashID == v.StashID && vv.Endpoint == v.Endpoint {
return
}
}
u.StashIDs = append(u.StashIDs, v)
}
type StashIDCriterionInput struct {
// If present, this value is treated as a predicate.
// That is, it will filter based on stash_ids with the matching endpoint
Endpoint *string `json:"endpoint"`
StashID *string `json:"stash_id"`
Modifier CriterionModifier `json:"modifier"`
}