Documentation
¶
Overview ¶
Package db provides SQLite persistence for librarr: users, library items, download jobs, requests, and related records.
Index ¶
- Variables
- func ItemToJSON(item models.LibraryItem) map[string]interface{}
- func NormalizeLibraryPath(filePath string) string
- type AddItemOutcome
- type BlocklistEntry
- type DB
- func (d *DB) AddBlocklistEntry(title, source, downloadURL, infoHash, reason string) (int64, error)
- func (d *DB) AddItem(item *models.LibraryItem) (int64, error)
- func (d *DB) AddItemTag(itemID, tagID int64) error
- func (d *DB) AddItemWithOutcome(item *models.LibraryItem) (AddItemOutcome, error)
- func (d *DB) AddMonitoredAuthor(name string, intervalDays int) (int64, error)
- func (d *DB) AddMonitoredAuthorWithOptions(name string, intervalDays int, autoAdd bool) (int64, error)
- func (d *DB) AddReadingHistory(userID int64, bookTitle, author, format string, ...) (int64, error)
- func (d *DB) AddSeenWorks(authorID int64, works []SeenWork) error
- func (d *DB) AddWishlistItem(title, author, mediaType string) (int64, error)
- func (d *DB) AddWishlistItemWithOptions(item models.WishlistItem) (int64, error)
- func (d *DB) BackfillLibraryMetadata(extract func(string) (title, author string)) (int, error)
- func (d *DB) ClearBlocklist() error
- func (d *DB) ClearFinishedJobs() (int, error)
- func (d *DB) ClearWishlistLink(id int64) error
- func (d *DB) Close() error
- func (d *DB) CountActivity() (int, error)
- func (d *DB) CountItems(mediaType string) (int, error)
- func (d *DB) CountRequests(userID int64, status string) (int, error)
- func (d *DB) CountUnreadNotifications(userID int64) (int, error)
- func (d *DB) CountUsers() (int, error)
- func (d *DB) CreateInviteCode(code string, createdBy int64, role string, maxUses int, expiresAt *float64) (int64, error)
- func (d *DB) CreateNotification(n *models.Notification) (int64, error)
- func (d *DB) CreateQualityProfile(qp *QualityProfile) (int64, error)
- func (d *DB) CreateReleaseProfile(rp *ReleaseProfile) (int64, error)
- func (d *DB) CreateRequest(req *models.Request) error
- func (d *DB) CreateTag(name, color string) (int64, error)
- func (d *DB) CreateUser(username, passwordHash, role string) (int64, error)
- func (d *DB) CreateWebhookConfig(c *webhook.Config) (int64, error)
- func (d *DB) DeleteBlocklistEntry(id int64) error
- func (d *DB) DeleteInviteCode(id int64) error
- func (d *DB) DeleteItem(id int64) error
- func (d *DB) DeleteItemBySourceID(sourceID string) error
- func (d *DB) DeleteJob(id string) error
- func (d *DB) DeleteMonitoredAuthor(id int64) error
- func (d *DB) DeleteNotification(id int64, userID int64) error
- func (d *DB) DeleteQualityProfile(id int64) error
- func (d *DB) DeleteReadingHistory(id, userID int64) error
- func (d *DB) DeleteReleaseProfile(id int64) error
- func (d *DB) DeleteRequest(id string) error
- func (d *DB) DeleteTag(id int64) error
- func (d *DB) DeleteUser(id int64) error
- func (d *DB) DeleteWebhookConfig(id int64) error
- func (d *DB) DeleteWishlistItem(id int64) error
- func (d *DB) DisableTOTP(userID int64) error
- func (d *DB) EnableTOTP(userID int64) error
- func (d *DB) FindByTitle(title string) ([]models.LibraryItem, error)
- func (d *DB) FindItems(mediaType, query string, limit, offset int) ([]models.LibraryItem, int, error)
- func (d *DB) FindWishlistByActiveJob(jobRef string) (*models.WishlistItem, error)
- func (d *DB) GetActivity(limit, offset int) ([]models.ActivityEvent, error)
- func (d *DB) GetActivityLog(user, action string, limit, offset int) ([]models.ActivityEntry, error)
- func (d *DB) GetActivityLogCount(user, action string) (int, error)
- func (d *DB) GetBlocklist(limit, offset int) ([]BlocklistEntry, error)
- func (d *DB) GetDBPath() string
- func (d *DB) GetDefaultQualityProfile(mediaType string) (*QualityProfile, error)
- func (d *DB) GetItem(id int64) (*models.LibraryItem, error)
- func (d *DB) GetItemTags(itemID int64) ([]Tag, error)
- func (d *DB) GetItems(mediaType string, limit, offset int) ([]models.LibraryItem, error)
- func (d *DB) GetItemsByTag(tagID int64, limit, offset int) ([]models.LibraryItem, error)
- func (d *DB) GetJob(id string) (*models.DownloadJob, error)
- func (d *DB) GetJobs() ([]models.DownloadJob, error)
- func (d *DB) GetMonitoredAuthor(id int64) (*MonitoredAuthor, error)
- func (d *DB) GetMonitoredAuthors() ([]MonitoredAuthor, error)
- func (d *DB) GetNotifications(userID int64, limit, offset int) ([]models.Notification, error)
- func (d *DB) GetQualityProfile(id int64) (*QualityProfile, error)
- func (d *DB) GetQualityProfiles() ([]QualityProfile, error)
- func (d *DB) GetReadingHistory(userID int64, status string, limit, offset int) ([]ReadingHistoryEntry, error)
- func (d *DB) GetReadingStats(userID int64) (map[string]interface{}, error)
- func (d *DB) GetReleaseProfile(id int64) (*ReleaseProfile, error)
- func (d *DB) GetReleaseProfiles() ([]ReleaseProfile, error)
- func (d *DB) GetRequest(id string) (*models.Request, error)
- func (d *DB) GetSeriesTracking() ([]map[string]interface{}, error)
- func (d *DB) GetStats() (map[string]interface{}, error)
- func (d *DB) GetTags() ([]Tag, error)
- func (d *DB) GetUploads(limit, offset int) ([]models.UploadRecord, error)
- func (d *DB) GetUser(id int64) (*models.User, error)
- func (d *DB) GetUserByUsername(username string) (*models.User, error)
- func (d *DB) GetWebhookConfigs() ([]webhook.Config, error)
- func (d *DB) GetWishlist() ([]models.WishlistItem, error)
- func (d *DB) GetWishlistItem(id int64) (*models.WishlistItem, error)
- func (d *DB) HasSourceID(sourceID string) bool
- func (d *DB) IsBlocklisted(downloadURL, infoHash string) bool
- func (d *DB) LibraryMatchIndex() (*library.Index, error)
- func (d *DB) LibraryPaths(mediaType string) (map[string]struct{}, error)
- func (d *DB) LinkWishlistItem(id, libraryItemID int64) error
- func (d *DB) ListInviteCodes() ([]map[string]interface{}, error)
- func (d *DB) ListRequests(userID int64, status string, limit, offset int) ([]models.Request, error)
- func (d *DB) ListUsers() ([]models.User, error)
- func (d *DB) LogActivity(user, action, target, detail string)
- func (d *DB) LogEvent(eventType, title, detail string, libraryItemID *int64, jobID string) error
- func (d *DB) MarkAllNotificationsRead(userID int64) error
- func (d *DB) MarkNZBJobImported(nzoID string) error
- func (d *DB) MarkNotificationRead(id int64, userID int64) error
- func (d *DB) PendingNZBJobs() ([]models.NZBJob, error)
- func (d *DB) RecordNZBJob(nzoID, title, mediaType string) error
- func (d *DB) RecordWishlistSearch(id int64, result string) error
- func (d *DB) RemoveItemTag(itemID, tagID int64) error
- func (d *DB) ResolveQualityProfile(profileID int64, mediaType string) QualityProfile
- func (d *DB) SatisfyWishlistItem(id, libraryItemID int64) (previous int64, err error)
- func (d *DB) SaveBackupCodes(userID int64, codeHashes []string) error
- func (d *DB) SaveJob(job *models.DownloadJob) error
- func (d *DB) SaveUpload(user, filename, originalName, fileType string, fileSize int64, ...) (int64, error)
- func (d *DB) SeenWorkKeys(authorID int64) (map[string]bool, error)
- func (d *DB) SetTOTPSecret(userID int64, secret string) error
- func (d *DB) SetWishlistActiveJob(id int64, jobRef string) error
- func (d *DB) UnlinkLibraryItemFromWishlist(libraryItemID int64) error
- func (d *DB) UpdateJobStatus(id, status, detail, errMsg string) error
- func (d *DB) UpdateLastLogin(userID int64) error
- func (d *DB) UpdateMonitoredAuthor(id int64, intervalDays *int, autoAdd *bool) error
- func (d *DB) UpdateMonitoredAuthorCheck(id int64, lastBookFound string) error
- func (d *DB) UpdateQualityProfile(qp *QualityProfile) error
- func (d *DB) UpdateReadingHistory(id, userID int64, finishedAt *time.Time, rating *int, notes *string) error
- func (d *DB) UpdateReleaseProfile(rp *ReleaseProfile) error
- func (d *DB) UpdateRequest(req *models.Request) error
- func (d *DB) UpdateRequestStatus(id, status string) error
- func (d *DB) UpdateUser(id int64, username, role string) error
- func (d *DB) UpdateUserPassword(id int64, passwordHash string) error
- func (d *DB) UpdateWishlistItem(id int64, monitored *bool, qualityProfileID *int64) error
- func (d *DB) UpsertSeriesTracking(seriesName string, knownTotal, ownedCount int) (int64, error)
- func (d *DB) UseBackupCode(userID int64, codeHash string) (bool, error)
- func (d *DB) UseInviteCode(code string) error
- func (d *DB) ValidateInviteCode(code string) (string, error)
- type MonitoredAuthor
- type PreferredWord
- type QualityProfile
- type ReadingHistoryEntry
- type ReleaseProfile
- type SeenWork
- type Tag
Constants ¶
This section is empty.
Variables ¶
var ErrBuiltinProfile = fmt.Errorf("built-in quality profiles cannot be deleted")
ErrBuiltinProfile is returned when deleting a built-in profile.
Functions ¶
func ItemToJSON ¶
func ItemToJSON(item models.LibraryItem) map[string]interface{}
func NormalizeLibraryPath ¶ added in v1.2.0
NormalizeLibraryPath returns a stable absolute path for identity checks. Symlinks are resolved when the target exists; case is intentionally not folded because Linux library filesystems are case-sensitive.
Types ¶
type AddItemOutcome ¶ added in v1.2.0
type AddItemOutcome struct {
ID int64
Inserted bool
Reason string
ContentHash string
NormalizedPath string
ExistingID int64
}
AddItemOutcome describes whether AddItem inserted a new row or reused an existing file-level identity.
type BlocklistEntry ¶ added in v1.0.0
type BlocklistEntry struct {
ID int64 `json:"id"`
Title string `json:"title"`
Source string `json:"source"`
DownloadURL string `json:"download_url"`
InfoHash string `json:"info_hash"`
Reason string `json:"reason"`
CreatedAt time.Time `json:"created_at"`
}
BlocklistEntry represents a blocklisted download.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite database for library tracking and download jobs.
func (*DB) AddBlocklistEntry ¶ added in v1.0.0
func (*DB) AddItem ¶
func (d *DB) AddItem(item *models.LibraryItem) (int64, error)
AddItem records a successfully processed book.
func (*DB) AddItemTag ¶ added in v1.0.0
func (*DB) AddItemWithOutcome ¶ added in v1.2.0
func (d *DB) AddItemWithOutcome(item *models.LibraryItem) (AddItemOutcome, error)
AddItemWithOutcome inserts a library item idempotently. Exact canonical destination paths are always unique. Content hashes are also unique within the same media type and file format, which prevents a moved or re-imported file from creating a second row without merging EPUB and MOBI records. The DB mutex serializes the identity check and insert, so concurrent imports within Librarr cannot race between those operations.
func (*DB) AddMonitoredAuthor ¶ added in v1.0.0
func (*DB) AddMonitoredAuthorWithOptions ¶ added in v1.3.0
func (d *DB) AddMonitoredAuthorWithOptions(name string, intervalDays int, autoAdd bool) (int64, error)
AddMonitoredAuthorWithOptions adds an author with an explicit auto-add flag.
func (*DB) AddReadingHistory ¶ added in v1.0.0
func (d *DB) AddReadingHistory(userID int64, bookTitle, author, format string, startedAt, finishedAt *time.Time, rating *int, notes string, libraryItemID *int64) (int64, error)
AddReadingHistory inserts a reading history entry.
func (*DB) AddSeenWorks ¶ added in v1.3.0
AddSeenWorks records works for an author; keys already present are ignored.
func (*DB) AddWishlistItem ¶
AddWishlistItem adds a monitored item using the default profile.
func (*DB) AddWishlistItemWithOptions ¶ added in v1.3.0
func (d *DB) AddWishlistItemWithOptions(item models.WishlistItem) (int64, error)
AddWishlistItemWithOptions adds an item with an explicit profile, monitored flag and provenance. An empty media type means ebook; an empty source means manual.
func (*DB) BackfillLibraryMetadata ¶ added in v1.2.0
BackfillLibraryMetadata updates rows whose title still matches the torrent-derived directory name. It deliberately leaves user-renamed rows alone and skips files that are no longer present.
func (*DB) ClearBlocklist ¶ added in v1.0.0
func (*DB) ClearFinishedJobs ¶
ClearFinishedJobs removes completed, error, and dead_letter jobs.
func (*DB) ClearWishlistLink ¶ added in v1.3.0
ClearWishlistLink detaches a wanted row from a library item that no longer exists, sending it back to "missing".
func (*DB) CountActivity ¶
CountActivity returns the total number of activity events.
func (*DB) CountItems ¶
CountItems counts library items, optionally filtered by media type.
func (*DB) CountRequests ¶
CountRequests returns the number of requests matching the filters.
func (*DB) CountUnreadNotifications ¶
CountUnreadNotifications returns the number of unread notifications for a user.
func (*DB) CountUsers ¶
CountUsers returns the total number of users.
func (*DB) CreateInviteCode ¶ added in v1.1.0
func (d *DB) CreateInviteCode(code string, createdBy int64, role string, maxUses int, expiresAt *float64) (int64, error)
CreateInviteCode generates a new invite code.
func (*DB) CreateNotification ¶
func (d *DB) CreateNotification(n *models.Notification) (int64, error)
CreateNotification inserts a new notification.
func (*DB) CreateQualityProfile ¶ added in v1.0.0
func (d *DB) CreateQualityProfile(qp *QualityProfile) (int64, error)
func (*DB) CreateReleaseProfile ¶ added in v1.0.0
func (d *DB) CreateReleaseProfile(rp *ReleaseProfile) (int64, error)
func (*DB) CreateRequest ¶
CreateRequest inserts a new book request.
func (*DB) CreateUser ¶
CreateUser inserts a new user. Returns the new user ID.
func (*DB) CreateWebhookConfig ¶ added in v1.0.0
CreateWebhookConfig inserts a new webhook config.
func (*DB) DeleteBlocklistEntry ¶ added in v1.0.0
func (*DB) DeleteInviteCode ¶ added in v1.1.0
DeleteInviteCode removes an invite code.
func (*DB) DeleteItem ¶
DeleteItem removes a library item by ID.
func (*DB) DeleteItemBySourceID ¶ added in v1.1.0
DeleteItemBySourceID removes a library item by its source_id field.
func (*DB) DeleteMonitoredAuthor ¶ added in v1.0.0
func (*DB) DeleteNotification ¶
DeleteNotification removes a notification by ID (must belong to user).
func (*DB) DeleteQualityProfile ¶ added in v1.0.0
DeleteQualityProfile removes a custom profile. Wanted items that used it fall back to the built-in default for their media type.
func (*DB) DeleteReadingHistory ¶ added in v1.0.0
DeleteReadingHistory removes a history entry by ID.
func (*DB) DeleteReleaseProfile ¶ added in v1.0.0
func (*DB) DeleteRequest ¶
DeleteRequest removes a request by ID.
func (*DB) DeleteWebhookConfig ¶ added in v1.0.0
DeleteWebhookConfig removes a webhook config by ID.
func (*DB) DeleteWishlistItem ¶
DeleteWishlistItem removes a wishlist item by ID.
func (*DB) DisableTOTP ¶
DisableTOTP disables TOTP and clears the secret.
func (*DB) EnableTOTP ¶
EnableTOTP enables TOTP for a user.
func (*DB) FindByTitle ¶
func (d *DB) FindByTitle(title string) ([]models.LibraryItem, error)
FindByTitle performs a case-insensitive title lookup.
func (*DB) FindItems ¶ added in v1.4.0
func (d *DB) FindItems(mediaType, query string, limit, offset int) ([]models.LibraryItem, int, error)
FindItems filters before pagination and returns the matching total. instr treats %, _ and quotes as literal search text rather than LIKE wildcards.
func (*DB) FindWishlistByActiveJob ¶ added in v1.3.0
func (d *DB) FindWishlistByActiveJob(jobRef string) (*models.WishlistItem, error)
FindWishlistByActiveJob returns the item whose in-flight grab is jobRef (a download job ID or "torrent:<infohash>"), or nil when none is.
func (*DB) GetActivity ¶
func (d *DB) GetActivity(limit, offset int) ([]models.ActivityEvent, error)
GetActivity returns recent activity, newest first.
func (*DB) GetActivityLog ¶
GetActivityLog returns paginated activity entries with optional filters.
func (*DB) GetActivityLogCount ¶
GetActivityLogCount returns the total number of activity entries matching filters.
func (*DB) GetBlocklist ¶ added in v1.0.0
func (d *DB) GetBlocklist(limit, offset int) ([]BlocklistEntry, error)
func (*DB) GetDefaultQualityProfile ¶ added in v1.3.0
func (d *DB) GetDefaultQualityProfile(mediaType string) (*QualityProfile, error)
GetDefaultQualityProfile returns the built-in profile for a media type.
func (*DB) GetItem ¶ added in v1.3.0
func (d *DB) GetItem(id int64) (*models.LibraryItem, error)
GetItem returns one library item by ID, or sql.ErrNoRows.
func (*DB) GetItemsByTag ¶ added in v1.0.0
func (*DB) GetJob ¶
func (d *DB) GetJob(id string) (*models.DownloadJob, error)
GetJob retrieves a download job by ID.
func (*DB) GetJobs ¶
func (d *DB) GetJobs() ([]models.DownloadJob, error)
GetJobs returns all download jobs.
func (*DB) GetMonitoredAuthor ¶ added in v1.3.0
func (d *DB) GetMonitoredAuthor(id int64) (*MonitoredAuthor, error)
GetMonitoredAuthor returns one author by ID.
func (*DB) GetMonitoredAuthors ¶ added in v1.0.0
func (d *DB) GetMonitoredAuthors() ([]MonitoredAuthor, error)
func (*DB) GetNotifications ¶
GetNotifications returns notifications for a user, newest first.
func (*DB) GetQualityProfile ¶ added in v1.0.0
func (d *DB) GetQualityProfile(id int64) (*QualityProfile, error)
func (*DB) GetQualityProfiles ¶ added in v1.0.0
func (d *DB) GetQualityProfiles() ([]QualityProfile, error)
func (*DB) GetReadingHistory ¶ added in v1.0.0
func (d *DB) GetReadingHistory(userID int64, status string, limit, offset int) ([]ReadingHistoryEntry, error)
GetReadingHistory returns paginated reading history for a user.
func (*DB) GetReadingStats ¶ added in v1.0.0
GetReadingStats returns reading statistics for a user.
func (*DB) GetReleaseProfile ¶ added in v1.0.0
func (d *DB) GetReleaseProfile(id int64) (*ReleaseProfile, error)
func (*DB) GetReleaseProfiles ¶ added in v1.0.0
func (d *DB) GetReleaseProfiles() ([]ReleaseProfile, error)
func (*DB) GetRequest ¶
GetRequest retrieves a request by ID.
func (*DB) GetSeriesTracking ¶ added in v1.0.0
GetSeriesTracking returns all tracked series.
func (*DB) GetUploads ¶
func (d *DB) GetUploads(limit, offset int) ([]models.UploadRecord, error)
GetUploads returns recent uploads.
func (*DB) GetUserByUsername ¶
GetUserByUsername retrieves a user by username (case-insensitive).
func (*DB) GetWebhookConfigs ¶ added in v1.0.0
GetWebhookConfigs returns all webhook configurations.
func (*DB) GetWishlist ¶
func (d *DB) GetWishlist() ([]models.WishlistItem, error)
GetWishlist returns all wishlist items, newest first, with the format and path of the library file currently satisfying each one.
func (*DB) GetWishlistItem ¶ added in v1.3.0
func (d *DB) GetWishlistItem(id int64) (*models.WishlistItem, error)
GetWishlistItem returns one item by ID, or sql.ErrNoRows.
func (*DB) HasSourceID ¶
HasSourceID checks if a source_id already exists.
func (*DB) IsBlocklisted ¶ added in v1.0.0
func (*DB) LibraryMatchIndex ¶ added in v1.2.1
LibraryMatchIndex builds an ownership index over the whole library so search results and download requests can be checked against what the user already has.
Only the four columns matching needs are read: a library of several thousand books would otherwise drag file paths, metadata blobs and content hashes through memory on every search. Building the index is a single sequential scan and the result is queried by map lookup, so callers should build it once per request and reuse it across every result they annotate.
func (*DB) LibraryPaths ¶ added in v1.4.0
LibraryPaths returns the canonical paths recorded for a media type. A library item may record either an individual file or the directory that contains an imported tree, so callers can use the result to recognize both forms without depending on the item's source ID.
func (*DB) LinkWishlistItem ¶ added in v1.3.0
LinkWishlistItem attaches an existing library file to a wanted row without touching the in-flight marker — used by reconciliation when a file arrived by some other route (manual download, an old library, a torrent librarr could not tie to the row).
func (*DB) ListInviteCodes ¶ added in v1.1.0
ListInviteCodes returns all invite codes for admin display.
func (*DB) ListRequests ¶
ListRequests returns requests filtered by optional user ID and status. If userID is 0, all requests are returned (admin view).
func (*DB) LogActivity ¶
LogActivity appends a user-attributed event to the activity log.
func (*DB) MarkAllNotificationsRead ¶
MarkAllNotificationsRead marks all notifications as read for a user.
func (*DB) MarkNZBJobImported ¶ added in v1.2.0
MarkNZBJobImported flags an NZB job as imported so it is not processed again.
func (*DB) MarkNotificationRead ¶
MarkNotificationRead marks a single notification as read.
func (*DB) PendingNZBJobs ¶ added in v1.2.0
PendingNZBJobs returns NZB jobs that have not yet been imported.
func (*DB) RecordNZBJob ¶ added in v1.2.0
RecordNZBJob remembers an NZB submitted to SABnzbd. It is idempotent: a repeated nzo_id (e.g. a retried submit) is ignored rather than resurrecting an already-imported job.
func (*DB) RecordWishlistSearch ¶ added in v1.3.0
RecordWishlistSearch stores what the scheduler decided on its last pass.
func (*DB) RemoveItemTag ¶ added in v1.0.0
func (*DB) ResolveQualityProfile ¶ added in v1.3.0
func (d *DB) ResolveQualityProfile(profileID int64, mediaType string) QualityProfile
ResolveQualityProfile returns the profile a wanted item should use: its own when set and still present, otherwise the built-in default for its media type, otherwise the package default so a decision is always possible.
func (*DB) SatisfyWishlistItem ¶ added in v1.3.0
SatisfyWishlistItem links a wanted row to the library item that now fulfils it and clears the in-flight marker. It returns the previously linked library item ID (0 if none) so the caller can retire a superseded file after an upgrade.
func (*DB) SaveBackupCodes ¶
SaveBackupCodes stores hashed backup codes for a user.
func (*DB) SaveJob ¶
func (d *DB) SaveJob(job *models.DownloadJob) error
SaveJob persists a download job.
func (*DB) SaveUpload ¶
func (d *DB) SaveUpload(user, filename, originalName, fileType string, fileSize int64, organizedTo, status, errMsg string) (int64, error)
SaveUpload records a file upload.
func (*DB) SeenWorkKeys ¶ added in v1.3.0
SeenWorkKeys returns the set of work keys already recorded for an author.
func (*DB) SetTOTPSecret ¶
SetTOTPSecret stores the TOTP secret for a user (does not enable it yet).
func (*DB) SetWishlistActiveJob ¶ added in v1.3.0
SetWishlistActiveJob marks a grab as in flight (or clears it with "").
func (*DB) UnlinkLibraryItemFromWishlist ¶ added in v1.3.0
UnlinkLibraryItemFromWishlist detaches every wanted row pointing at a library item that is being deleted, so those rows become wanted again instead of silently pointing at nothing.
func (*DB) UpdateJobStatus ¶
UpdateJobStatus updates the status and detail of a job.
func (*DB) UpdateLastLogin ¶
UpdateLastLogin updates the last_login timestamp for a user.
func (*DB) UpdateMonitoredAuthor ¶ added in v1.3.0
UpdateMonitoredAuthor changes the editable settings. Nil leaves a field as is.
func (*DB) UpdateMonitoredAuthorCheck ¶ added in v1.0.0
func (*DB) UpdateQualityProfile ¶ added in v1.0.0
func (d *DB) UpdateQualityProfile(qp *QualityProfile) error
UpdateQualityProfile rewrites the editable fields. The builtin flag and media type of a built-in profile are preserved: the defaults stay one per media type no matter what a client sends.
func (*DB) UpdateReadingHistory ¶ added in v1.0.0
func (d *DB) UpdateReadingHistory(id, userID int64, finishedAt *time.Time, rating *int, notes *string) error
UpdateReadingHistory updates a history entry (finish date, rating, notes).
func (*DB) UpdateReleaseProfile ¶ added in v1.0.0
func (d *DB) UpdateReleaseProfile(rp *ReleaseProfile) error
func (*DB) UpdateRequest ¶
UpdateRequest updates mutable fields on a request.
func (*DB) UpdateRequestStatus ¶
UpdateRequestStatus updates the status and optional fields of a request.
func (*DB) UpdateUser ¶
UpdateUser updates a user's username and role.
func (*DB) UpdateUserPassword ¶
UpdateUserPassword updates only the password hash.
func (*DB) UpdateWishlistItem ¶ added in v1.3.0
UpdateWishlistItem changes the user-editable fields: monitored flag and quality profile. Nil pointers leave a field untouched.
func (*DB) UpsertSeriesTracking ¶ added in v1.0.0
UpsertSeriesTracking creates or updates a series tracking entry.
func (*DB) UseBackupCode ¶
UseBackupCode checks if a backup code matches any unused code for the user. If found, marks it used.
func (*DB) UseInviteCode ¶ added in v1.1.0
UseInviteCode increments the use count.
type MonitoredAuthor ¶ added in v1.0.0
type MonitoredAuthor struct {
ID int64 `json:"id"`
Name string `json:"name"`
LastChecked time.Time `json:"last_checked"`
LastBookFound string `json:"last_book_found"`
CheckIntervalDays int `json:"check_interval_days"`
// AutoAdd puts newly discovered works on the wanted list instead of
// only notifying about them.
AutoAdd bool `json:"auto_add"`
// SeenWorks is the number of works already recorded for the author; zero
// means the next check will take a baseline instead of announcing the
// entire back catalogue as new.
SeenWorks int `json:"seen_works"`
}
MonitoredAuthor represents a monitored author record.
type PreferredWord ¶ added in v1.0.0
PreferredWord represents a word+score pair in a release profile.
type QualityProfile ¶ added in v1.0.0
type QualityProfile struct {
ID int64 `json:"id"`
Name string `json:"name"`
MediaType string `json:"media_type"`
FormatRanking []string `json:"format_ranking"`
PreferredSizeMin int64 `json:"preferred_size_min"`
PreferredSizeMax int64 `json:"preferred_size_max"`
UpgradeAllowed bool `json:"upgrade_allowed"`
CutoffFormat string `json:"cutoff_format"`
// Builtin profiles are seeded per media type and cannot be deleted; they
// are what an item with no explicit profile uses.
Builtin bool `json:"builtin"`
}
QualityProfile represents a quality profile record.
func (QualityProfile) Profile ¶ added in v1.3.0
func (qp QualityProfile) Profile() quality.Profile
Profile converts the record into the decision engine's view of it.
type ReadingHistoryEntry ¶ added in v1.0.0
type ReadingHistoryEntry struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
BookTitle string `json:"book_title"`
Author string `json:"author"`
Format string `json:"format"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Rating *int `json:"rating,omitempty"`
Notes string `json:"notes"`
LibraryItemID *int64 `json:"library_item_id,omitempty"`
Status string `json:"status"`
}
ReadingHistoryEntry represents a reading history record.
type ReleaseProfile ¶ added in v1.0.0
type ReleaseProfile struct {
ID int64 `json:"id"`
Name string `json:"name"`
MustContain []string `json:"must_contain"`
MustNotContain []string `json:"must_not_contain"`
Preferred []PreferredWord `json:"preferred"`
Enabled bool `json:"enabled"`
}
ReleaseProfile represents a release profile record.