mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +00:00
Rename helper packages
This commit is contained in:
parent
3c3f397bf5
commit
c39f2e1a8d
31 changed files with 97 additions and 97 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue