Compare commits

...

2 Commits

Author SHA1 Message Date
Simon Ding
4341e31251 fix download stats 2025-11-13 00:05:41 +08:00
Simon Ding
53dda90c0f reduce arch support 2025-11-12 23:53:12 +08:00
3 changed files with 23 additions and 58 deletions

View File

@@ -63,7 +63,7 @@ jobs:
context: .
file: ./docker/Dockerfile
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/s390x,linux/ppc64le
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |

View File

@@ -179,14 +179,6 @@ func (s *Server) Start(addr string) (int, error) {
log.Infof("----------- Polaris Server Successfully Started on Port %d------------", p)
ticker := time.NewTicker(10 * time.Minute)
go func() {
for {
s.cacheDownloadedStatus()
<-ticker.C
}
}()
return p, nil
}

View File

@@ -89,10 +89,16 @@ type MediaWithStatus struct {
DownloadedNum int `json:"downloaded_num"`
}
func (s *Server) cacheDownloadedStatus() {
log.Info("cache watchlist downloaded/monitored status")
//missing: episode aired missing
//downloaded: all monitored episode downloaded
//monitoring: episode aired downloaded, but still has not aired episode
//for movie, only monitoring/downloaded
func (s *Server) GetTvWatchlist(c *gin.Context) (interface{}, error) {
list := s.db.GetMediaWatchlist(media.MediaTypeTv)
for _, item := range list {
res := make([]MediaWithStatus, len(list))
for i, item := range list {
var ms = MediaWithStatus{
Media: item,
MonitoredNum: 0,
@@ -120,51 +126,6 @@ func (s *Server) cacheDownloadedStatus() {
s.monitorNumCache.Set(item.ID, ms.MonitoredNum)
s.downloadNumCache.Set(item.ID, ms.DownloadedNum)
}
}
list = s.db.GetMediaWatchlist(media.MediaTypeMovie)
for _, item := range list {
_, ok2 := s.downloadNumCache.Get(item.ID)
if ok2 {
continue
}
dummyEp, err := s.db.GetMovieDummyEpisode(item.ID)
if err != nil {
log.Errorf("get dummy episode: %v", err)
} else {
if dummyEp.Status == episode.StatusDownloaded {
s.downloadNumCache.Set(item.ID, 1)
}
}
}
}
//missing: episode aired missing
//downloaded: all monitored episode downloaded
//monitoring: episode aired downloaded, but still has not aired episode
//for movie, only monitoring/downloaded
func (s *Server) GetTvWatchlist(c *gin.Context) (interface{}, error) {
list := s.db.GetMediaWatchlist(media.MediaTypeTv)
res := make([]MediaWithStatus, len(list))
for i, item := range list {
var ms = MediaWithStatus{
Media: item,
MonitoredNum: 0,
DownloadedNum: 0,
}
mon, ok1 := s.monitorNumCache.Get(item.ID)
dow, ok2 := s.downloadNumCache.Get(item.ID)
if ok1 && ok2 {
ms.MonitoredNum = mon
ms.DownloadedNum = dow
} else {
continue
}
res[i] = ms
}
@@ -183,7 +144,19 @@ func (s *Server) GetMovieWatchlist(c *gin.Context) (interface{}, error) {
dow, ok2 := s.downloadNumCache.Get(item.ID)
if ok2 {
ms.DownloadedNum = dow
}
} else {
dummyEp, err := s.db.GetMovieDummyEpisode(item.ID)
if err != nil {
log.Errorf("get dummy episode: %v", err)
} else {
ms.DownloadedNum++
if dummyEp.Status == episode.StatusDownloaded {
s.downloadNumCache.Set(item.ID, 1)
}
}
}
res[i] = ms
}
return res, nil