feat(feeds): show next run (#1074)

This commit is contained in:
ze0s 2023-09-02 23:06:21 +02:00 committed by GitHub
parent 6fd8626507
commit a6d789ee44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 5 deletions

View file

@ -52,6 +52,7 @@ type Feed struct {
Indexerr FeedIndexer `json:"-"`
LastRun time.Time `json:"last_run"`
LastRunData string `json:"last_run_data"`
NextRun time.Time `json:"next_run"`
}
type FeedSettingsJSON struct {

View file

@ -91,7 +91,21 @@ func (s *service) FindByIndexerIdentifier(ctx context.Context, indexer string) (
}
func (s *service) Find(ctx context.Context) ([]domain.Feed, error) {
return s.repo.Find(ctx)
feeds, err := s.repo.Find(ctx)
if err != nil {
return nil, err
}
for i, feed := range feeds {
t, err := s.scheduler.GetNextRun(feedKey{id: feed.ID}.ToString())
if err != nil {
continue
}
feed.NextRun = t
feeds[i] = feed
}
return feeds, nil
}
func (s *service) GetCacheByID(ctx context.Context, feedId int) ([]domain.FeedCacheItem, error) {

View file

@ -118,7 +118,7 @@ function FeedSettings() {
Enabled <span className="sort-indicator">{sortedFeeds.getSortIndicator("enabled")}</span>
</div>
<div
className="col-span-6 pl-12 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
className="col-span-5 pl-12 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
onClick={() => sortedFeeds.requestSort("name")}>
Name <span className="sort-indicator">{sortedFeeds.getSortIndicator("name")}</span>
</div>
@ -128,10 +128,15 @@ function FeedSettings() {
Type <span className="sort-indicator">{sortedFeeds.getSortIndicator("type")}</span>
</div>
<div
className="hidden md:flex col-span-3 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
className="hidden md:flex col-span-2 px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
onClick={() => sortedFeeds.requestSort("last_run")}>
Last run <span className="sort-indicator">{sortedFeeds.getSortIndicator("last_run")}</span>
</div>
<div
className="hidden md:flex col-span-2 px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
onClick={() => sortedFeeds.requestSort("next_run")}>
Next run <span className="sort-indicator">{sortedFeeds.getSortIndicator("next_run")}</span>
</div>
</li>
{sortedFeeds.items.map((feed) => (
<ListItem key={feed.id} feed={feed}/>
@ -193,7 +198,7 @@ function ListItem({ feed }: ListItemProps) {
/>
</Switch>
</div>
<div className="col-span-8 sm:col-span-6 pl-12 py-3 flex flex-col text-sm font-medium text-gray-900 dark:text-white">
<div className="col-span-8 sm:col-span-5 pl-12 py-3 flex flex-col text-sm font-medium text-gray-900 dark:text-white">
<span>{feed.name}</span>
<span className="text-gray-900 dark:text-gray-500 text-xs">
{feed.indexer}
@ -202,11 +207,16 @@ function ListItem({ feed }: ListItemProps) {
<div className="hidden md:flex col-span-1 py-3 items-center">
{ImplementationBadges[feed.type.toLowerCase()]}
</div>
<div className="hidden md:flex col-span-3 py-3 items-center sm:px-6 text-sm font-medium text-gray-900 dark:text-gray-500">
<div className="hidden md:flex col-span-2 py-3 items-center sm:px-4 text-sm font-medium text-gray-900 dark:text-gray-500">
<span title={simplifyDate(feed.last_run)}>
{IsEmptyDate(feed.last_run)}
</span>
</div>
<div className="hidden md:flex col-span-2 py-3 items-center sm:px-4 text-sm font-medium text-gray-900 dark:text-gray-500">
<span title={simplifyDate(feed.next_run)}>
{IsEmptyDate(feed.next_run)}
</span>
</div>
<div className="col-span-1 flex justify-center items-center sm:px-6">
<FeedItemDropdown
feed={feed}

View file

@ -17,6 +17,7 @@ interface Feed {
cookie: string;
last_run: string;
last_run_data: string;
next_run: string;
settings: FeedSettings;
created_at: Date;
updated_at: Date;