Skip to content

Commit

Permalink
feat: Add GetPaidTables() and HasPaidTables() to schema.Tables (#…
Browse files Browse the repository at this point in the history
…1403)

Co-authored-by: Kemal Hadimli <[email protected]>
  • Loading branch information
disq and disq authored Dec 5, 2023
1 parent 2f98271 commit b355fa0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions schema/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,21 @@ func (tt Tables) ValidateDuplicateTables() error {
return nil
}

func (tt Tables) GetPaidTables() Tables {
flattenedTables := tt.FlattenTables()
paidTables := make(Tables, 0, len(flattenedTables))
for i := range flattenedTables {
if flattenedTables[i].IsPaid {
paidTables = append(paidTables, flattenedTables[i])
}
}
return paidTables
}

func (tt Tables) HasPaidTables() bool {
return len(tt.GetPaidTables()) > 0
}

// this will filter the tree in-place
func (t *Table) filterDfs(parentMatched bool, include, exclude func(*Table) bool, skipDependentTables bool) *Table {
if exclude(t) {
Expand Down

1 comment on commit b355fa0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Benchmark results

  • Glob-8 ns/op: 211.2

Please sign in to comment.