You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sessions.go
    path of file: ./repos/photoprism/internal/search
    
    the code of the file until where you have to start completion: package search

import (
	"strings"

	"github.com/photoprism/photoprism/internal/entity"
	"github.com/photoprism/photoprism/internal/form"
	"github.com/photoprism/photoprism/pkg/rnd"
)

// Sessions finds user sessions.
func Sessions(f form.SearchSessions) (result entity.Sessions, err error) {
	result = entity.Sessions{}
	stmt := Db()

	search := strings.TrimSpace(f.Query)
	uid := strings.TrimSpace(f.UID)
	sortOrder := f.Order
	limit := f.Count
	offset := f.Offset

	if search == "all" {
		// Don't filter.
	} else if rnd.IsUID(uid, entity.UserUID) {
		stmt = stmt.Where("user_uid = ?", search)
	} else if search != "" {
		stmt = stmt.Where("user_name LIKE ? OR a
    
func Sessions(f form.SearchSessions) (result entity.Sessions, err error) {
	result = entity.Sessions{}
	stmt := Db()

	search := strings.TrimSpace(f.Query)
	uid := strings.TrimSpace(f.UID)
	sortOrder := f.Order
	limit := f.Count
	offset := f.Offset

	if search == "all" {
		// Don't filter.
	} else if rnd.IsUID(uid, entity.UserUID) {
		stmt = stmt.Where("user_uid = ?", search)
	} else if search != "" {
		stmt = stmt.Where("user_name LIKE ? OR auth_provider LIKE ?", search+"%", search+"%")
	}

	if sortOrder == "" {
		sortOrder = "last_active DESC, user_name"
	}

	if limit > 0 {
		stmt = stmt.Limit(limit)

		if offset > 0 {
			stmt = stmt.Offset(offset)
		}
	}

	err = stmt.Order(sortOrder).Find(&result).Error

	return result, err
}