bookpreviews

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package bookpreviews picks a few books to show as covers on each entry of a people, genre, tag, or publisher list. It sits below those packages because pkg/books imports them.

Index

Constants

View Source
const Limit = 3

Limit is the most books an entry previews.

Variables

View Source
var (
	// Genres previews the books in each genre.
	Genres = Source{/* contains filtered or unexported fields */}
	// Tags previews the books with each tag.
	Tags = Source{/* contains filtered or unexported fields */}
	// People previews the books each person wrote, then the books of files
	// they narrated, so a narrator who wrote nothing still shows covers.
	People = Source{
			// contains filtered or unexported fields
	}
	// Publishers previews the books of each publisher's files and its
	// sub-publishers' files, as a publisher's file count counts both.
	Publishers = Source{
				// contains filtered or unexported fields
	}
)

Functions

This section is empty.

Types

type PreviewBook

type PreviewBook struct {
	ID            int    `json:"id"`
	Title         string `json:"title"`
	CoverCacheKey string `json:"cover_cache_key"`
	// The shape the gallery gives this book's cover in its library.
	CoverAspect string `json:"cover_aspect" tstype:"ThumbnailAspect"`
}

PreviewBook is a book shown as a cover on a list entry.

type Previews

type Previews map[int][]PreviewBook

Previews holds each entity's preview books, keyed by entity id.

func (Previews) For

func (p Previews) For(entityID int) []PreviewBook

For returns an entity's preview books, an empty slice when it has none so the field serializes as [].

type Service

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

func NewService

func NewService(db *bun.DB) *Service

func (*Service) Load

func (s *Service) Load(ctx context.Context, source Source, entityIDs []int) (Previews, error)

Load returns up to Limit preview books for each of entityIDs, in display order, in one query for the picks and one for the books. Entities without books are absent from the map.

type Source

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

Source selects the books linked to an entity, as rows of (entity_id, book_id, priority) for the entity ids bound to every `?`. Lower priority books come first; within a priority, the newest released, then the newest added.

Jump to

Keyboard shortcuts

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