querying

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPageNumberOutOfBounds error = errors.New("querying: invalid page index (out of bounds)")
	ErrOwnerNotFound         error = errors.New("querying: owner not found")
)

Functions

This section is empty.

Types

type BookmarkPage

type BookmarkPage struct {
	// Owner exposes public metadata for the User owning the bookmarks.
	Owner Owner

	PageNumber         uint
	PreviousPageNumber uint
	NextPageNumber     uint
	TotalPages         uint
	Offset             uint

	SearchTerms       string
	SearchResultCount uint

	Bookmarks []bookmark.Bookmark
}

A BookmarkPage holds a set of paginated bookmarks.

func NewBookmarkPage

func NewBookmarkPage(owner Owner, number uint, totalPages uint, bookmarks []bookmark.Bookmark) BookmarkPage

NewBookmarkPage initializes and returns a new BookmarkPage.

func NewBookmarkSearchResultPage

func NewBookmarkSearchResultPage(owner Owner, searchTerms string, searchResultCount uint, number uint, totalPages uint, bookmarks []bookmark.Bookmark) BookmarkPage

NewBookmarkSearchResultPage initializes and returns a new BookmarkPage containing search results.

type Owner

type Owner struct {
	// UUID is the internal identifier for this User.
	UUID string

	// NickName is the handle used in user-specific URLs, and may only contain
	// alphanumerical characters, the dash character, or the underscore character.
	NickName string

	// DisplayName is the handle used in the Web interface for this User.
	DisplayName string
}

Owner exposes public metadata for the User owning the displayed bookmarks.

type Repository

type Repository interface {
	// BookmarkGetCount returns the number of bookmarks for a given user.
	BookmarkGetCount(userUUID string, visibility Visibility) (uint, error)

	// BookmarkGetN returns at most n bookmarks for a given user, starting at
	// a given offset.
	BookmarkGetN(userUUID string, visibility Visibility, n uint, offset uint) ([]bookmark.Bookmark, error)

	// BookmarkGetPublicByUID returns the bookmark for a given user and UID, provided the bookmark is public.
	BookmarkGetPublicByUID(userUUID, uid string) (bookmark.Bookmark, error)

	// BookmarkSearchCount returns the number of bookmarks for a given user and
	// search terms.
	BookmarkSearchCount(userUUID string, visibility Visibility, searchTerms string) (uint, error)

	// BookmarkSearchN returns at most n bookmarks for a given user and search
	// terms, starting at a given offset.
	BookmarkSearchN(userUUID string, visibility Visibility, searchTerms string, n uint, offset uint) ([]bookmark.Bookmark, error)

	// OwnerGetByUUID returns the Owner corresponding to a given UUID.
	OwnerGetByUUID(string) (Owner, error)

	// TagGetAll returns all tags for a given user.
	TagGetAll(userUUID string, visibility Visibility) ([]Tag, error)

	// TagGetCount returns the number of tags for a given user.
	TagGetCount(userUUID string, visibility Visibility) (uint, error)

	// TagGetN returns at most n tags for a given user, starting at
	// a given offset.
	TagGetN(userUUID string, visibility Visibility, n uint, offset uint) ([]Tag, error)

	// TagFilterCount returns the number of tags for a given user and
	// filter term.
	TagFilterCount(userUUID string, visibility Visibility, filterTerm string) (uint, error)

	// BookmarkSearchN returns at most n tags for a given user and filter
	// term, starting at a given offset.
	TagFilterN(userUUID string, visibility Visibility, filterTerm string, n uint, offset uint) ([]Tag, error)
}

Repository provides access to query user bookmarks.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles oprtaions related to displaying and paginating bookmarks.

func NewService

func NewService(r Repository) *Service

NewService initializes and returns a new Service.

func (*Service) BookmarksByPage

func (s *Service) BookmarksByPage(ownerUUID string, visibility Visibility, number uint) (BookmarkPage, error)

BookmarksByPage returns a Page containing a limited and offset number of bookmarks.

func (*Service) BookmarksBySearchQueryAndPage

func (s *Service) BookmarksBySearchQueryAndPage(ownerUUID string, visibility Visibility, searchTerms string, number uint) (BookmarkPage, error)

BookmarksBySearchQueryAndPage returns a SearchPage containing a limited and offset number of bookmarks for a given set of search terms.

func (*Service) PublicBookmarkByUID

func (s *Service) PublicBookmarkByUID(ownerUUID string, uid string) (BookmarkPage, error)

BookmarkByUID returns a Page containing a single bookmark.

func (*Service) PublicBookmarksByPage

func (s *Service) PublicBookmarksByPage(ownerUUID string, number uint) (BookmarkPage, error)

PublicBookmarksByPage returns a Page containing a limited and offset number of bookmarks.

func (*Service) PublicBookmarksBySearchQueryAndPage

func (s *Service) PublicBookmarksBySearchQueryAndPage(ownerUUID string, searchTerms string, number uint) (BookmarkPage, error)

PublicBookmarksBySearchQueryAndPage returns a SearchPage containing a limited and offset number of bookmarks for a given set of search terms.

func (*Service) TagNamesByCount

func (s *Service) TagNamesByCount(userUUID string, visibility Visibility) ([]string, error)

TagNamesByCount returns all tag names for a given user, sorted by count in descending order.

func (*Service) Tags

func (s *Service) Tags(userUUID string, visibility Visibility) ([]Tag, error)

Tags return all tags for a given user.

func (*Service) TagsByFilterQueryAndPage

func (s *Service) TagsByFilterQueryAndPage(ownerUUID string, visibility Visibility, filterTerm string, number uint) (TagPage, error)

TagsByFilterQueryAndPage returns a TagSearchPage containing a limited and offset number of tags for a given filter term.

func (*Service) TagsByPage

func (s *Service) TagsByPage(ownerUUID string, visibility Visibility, number uint) (TagPage, error)

TagsByPage returns a Page containing a limited and offset number of tags.

type Tag

type Tag struct {
	Name        string
	EncodedName string
	Count       uint
}

A Tag holds metadata for a given bookmark tag.

func NewTag

func NewTag(name string, count uint) Tag

NewTag initializes and returns a new Tag.

type TagPage

type TagPage struct {
	// Owner exposes public metadata for the User owning the bookmarks.
	Owner Owner

	PageNumber         uint
	PreviousPageNumber uint
	NextPageNumber     uint
	TotalPages         uint
	Offset             uint

	FilterTerm string

	TagCount uint
	Tags     []Tag
}

A TagPage holds a set of paginated bookmark tags.

func NewTagFilterResultPage

func NewTagFilterResultPage(owner Owner, filterTerm string, tagCount uint, number uint, totalPages uint, tags []Tag) TagPage

NewTagFilterResultPage initializes and returns a new bookmark Page containing filtered results.

func NewTagPage

func NewTagPage(owner Owner, number uint, totalPages uint, tagCount uint, tags []Tag) TagPage

NewTagPage initializes and returns a new TagPage.

type Visibility

type Visibility string

Visibility represents a visibility filter for bookmarks.

const (
	// Public and private bookmarks.
	VisibilityAll Visibility = "all"

	// Private bookmarks only.
	VisibilityPrivate Visibility = "private"

	// Public bookmarks only.
	VisibilityPublic Visibility = "public"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL