• 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/cache/cache.go
1
package cache
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/inspect"
12
        "github.com/supabase/cli/internal/migration/list"
13
        "github.com/supabase/cli/internal/utils"
14
        "github.com/supabase/cli/internal/utils/pgxv5"
15
)
16

17
type Result struct {
18
        Name  string
19
        Ratio float64
20
}
21

22
func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
×
23
        conn, err := utils.ConnectByConfig(ctx, config, options...)
×
24
        if err != nil {
×
25
                return err
×
26
        }
×
NEW
27
        rows, err := conn.Query(ctx, inspect.CACHE_QUERY)
×
28
        if err != nil {
×
29
                return errors.Errorf("failed to query rows: %w", err)
×
30
        }
×
31
        result, err := pgxv5.CollectRows[Result](rows)
×
32
        if err != nil {
×
33
                return err
×
34
        }
×
35
        // TODO: implement a markdown table marshaller
NEW
36
        table := "|Name|Ratio|OK?|Explanation|\n|-|-|-|-|\n"
×
37
        for _, r := range result {
×
NEW
38
                ok := "Yup!"
×
NEW
39
                if r.Ratio < 0.94 {
×
NEW
40
                        ok = "Maybe not..."
×
NEW
41
                }
×
NEW
42
                var explanation string
×
NEW
43
                if r.Name == "index hit rate" {
×
NEW
44
                        explanation = "This is the ratio of index hits to index scans. If this ratio is low, it means that the database is not using indexes effectively. Check the `index-usage` command for more info."
×
NEW
45
                } else if r.Name == "table hit rate" {
×
NEW
46
                        explanation = "This is the ratio of table hits to table scans. If this ratio is low, it means that your queries are not finding the data effectively. Check your query performance and it might be worth increasing your compute."
×
NEW
47
                }
×
NEW
48
                table += fmt.Sprintf("|`%s`|`%.6f`|`%s`|`%s`|\n", r.Name, r.Ratio, ok, explanation)
×
49
        }
50
        return list.RenderTable(table)
×
51
}
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