Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOISSUE - Limit listing based on domain #41

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion re/postgres/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
INSERT INTO rules (id, name, domain_id, metadata, input_channel, input_topic, logic_type, logic_value,
output_channel, output_topic, recurring_time, recurring_type, recurring_period, created_at, created_by, updated_at, updated_by, status)
VALUES (:id, :name, :domain_id, :metadata, :input_channel, :input_topic, :logic_type, :logic_value,
:output_channel, :output_topic, :recurring_time, :recurring_type, :recurring_period, :created_at, :updated_at, :updated_by, :status)
:output_channel, :output_topic, :recurring_time, :recurring_type, :recurring_period, :created_at, :created_by, :updated_at, :updated_by, :status)
RETURNING id, name, domain_id, metadata, input_channel, input_topic, logic_type, logic_value,
output_channel, output_topic, recurring_time, recurring_type, recurring_period, created_at, created_by, updated_at, updated_by, status;
`
Expand Down Expand Up @@ -229,6 +229,10 @@ func pageQuery(pm re.PageMeta) string {
query = append(query, "r.status = :status")
}

if pm.Domain != "" {
query = append(query, "r.domain_id = :domain_id")
}

var q string
if len(query) > 0 {
q = fmt.Sprintf("WHERE %s", strings.Join(query, " AND "))
Expand Down
2 changes: 2 additions & 0 deletions re/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type PageMeta struct {
InputChannel string `json:"input_channel,omitempty" db:"input_channel"`
OutputChannel string `json:"output_channel,omitempty" db:"output_channel"`
Status Status `json:"status,omitempty" db:"status"`
Domain string `json:"domain_id,omitempty" db:"domain_id"`
}

type Page struct {
Expand Down Expand Up @@ -135,6 +136,7 @@ func (re *re) UpdateRule(ctx context.Context, session authn.Session, r Rule) (Ru
}

func (re *re) ListRules(ctx context.Context, session authn.Session, pm PageMeta) (Page, error) {
pm.Domain = session.DomainID
return re.repo.ListRules(ctx, pm)
}

Expand Down
Loading