• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 8665741536

12 Apr 2024 05:19PM UTC coverage: 57.738% (-0.07%) from 57.812%
8665741536

Pull #2138

github

sweatybridge
fix: add schema column to table sizes query
Pull Request #2138: fix: exclude supabase managed schemas from inspect subcommand

2 of 46 new or added lines in 20 files covered. (4.35%)

5 existing lines in 1 file now uncovered.

6376 of 11043 relevant lines covered (57.74%)

662.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/inspect/index_usage/index_usage.go
1
package index_usage
2

3
import (
4
        "context"
5
        "fmt"
6

7
        "github.com/go-errors/errors"
8
        "github.com/jackc/pgconn"
9
        "github.com/jackc/pgx/v4"
10
        "github.com/spf13/afero"
11
        "github.com/supabase/cli/internal/db/reset"
12
        "github.com/supabase/cli/internal/inspect"
13
        "github.com/supabase/cli/internal/migration/list"
14
        "github.com/supabase/cli/internal/utils"
15
        "github.com/supabase/cli/internal/utils/pgxv5"
16
)
17

18
type Result struct {
19
        Name                        string
20
        Percent_of_times_index_used string
21
        Rows_in_table               int64
22
}
23

24
func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
×
25
        conn, err := utils.ConnectByConfig(ctx, config, options...)
×
26
        if err != nil {
×
27
                return err
×
28
        }
×
NEW
29
        rows, err := conn.Query(ctx, inspect.INDEX_USAGE_QUERY, reset.LikeEscapeSchema(utils.InternalSchemas))
×
30
        if err != nil {
×
31
                return errors.Errorf("failed to query rows: %w", err)
×
32
        }
×
33
        result, err := pgxv5.CollectRows[Result](rows)
×
34
        if err != nil {
×
35
                return err
×
36
        }
×
37
        // TODO: implement a markdown table marshaller
38
        table := "|Table name|Percentage of times index used|Rows in table|\n|-|-|-|\n"
×
39
        for _, r := range result {
×
NEW
40
                table += fmt.Sprintf("|`%s`|`%s`|`%d`|\n", r.Name, r.Percent_of_times_index_used, r.Rows_in_table)
×
41
        }
×
42
        return list.RenderTable(table)
×
43
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc