fix: Import
All checks were successful
Build / build (push) Successful in 4m8s

This commit is contained in:
Daniel Kempkens 2023-10-20 19:49:51 +02:00
parent c6a1d6e12b
commit 6d9db86e30
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM

View file

@ -144,10 +144,12 @@ defmodule BdfrBrowser.Importer do
@impl true @impl true
def handle_cast(:background_import, %State{last_import: last_import} = state) do def handle_cast(:background_import, %State{last_import: last_import} = state) do
current_time = System.os_time(:second)
_ = subreddits() _ = subreddits()
_ = posts_and_comments(last_import) _ = posts_and_comments(last_import)
_ = chats() _ = chats()
{:noreply, %State{state | last_import: System.os_time(:second)}} {:noreply, %State{state | last_import: current_time}}
end end
@impl true @impl true
@ -310,7 +312,7 @@ defmodule BdfrBrowser.Importer do
defp import_post(post, subreddit) when not is_nil(subreddit) do defp import_post(post, subreddit) when not is_nil(subreddit) do
id = post["id"] id = post["id"]
db_post = id |> Post.get_import() |> Repo.one() db_post = Repo.get(Post, id)
if is_nil(db_post) do if is_nil(db_post) do
%Post{ %Post{
@ -333,7 +335,7 @@ defmodule BdfrBrowser.Importer do
defp import_comment(comment, post, parent) when not is_nil(post) do defp import_comment(comment, post, parent) when not is_nil(post) do
id = comment["id"] id = comment["id"]
db_comment = id |> Comment.get_import() |> Repo.one() db_comment = Repo.get(Comment, id)
{:ok, parent} = {:ok, parent} =
if is_nil(db_comment) do if is_nil(db_comment) do