Skip to content

Commit

Permalink
fix: enable rule and attachments count
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNotGoodName committed Jul 20, 2023
1 parent 5dab096 commit da486b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/db/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func EnvelopeCount(cc *core.Context) (int, error) {
}

func EnvelopeAttachmentCount(cc *core.Context) (int, error) {
return cc.DB.NewSelect().Model(&envelope.Attachment{}).Where("message_id != NULL").Count(cc.Context())
return cc.DB.NewSelect().Model(&envelope.Attachment{}).Where("message_id IS NOT NULL").Count(cc.Context())
}

func EnvelopeAttachmentList(cc *core.Context, page pagination.Page, filter envelope.AttachmentFilter) (envelope.AttachmentListResult, error) {
Expand Down
6 changes: 6 additions & 0 deletions internal/db/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ func RuleList(cc *core.Context) ([]rules.Rule, error) {
return rrules, err
}

func RuleListEnable(cc *core.Context) ([]rules.Rule, error) {
var rrules []rules.Rule
err := cc.DB.NewSelect().Model(&rrules).Where("enable = TRUE").Scan(cc.Context())
return rrules, err
}

func RuleEndpointList(cc *core.Context, ruleID int64) ([]rules.Endpoint, error) {
var e []rules.Endpoint
err := cc.DB.NewSelect().
Expand Down
2 changes: 1 addition & 1 deletion internal/procs/mailman.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func mailman(cc *core.Context, evtC <-chan core.EventEnvelopeCreated) {
}

// List all rules
rrules, err := db.RuleList(cc)
rrules, err := db.RuleListEnable(cc)
if err != nil {
log.Err(err).Msg("Failed to list rules from database")
continue
Expand Down
1 change: 0 additions & 1 deletion internal/rules/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type CreateRule struct {
InternalID string
Name string
Template string
Enable bool
}

type Rule struct {
Expand Down

0 comments on commit da486b8

Please sign in to comment.