Skip to content

Commit

Permalink
Update timestamp on access
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Feb 26, 2024
1 parent 2839a7e commit 60886a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/polar/streams/item/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ defmodule Polar.Streams.Item.Manager do
|> Repo.insert!()

%Item.Access{id: item_access_id} = item_access ->
timestamp = DateTime.utc_now()

from(ia in Item.Access,
update: [inc: [count: 1]],
update: [inc: [count: 1], set: [updated_at: ^timestamp]],
where: ia.id == ^item_access_id
)
|> Repo.update_all([])
Expand Down
4 changes: 1 addition & 3 deletions lib/polar_web/controllers/streams/item_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ defmodule PolarWeb.Streams.ItemController do

Streams.record_item_access(item, credential)

endpoint = credential.space.cdn_host || default_cdn_host

url = Path.join(["https://", endpoint, item.path])
url = Path.join(["https://", default_cdn_host, item.path])

redirect(conn, external: url)
end
Expand Down

0 comments on commit 60886a1

Please sign in to comment.