Documentation
¶
Overview ¶
Package db provides database models and data access functions.
Package db provides database models and data access functions.
Package db provides database models and data access functions.
Package db provides database models and data access functions.
Package db provides database models and data access functions.
Index ¶
- Variables
- func AddTagToPodcast(id, tagID string) error
- func AssertNoPodcastsExist(t *testing.T, database *gorm.DB)
- func AssertPodcastItemCount(t *testing.T, database *gorm.DB, podcastID string, expectedCount int)
- func CreatePodcast(podcast *Podcast) error
- func CreatePodcastItem(podcastItem *PodcastItem) error
- func CreateTag(tag *Tag) error
- func DeletePodcastByID(id string) error
- func DeletePodcastItemByID(id string) error
- func DeleteTagByID(id string) error
- func ExecuteAndSaveMigration(mig localMigration) error
- func ForceSetLastEpisodeDate(podcastID string)
- func GetAllPodcastItems(podcasts *[]PodcastItem) error
- func GetAllPodcastItemsAlreadyDownloaded() (*[]PodcastItem, error)
- func GetAllPodcastItemsByIDs(podcastItemIDs []string) (*[]PodcastItem, error)
- func GetAllPodcastItemsByPodcastID(podcastID string, podcastItems *[]PodcastItem) error
- func GetAllPodcastItemsByPodcastIDs(podcastIDs []string, podcastItems *[]PodcastItem) error
- func GetAllPodcastItemsToBeDownloaded() (*[]PodcastItem, error)
- func GetAllPodcastItemsWithoutImage() (*[]PodcastItem, error)
- func GetAllPodcastItemsWithoutSize() (*[]PodcastItem, error)
- func GetAllPodcasts(podcasts *[]Podcast, sorting string) error
- func GetAllTags(sorting string) (*[]Tag, error)
- func GetDB() *gorm.DB
- func GetEpisodeNumber(podcastItemID, podcastID string) (int, error)
- func GetPaginatedPodcastItems(page, count int, downloadedOnly, playedOnly *bool, fromDate time.Time, ...) error
- func GetPaginatedPodcastItemsNew(queryModel *model.EpisodesFilter) (*[]PodcastItem, int64, error)
- func GetPaginatedTags(page, count int, tags *[]Tag, total *int64) error
- func GetPodcastByID(id string, podcast *Podcast) error
- func GetPodcastByTitleAndAuthor(title, author string, podcast *Podcast) error
- func GetPodcastByURL(url string, podcast *Podcast) error
- func GetPodcastEpisodeStats() (*[]PodcastItemStatsModel, error)
- func GetPodcastItemByID(id string, podcastItem *PodcastItem) error
- func GetPodcastItemByPodcastIDAndGUID(podcastID, guid string, podcastItem *PodcastItem) error
- func GetPodcastItemsByPodcastIDAndGUIDs(podcastID string, guids []string) (*[]PodcastItem, error)
- func GetPodcastsByURLList(urls []string, podcasts *[]Podcast) error
- func GetTagsByIDs(ids []string) (*[]Tag, error)
- func Init() (*gorm.DB, error)
- func Lock(name string, duration int)
- func Migrate()
- func RemoveTagFromPodcast(id, tagID string) error
- func RunMigrations()
- func SetAllEpisodesToDownload(podcastID string) error
- func SetupTestDB(t *testing.T) *gorm.DB
- func TeardownTestDB(t *testing.T, database *gorm.DB)
- func TogglePodcastPauseStatus(podcastID string, isPaused bool) error
- func Unlock(name string)
- func UnlockMissedJobs()
- func UntagAllByTagID(tagID string) error
- func UpdateLastEpisodeDateForPodcast(podcastID string, lastEpisode time.Time) error
- func UpdatePodcast(podcast *Podcast) error
- func UpdatePodcastItem(podcastItem *PodcastItem) error
- func UpdatePodcastItemFileSize(podcastItemID string, size int64) error
- func UpdateSettings(setting *Setting) error
- func UpdateTag(tag *Tag) error
- type Base
- type DownloadStatus
- type JobLock
- type Migration
- type Podcast
- type PodcastItem
- type PodcastItemConsolidateDiskStatsModel
- type PodcastItemDiskStatsModel
- type PodcastItemStatsModel
- type Setting
- type Tag
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
DB is
Functions ¶
func AddTagToPodcast ¶
AddTagToPodcast add tag to podcast.
func AssertNoPodcastsExist ¶
AssertNoPodcastsExist verifies the database has no podcasts.
func AssertPodcastItemCount ¶
AssertPodcastItemCount verifies the expected number of podcast items exist.
func CreatePodcastItem ¶
func CreatePodcastItem(podcastItem *PodcastItem) error
CreatePodcastItem create podcast item.
func DeletePodcastByID ¶
DeletePodcastByID delete podcast by id.
func DeletePodcastItemByID ¶
DeletePodcastItemByID delete podcast item by id.
func ExecuteAndSaveMigration ¶
func ExecuteAndSaveMigration(mig localMigration) error
ExecuteAndSaveMigration execute and save migration.
func ForceSetLastEpisodeDate ¶
func ForceSetLastEpisodeDate(podcastID string)
ForceSetLastEpisodeDate force set last episode date.
func GetAllPodcastItems ¶
func GetAllPodcastItems(podcasts *[]PodcastItem) error
GetAllPodcastItems get all podcast items.
func GetAllPodcastItemsAlreadyDownloaded ¶
func GetAllPodcastItemsAlreadyDownloaded() (*[]PodcastItem, error)
GetAllPodcastItemsAlreadyDownloaded get all podcast items already downloaded.
func GetAllPodcastItemsByIDs ¶
func GetAllPodcastItemsByIDs(podcastItemIDs []string) (*[]PodcastItem, error)
GetAllPodcastItemsByIDs get all podcast items by ids.
func GetAllPodcastItemsByPodcastID ¶
func GetAllPodcastItemsByPodcastID(podcastID string, podcastItems *[]PodcastItem) error
GetAllPodcastItemsByPodcastID get all podcast items by podcast id.
func GetAllPodcastItemsByPodcastIDs ¶
func GetAllPodcastItemsByPodcastIDs(podcastIDs []string, podcastItems *[]PodcastItem) error
GetAllPodcastItemsByPodcastIDs get all podcast items by podcast ids.
func GetAllPodcastItemsToBeDownloaded ¶
func GetAllPodcastItemsToBeDownloaded() (*[]PodcastItem, error)
GetAllPodcastItemsToBeDownloaded get all podcast items to be downloaded.
func GetAllPodcastItemsWithoutImage ¶
func GetAllPodcastItemsWithoutImage() (*[]PodcastItem, error)
GetAllPodcastItemsWithoutImage get all podcast items without image.
func GetAllPodcastItemsWithoutSize ¶
func GetAllPodcastItemsWithoutSize() (*[]PodcastItem, error)
GetAllPodcastItemsWithoutSize get all podcast items without size.
func GetAllPodcasts ¶
GetAllPodcasts get all podcasts.
func GetEpisodeNumber ¶
GetEpisodeNumber get episode number.
func GetPaginatedPodcastItems ¶
func GetPaginatedPodcastItems(page, count int, downloadedOnly, playedOnly *bool, fromDate time.Time, podcasts *[]PodcastItem, total *int64) error
GetPaginatedPodcastItems get paginated podcast items.
func GetPaginatedPodcastItemsNew ¶
func GetPaginatedPodcastItemsNew(queryModel *model.EpisodesFilter) (*[]PodcastItem, int64, error)
GetPaginatedPodcastItemsNew get paginated podcast items new.
func GetPaginatedTags ¶
GetPaginatedTags get paginated tags.
func GetPodcastByID ¶
GetPodcastByID get podcast by id.
func GetPodcastByTitleAndAuthor ¶
GetPodcastByTitleAndAuthor get podcast by title and author.
func GetPodcastByURL ¶
GetPodcastByURL get podcast by u r l.
func GetPodcastEpisodeStats ¶
func GetPodcastEpisodeStats() (*[]PodcastItemStatsModel, error)
GetPodcastEpisodeStats get podcast episode stats.
func GetPodcastItemByID ¶
func GetPodcastItemByID(id string, podcastItem *PodcastItem) error
GetPodcastItemByID get podcast item by id.
func GetPodcastItemByPodcastIDAndGUID ¶
func GetPodcastItemByPodcastIDAndGUID(podcastID, guid string, podcastItem *PodcastItem) error
GetPodcastItemByPodcastIDAndGUID get podcast item by podcast id and g u i d.
func GetPodcastItemsByPodcastIDAndGUIDs ¶
func GetPodcastItemsByPodcastIDAndGUIDs(podcastID string, guids []string) (*[]PodcastItem, error)
GetPodcastItemsByPodcastIDAndGUIDs get podcast items by podcast id and g u i ds.
func GetPodcastsByURLList ¶
GetPodcastsByURLList get podcasts by u r l list.
func RemoveTagFromPodcast ¶
RemoveTagFromPodcast remove tag from podcast.
func SetAllEpisodesToDownload ¶
SetAllEpisodesToDownload set all episodes to download.
func SetupTestDB ¶
SetupTestDB creates an in-memory SQLite database for testing. It automatically runs migrations and returns the database connection. The database is isolated per test and will be cleaned up automatically.
func TeardownTestDB ¶
TeardownTestDB closes the database connection and cleans up resources.
func TogglePodcastPauseStatus ¶
TogglePodcastPauseStatus toggle podcast pause status.
func UntagAllByTagID ¶
UntagAllByTagID untag all by tag id.
func UpdateLastEpisodeDateForPodcast ¶
UpdateLastEpisodeDateForPodcast update last episode date for podcast.
func UpdatePodcastItem ¶
func UpdatePodcastItem(podcastItem *PodcastItem) error
UpdatePodcastItem update podcast item.
func UpdatePodcastItemFileSize ¶
UpdatePodcastItemFileSize update podcast item file size.
Types ¶
type Base ¶
type Base struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `gorm:"index"`
ID string `sql:"type:uuid;primary_key"`
}
Base is
type DownloadStatus ¶
type DownloadStatus int
DownloadStatus represents the download state of a podcast episode.
const ( // NotDownloaded indicates the episode has not been downloaded yet. NotDownloaded DownloadStatus = iota // Downloading indicates the episode is currently being downloaded. Downloading // Downloaded indicates the episode has been successfully downloaded. Downloaded // Deleted indicates the episode file has been removed. Deleted )
Download status constants.
type Podcast ¶
type Podcast struct {
Base
Title string
Summary string `gorm:"type:text"`
Author string
Image string
URL string
LastEpisode *time.Time
PodcastItems []PodcastItem
Tags []*Tag `gorm:"many2many:podcast_tags;"`
DownloadedEpisodesCount int `gorm:"-"`
DownloadingEpisodesCount int `gorm:"-"`
AllEpisodesCount int `gorm:"-"`
DownloadedEpisodesSize int64 `gorm:"-"`
DownloadingEpisodesSize int64 `gorm:"-"`
AllEpisodesSize int64 `gorm:"-"`
IsPaused bool `gorm:"default:false"`
}
Podcast is
func AssertPodcastExists ¶
AssertPodcastExists verifies a podcast exists with the given URL.
type PodcastItem ¶
type PodcastItem struct {
Base
PubDate time.Time
BookmarkDate time.Time
DownloadDate time.Time
FileURL string
PodcastID string
LocalImage string
Summary string `gorm:"type:text"`
Title string
GUID string
Image string
EpisodeType string
DownloadPath string
Podcast Podcast
DownloadStatus DownloadStatus `gorm:"default:0"`
Duration int
FileSize int64
IsPlayed bool `gorm:"default:false"`
}
PodcastItem is
func CreateTestPodcastItem ¶
func CreateTestPodcastItem(t *testing.T, database *gorm.DB, podcastID string, overrides ...*PodcastItem) *PodcastItem
CreateTestPodcastItem creates a test podcast item with default values.
type PodcastItemConsolidateDiskStatsModel ¶
type PodcastItemConsolidateDiskStatsModel struct {
Downloaded int64
Downloading int64
NotDownloaded int64
Deleted int64
PendingDownload int64
}
PodcastItemConsolidateDiskStatsModel represents podcast item consolidate disk stats model data.
func GetPodcastEpisodeDiskStats ¶
func GetPodcastEpisodeDiskStats() (PodcastItemConsolidateDiskStatsModel, error)
GetPodcastEpisodeDiskStats get podcast episode disk stats.
type PodcastItemDiskStatsModel ¶
type PodcastItemDiskStatsModel struct {
DownloadStatus DownloadStatus
Count int
Size int64
}
PodcastItemDiskStatsModel represents podcast item disk stats model data.
type PodcastItemStatsModel ¶
type PodcastItemStatsModel struct {
PodcastID string
DownloadStatus DownloadStatus
Count int
Size int64
}
PodcastItemStatsModel represents podcast item stats model data.
type Setting ¶
type Setting struct {
Base
FileNameFormat string `gorm:"default:%EpisodeTitle%"`
UserAgent string
BaseURL string
InitialDownloadCount int `gorm:"default:5"`
MaxDownloadConcurrency int `gorm:"default:5"`
MaxDownloadKeep int `gorm:"default:0"`
DarkMode bool `gorm:"default:false"`
DownloadEpisodeImages bool `gorm:"default:false"`
GenerateNFOFile bool `gorm:"default:false"`
DontDownloadDeletedFromDisk bool `gorm:"default:false"`
AutoDownload bool `gorm:"default:true"`
DownloadOnAdd bool `gorm:"default:true"`
PassthroughPodcastGUID bool `gorm:"default:false"`
}
Setting represents setting data.
func CreateTestSetting ¶
CreateTestSetting creates test settings with default values.
func GetOrCreateSetting ¶
func GetOrCreateSetting() *Setting
GetOrCreateSetting get or create setting.