This commit is contained in:
parent
c6a1d6e12b
commit
6d9db86e30
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||||
|
|
Reference in a new issue