Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread parse script #39

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions parse_by_thread.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Mix.install([{:httpoison, "~> 2.0"}, {:logger_file_backend, "~> 0.0.10"}])

defmodule ParseByThread do
require Logger

Logger.add_backend({LoggerFileBackend, :error})

Logger.configure_backend({LoggerFileBackend, :error},
path: "./parse_by_thread_error.log",
level: :error
)

@start_id 5_485_059
@end_id 1

def run do
for id <- @start_id..@end_id//-1 do
case HTTPoison.get("http://localhost:4000/api/posts?thread_id=#{id}") do
{:ok, %HTTPoison.Response{status_code: 200, body: _body}} ->
Logger.info("Successfully parsed thread with id (#{id})")

{:ok, %HTTPoison.Response{status_code: status_code}} ->
Logger.error("Thread with id (#{id}) received response with status code #{status_code}")

{:error, %HTTPoison.Error{reason: reason}} ->
Logger.error("Thread with id (#{id}) HTTP request failed: #{reason}")
end
end
end
end

ParseByThread.run()
Loading