Cleanup: remove unused code
This commit is contained in:
parent
531a0184f7
commit
7be05afa11
@ -10,7 +10,3 @@ func nullTimeToUTC(t sql.NullTime) sql.NullTime {
|
|||||||
Valid: t.Valid,
|
Valid: t.Valid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ptr[T any](value T) *T {
|
|
||||||
return &value
|
|
||||||
}
|
|
||||||
|
@ -297,17 +297,3 @@ func testFixtures(t *testing.T) (*SleepScheduler, TestMocks, context.Context) {
|
|||||||
ss := New(mocks.clock, mocks.persist, mocks.broadcaster)
|
ss := New(mocks.clock, mocks.persist, mocks.broadcaster)
|
||||||
return ss, mocks, ctx
|
return ss, mocks, ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestWorker(updaters ...func(*persistence.Worker)) persistence.Worker {
|
|
||||||
w := persistence.Worker{
|
|
||||||
ID: 47,
|
|
||||||
UUID: "4f2d3755-c365-429f-8017-44356427c069",
|
|
||||||
Name: "schedule test worker",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, updater := range updaters {
|
|
||||||
updater(&w)
|
|
||||||
}
|
|
||||||
|
|
||||||
return w
|
|
||||||
}
|
|
||||||
|
@ -150,49 +150,12 @@ func (db *DB) queries() *sqlc.Queries {
|
|||||||
return sqlc.New(&loggingWrapper)
|
return sqlc.New(&loggingWrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
type queriesTX struct {
|
|
||||||
queries *sqlc.Queries
|
|
||||||
commit func() error
|
|
||||||
rollback func() error
|
|
||||||
}
|
|
||||||
|
|
||||||
// queries returns the SQLC Queries struct, connected to this database.
|
|
||||||
//
|
|
||||||
// After calling this function, all queries should use this transaction until it
|
|
||||||
// is closed (either committed or rolled back). Otherwise SQLite will deadlock,
|
|
||||||
// as it will make any other query wait until this transaction is done.
|
|
||||||
func (db *DB) queriesWithTX() (*queriesTX, error) {
|
|
||||||
tx, err := db.sqlDB.Begin()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("could not begin database transaction: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
loggingWrapper := LoggingDBConn{tx}
|
|
||||||
|
|
||||||
qtx := queriesTX{
|
|
||||||
queries: sqlc.New(&loggingWrapper),
|
|
||||||
commit: tx.Commit,
|
|
||||||
rollback: tx.Rollback,
|
|
||||||
}
|
|
||||||
|
|
||||||
return &qtx, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// now returns 'now' as reported by db.nowfunc.
|
// now returns 'now' as reported by db.nowfunc.
|
||||||
// It always converts the timestamp to UTC.
|
// It always converts the timestamp to UTC.
|
||||||
func (db *DB) now() time.Time {
|
func (db *DB) now() time.Time {
|
||||||
return db.nowfunc()
|
return db.nowfunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
// nowNullable returns the result of `now()` wrapped in a sql.NullTime.
|
|
||||||
// It is nullable just for ease of use, it will never actually be null.
|
|
||||||
func (db *DB) nowNullable() sql.NullTime {
|
|
||||||
return sql.NullTime{
|
|
||||||
Time: db.now(),
|
|
||||||
Valid: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *DB) pragmaForeignKeys(ctx context.Context, enabled bool) error {
|
func (db *DB) pragmaForeignKeys(ctx context.Context, enabled bool) error {
|
||||||
var noun string
|
var noun string
|
||||||
switch enabled {
|
switch enabled {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user