mirror of
https://github.com/miniflux/v2.git
synced 2025-08-21 18:11:09 +00:00
Remove debug timer from most storage functions
This commit is contained in:
parent
4295a86e55
commit
0dff432337
7 changed files with 0 additions and 88 deletions
|
@ -9,10 +9,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"miniflux.app/model"
|
||||
"miniflux.app/timer"
|
||||
|
||||
"github.com/lib/pq/hstore"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
@ -20,7 +18,6 @@ import (
|
|||
|
||||
// SetLastLogin updates the last login date of a user.
|
||||
func (s *Storage) SetLastLogin(userID int64) error {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:SetLastLogin] userID=%d", userID))
|
||||
query := "UPDATE users SET last_login_at=now() WHERE id=$1"
|
||||
_, err := s.db.Exec(query, userID)
|
||||
if err != nil {
|
||||
|
@ -32,8 +29,6 @@ func (s *Storage) SetLastLogin(userID int64) error {
|
|||
|
||||
// UserExists checks if a user exists by using the given username.
|
||||
func (s *Storage) UserExists(username string) bool {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserExists] username=%s", username))
|
||||
|
||||
var result int
|
||||
s.db.QueryRow(`SELECT count(*) as c FROM users WHERE username=LOWER($1)`, username).Scan(&result)
|
||||
return result >= 1
|
||||
|
@ -41,8 +36,6 @@ func (s *Storage) UserExists(username string) bool {
|
|||
|
||||
// AnotherUserExists checks if another user exists with the given username.
|
||||
func (s *Storage) AnotherUserExists(userID int64, username string) bool {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:AnotherUserExists] userID=%d, username=%s", userID, username))
|
||||
|
||||
var result int
|
||||
s.db.QueryRow(`SELECT count(*) as c FROM users WHERE id != $1 AND username=LOWER($2)`, userID, username).Scan(&result)
|
||||
return result >= 1
|
||||
|
@ -50,7 +43,6 @@ func (s *Storage) AnotherUserExists(userID int64, username string) bool {
|
|||
|
||||
// CreateUser creates a new user.
|
||||
func (s *Storage) CreateUser(user *model.User) (err error) {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:CreateUser] username=%s", user.Username))
|
||||
password := ""
|
||||
extra := hstore.Hstore{Map: make(map[string]sql.NullString)}
|
||||
|
||||
|
@ -117,8 +109,6 @@ func (s *Storage) RemoveExtraField(userID int64, field string) error {
|
|||
|
||||
// UpdateUser updates a user.
|
||||
func (s *Storage) UpdateUser(user *model.User) error {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UpdateUser] userID=%d", user.ID))
|
||||
|
||||
if user.Password != "" {
|
||||
hashedPassword, err := hashPassword(user.Password)
|
||||
if err != nil {
|
||||
|
@ -190,7 +180,6 @@ func (s *Storage) UpdateUser(user *model.User) error {
|
|||
|
||||
// UserLanguage returns the language of the given user.
|
||||
func (s *Storage) UserLanguage(userID int64) (language string) {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserLanguage] userID=%d", userID))
|
||||
err := s.db.QueryRow(`SELECT language FROM users WHERE id = $1`, userID).Scan(&language)
|
||||
if err != nil {
|
||||
return "en_US"
|
||||
|
@ -201,7 +190,6 @@ func (s *Storage) UserLanguage(userID int64) (language string) {
|
|||
|
||||
// UserByID finds a user by the ID.
|
||||
func (s *Storage) UserByID(userID int64) (*model.User, error) {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByID] userID=%d", userID))
|
||||
query := `
|
||||
SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, keyboard_shortcuts,
|
||||
|
@ -217,7 +205,6 @@ func (s *Storage) UserByID(userID int64) (*model.User, error) {
|
|||
|
||||
// UserByUsername finds a user by the username.
|
||||
func (s *Storage) UserByUsername(username string) (*model.User, error) {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByUsername] username=%s", username))
|
||||
query := `
|
||||
SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, keyboard_shortcuts,
|
||||
|
@ -233,7 +220,6 @@ func (s *Storage) UserByUsername(username string) (*model.User, error) {
|
|||
|
||||
// UserByExtraField finds a user by an extra field value.
|
||||
func (s *Storage) UserByExtraField(field, value string) (*model.User, error) {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UserByExtraField] field=%s", field))
|
||||
query := `
|
||||
SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, keyboard_shortcuts,
|
||||
|
@ -281,8 +267,6 @@ func (s *Storage) fetchUser(query string, args ...interface{}) (*model.User, err
|
|||
|
||||
// RemoveUser deletes a user.
|
||||
func (s *Storage) RemoveUser(userID int64) error {
|
||||
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:RemoveUser] userID=%d", userID))
|
||||
|
||||
result, err := s.db.Exec("DELETE FROM users WHERE id = $1", userID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to remove this user: %v", err)
|
||||
|
@ -302,7 +286,6 @@ func (s *Storage) RemoveUser(userID int64) error {
|
|||
|
||||
// Users returns all users.
|
||||
func (s *Storage) Users() (model.Users, error) {
|
||||
defer timer.ExecutionTime(time.Now(), "[Storage:Users]")
|
||||
query := `
|
||||
SELECT
|
||||
id, username, is_admin, theme, language, timezone, entry_direction, keyboard_shortcuts,
|
||||
|
@ -353,8 +336,6 @@ func (s *Storage) Users() (model.Users, error) {
|
|||
|
||||
// CheckPassword validate the hashed password.
|
||||
func (s *Storage) CheckPassword(username, password string) error {
|
||||
defer timer.ExecutionTime(time.Now(), "[Storage:CheckPassword]")
|
||||
|
||||
var hash string
|
||||
username = strings.ToLower(username)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue