MCPcopy Index your code
hub / github.com/coder/coder / run

Function run

scripts/dbgen/main.go:49–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49func run() error {
50 localPath, err := localFilePath()
51 if err != nil {
52 return err
53 }
54 databasePath := filepath.Join(localPath, "..", "..", "..", "coderd", "database")
55 err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbmetrics", "querymetrics.go"), "m", "queryMetricsStore", func(params stubParams) string {
56 return fmt.Sprintf(`
57start := time.Now()
58%s := m.s.%s(%s)
59m.queryLatencies.WithLabelValues("%s").Observe(time.Since(start).Seconds())
60m.queryCounts.WithLabelValues(httpmw.ExtractHTTPRoute(ctx), httpmw.ExtractHTTPMethod(ctx), "%s").Inc()
61return %s
62`, params.Returns, params.FuncName, params.Parameters, params.FuncName, params.FuncName, params.Returns)
63 })
64 if err != nil {
65 return xerrors.Errorf("stub dbmetrics: %w", err)
66 }
67
68 err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbauthz", "dbauthz.go"), "q", "querier", func(_ stubParams) string {
69 return `panic("not implemented")`
70 })
71 if err != nil {
72 return xerrors.Errorf("stub dbauthz: %w", err)
73 }
74
75 err = generateUniqueConstraints()
76 if err != nil {
77 return xerrors.Errorf("generate unique constraints: %w", err)
78 }
79
80 err = generateForeignKeyConstraints()
81 if err != nil {
82 return xerrors.Errorf("generate foreign key constraints: %w", err)
83 }
84
85 err = generateCheckConstraints()
86 if err != nil {
87 return xerrors.Errorf("generate check constraints: %w", err)
88 }
89
90 return nil
91}
92
93type stubParams struct {
94 FuncName string

Callers 1

mainFunction · 0.70

Calls 6

localFilePathFunction · 0.85
generateCheckConstraintsFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected