Skip to content

Commit

Permalink
Track feed latest refresh time
Browse files Browse the repository at this point in the history
  • Loading branch information
jerodsanto committed Jul 29, 2024
1 parent d8a0cfd commit 5869085
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/changelog/schema/feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ defmodule Changelog.Feed do
def preload_owner(query = %Ecto.Query{}), do: Ecto.Query.preload(query, :owner)
def preload_owner(feed), do: Repo.preload(feed, :owner)

def refresh!(feed) do
# using update_all to avoid auto `updated_at` change
query = from(q in __MODULE__, where: q.id == ^feed.id)
Repo.update_all(query, set: [refreshed_at: now_in_seconds()])
end

def starts_on_time(%{starts_on: nil}), do: nil

def starts_on_time(%{starts_on: date}) do
Expand Down
1 change: 1 addition & 0 deletions lib/changelog_web/feeds.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule ChangelogWeb.Feeds do
def refresh(feed = %Feed{slug: slug}) do
content = generate(feed)
upload(content, slug)
Feed.refresh!(feed)
notify_services(feed)

:ok
Expand Down
2 changes: 2 additions & 0 deletions lib/changelog_web/templates/admin/feed/_table.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<th>Owner</th>
<th>Cover</th>
<th>Name</th>
<th>Refreshed at</th>
<th>Starts on</th>
<th>Podcasts</th>
<th></th>
Expand Down Expand Up @@ -32,6 +33,7 @@
<span class="ui tiny green basic label">auto</span>
<% end %>
</td>
<td><%= AdminHelpers.ts(feed.refreshed_at) %></td>
<td><%= TimeView.hacker_date(feed.starts_on) %></td>
<td class="ui mini images">
<%= for podcast <- @podcasts do %>
Expand Down

0 comments on commit 5869085

Please sign in to comment.