1
0

Well, GetCategoryByID() actually has no use. Let's get rid of it.

This commit is contained in:
Alexander Andreev 2023-05-23 00:44:42 +04:00
parent aeba6d6ea5
commit a8a7e6427d
Signed by: Arav
GPG Key ID: D22A817D95815393
2 changed files with 0 additions and 31 deletions

View File

@ -14,8 +14,6 @@ var (
//go:embed queries/schema.sql
querySchema string
//go:embed queries/categoryById.sql
queryCategoryById string
//go:embed queries/categoryGetAll.sql
queryCategoryGetAll string
//go:embed queries/categoryNew.sql
@ -37,7 +35,6 @@ var (
)
var (
stmtCategoryById *sql.Stmt
stmtCategoryGetAll *sql.Stmt
stmtCategoryNew *sql.Stmt
stmtCategoryEdit *sql.Stmt
@ -57,11 +54,6 @@ func initDBStatements(db *sql.DB) error {
return errors.Wrap(err, "failed to init schema")
}
stmtCategoryById, err = db.Prepare(queryCategoryById)
if err != nil {
return errors.Wrap(err, "failed to prepare queryCategoryById")
}
stmtCategoryGetAll, err = db.Prepare(queryCategoryGetAll)
if err != nil {
return errors.Wrap(err, "failed to prepare queryCategoryGetAll")
@ -284,27 +276,6 @@ func (s *SQLiteMindflow) EditCategory(category *mindflow.Category) error {
return nil
}
func (s *SQLiteMindflow) GetCategoryByID(id int64) (name string, err error) {
tx, err := s.db.Begin()
if err != nil {
return "", err
}
defer tx.Rollback()
r := tx.Stmt(stmtCategoryById).QueryRow(id)
if r.Err() != nil {
return "", r.Err()
}
if err := r.Scan(name); err != nil {
return "", err
}
tx.Commit()
return
}
func (s *SQLiteMindflow) DeleteCategory(id int64) (err error) {
tx, err := s.db.Begin()
if err != nil {
@ -338,7 +309,6 @@ func (s *SQLiteMindflow) DeleteUnusedCategories() (err error) {
}
func (s *SQLiteMindflow) Close() error {
stmtCategoryById.Close()
stmtCategoryGetAll.Close()
stmtCategoryNew.Close()
stmtCategoryEdit.Close()

View File

@ -44,7 +44,6 @@ type Mindflow interface {
Posts() ([]Post, error)
Categories() ([]Category, error)
NewCategory(name string) (int64, error)
GetCategoryByID(id int64) (string, error)
EditCategory(category *Category) error
DeleteCategory(id int64) error
DeleteUnusedCategories() error