diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-01-02 19:15:08 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-01-02 19:15:08 -0800 |
commit | c39f2e1a8d2de6d412bcc673d29eb0f7a2d1f5f7 (patch) | |
tree | 950efc2155037ce055e1aae334e160812b0ee38f /storage/category.go | |
parent | 3c3f397bf57e232201fccd64bad2820e6ade567a (diff) |
Rename helper packages
Diffstat (limited to 'storage/category.go')
-rw-r--r-- | storage/category.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/storage/category.go b/storage/category.go index a9de759..197b78b 100644 --- a/storage/category.go +++ b/storage/category.go @@ -10,13 +10,13 @@ import ( "fmt" "time" - "github.com/miniflux/miniflux/helper" "github.com/miniflux/miniflux/model" + "github.com/miniflux/miniflux/timer" ) // AnotherCategoryExists checks if another category exists with the same title. func (s *Storage) AnotherCategoryExists(userID, categoryID int64, title string) bool { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:AnotherCategoryExists] userID=%d, categoryID=%d, title=%s", userID, categoryID, title)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:AnotherCategoryExists] userID=%d, categoryID=%d, title=%s", userID, categoryID, title)) var result int query := `SELECT count(*) as c FROM categories WHERE user_id=$1 AND id != $2 AND title=$3` @@ -26,7 +26,7 @@ func (s *Storage) AnotherCategoryExists(userID, categoryID int64, title string) // CategoryExists checks if the given category exists into the database. func (s *Storage) CategoryExists(userID, categoryID int64) bool { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CategoryExists] userID=%d, categoryID=%d", userID, categoryID)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CategoryExists] userID=%d, categoryID=%d", userID, categoryID)) var result int query := `SELECT count(*) as c FROM categories WHERE user_id=$1 AND id=$2` @@ -36,7 +36,7 @@ func (s *Storage) CategoryExists(userID, categoryID int64) bool { // Category returns a category from the database. func (s *Storage) Category(userID, categoryID int64) (*model.Category, error) { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:Category] userID=%d, getCategory=%d", userID, categoryID)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:Category] userID=%d, getCategory=%d", userID, categoryID)) var category model.Category query := `SELECT id, user_id, title FROM categories WHERE user_id=$1 AND id=$2` @@ -52,7 +52,7 @@ func (s *Storage) Category(userID, categoryID int64) (*model.Category, error) { // FirstCategory returns the first category for the given user. func (s *Storage) FirstCategory(userID int64) (*model.Category, error) { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:FirstCategory] userID=%d", userID)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:FirstCategory] userID=%d", userID)) var category model.Category query := `SELECT id, user_id, title FROM categories WHERE user_id=$1 ORDER BY title ASC LIMIT 1` @@ -68,7 +68,7 @@ func (s *Storage) FirstCategory(userID int64) (*model.Category, error) { // CategoryByTitle finds a category by the title. func (s *Storage) CategoryByTitle(userID int64, title string) (*model.Category, error) { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CategoryByTitle] userID=%d, title=%s", userID, title)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CategoryByTitle] userID=%d, title=%s", userID, title)) var category model.Category query := `SELECT id, user_id, title FROM categories WHERE user_id=$1 AND title=$2` @@ -84,7 +84,7 @@ func (s *Storage) CategoryByTitle(userID int64, title string) (*model.Category, // Categories returns all categories that belongs to the given user. func (s *Storage) Categories(userID int64) (model.Categories, error) { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:Categories] userID=%d", userID)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:Categories] userID=%d", userID)) query := `SELECT id, user_id, title FROM categories WHERE user_id=$1 ORDER BY title ASC` rows, err := s.db.Query(query, userID) @@ -108,7 +108,7 @@ func (s *Storage) Categories(userID int64) (model.Categories, error) { // CategoriesWithFeedCount returns all categories with the number of feeds. func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error) { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CategoriesWithFeedCount] userID=%d", userID)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CategoriesWithFeedCount] userID=%d", userID)) query := `SELECT c.id, c.user_id, c.title, (SELECT count(*) FROM feeds WHERE feeds.category_id=c.id) AS count @@ -135,7 +135,7 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error // CreateCategory creates a new category. func (s *Storage) CreateCategory(category *model.Category) error { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CreateCategory] title=%s", category.Title)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CreateCategory] title=%s", category.Title)) query := ` INSERT INTO categories @@ -159,7 +159,7 @@ func (s *Storage) CreateCategory(category *model.Category) error { // UpdateCategory updates an existing category. func (s *Storage) UpdateCategory(category *model.Category) error { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UpdateCategory] categoryID=%d", category.ID)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UpdateCategory] categoryID=%d", category.ID)) query := `UPDATE categories SET title=$1 WHERE id=$2 AND user_id=$3` _, err := s.db.Exec( @@ -178,7 +178,7 @@ func (s *Storage) UpdateCategory(category *model.Category) error { // RemoveCategory deletes a category. func (s *Storage) RemoveCategory(userID, categoryID int64) error { - defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:RemoveCategory] userID=%d, categoryID=%d", userID, categoryID)) + defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:RemoveCategory] userID=%d, categoryID=%d", userID, categoryID)) result, err := s.db.Exec("DELETE FROM categories WHERE id = $1 AND user_id = $2", categoryID, userID) if err != nil { |