Skip to content

Commit 6077ed1

Browse files
committed
feat: improve job posting query and description rendering
1 parent c147f3e commit 6077ed1

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

lib/algora/admin/admin.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ defmodule Algora.Admin do
3535
company_url: user.website_url,
3636
title: opts.title,
3737
description: opts.description,
38-
tech_stack: opts.tech_stack || Enum.take(user.tech_stack, 1)
38+
tech_stack: opts.tech_stack || Enum.take(user.tech_stack, 1),
39+
status: opts[:status] || :initialized
3940
}) do
4041
dbg("#{AlgoraWeb.Endpoint.url()}/#{user.handle}/jobs/#{job.id}")
42+
{:ok, job}
4143
end
4244
end
4345

lib/algora/jobs/jobs.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ defmodule Algora.Jobs do
1717

1818
def list_jobs(opts \\ []) do
1919
JobPosting
20-
|> where([j], j.status == :active)
2120
|> order_by([j], desc: j.inserted_at)
2221
|> maybe_filter_by_user(opts[:user_id])
2322
|> maybe_filter_by_tech_stack(opts[:tech_stack])
@@ -32,10 +31,10 @@ defmodule Algora.Jobs do
3231
|> Repo.insert()
3332
end
3433

35-
defp maybe_filter_by_user(query, nil), do: query
34+
defp maybe_filter_by_user(query, nil), do: where(query, [j], j.status in [:active])
3635

3736
defp maybe_filter_by_user(query, user_id) do
38-
where(query, [j], j.user_id == ^user_id)
37+
where(query, [j], j.user_id == ^user_id and j.status in [:active, :processing])
3938
end
4039

4140
defp maybe_filter_by_tech_stack(query, nil), do: query

lib/algora_web/live/org/job_live.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule AlgoraWeb.Org.JobLive do
44

55
alias Algora.Accounts.User
66
alias Algora.Jobs
7+
alias Algora.Markdown
78
alias Algora.Repo
89
alias Algora.Settings
910
alias AlgoraWeb.Forms.BountyForm
@@ -171,8 +172,11 @@ defmodule AlgoraWeb.Org.JobLive do
171172
<div class="text-lg font-semibold">
172173
{@job.title}
173174
</div>
174-
<div :if={@job.description} class="pt-1 text-sm text-muted-foreground">
175-
{@job.description}
175+
<div
176+
:if={@job.description}
177+
class="pt-1 text-sm text-muted-foreground prose prose-invert max-w-none"
178+
>
179+
{Phoenix.HTML.raw(Markdown.render(@job.description))}
176180
</div>
177181
<div class="pt-2 flex flex-wrap gap-2">
178182
<%= for tech <- @job.tech_stack do %>

lib/algora_web/live/org/jobs_live.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule AlgoraWeb.Org.JobsLive do
44

55
alias Algora.Accounts
66
alias Algora.Jobs
7+
alias Algora.Markdown
78

89
require Logger
910

@@ -112,8 +113,11 @@ defmodule AlgoraWeb.Org.JobsLive do
112113
</div>
113114
<% end %>
114115
</div>
115-
<div :if={job.description} class="pt-1 text-sm text-muted-foreground">
116-
{job.description}
116+
<div
117+
:if={job.description}
118+
class="pt-1 text-sm text-muted-foreground prose prose-invert max-w-none"
119+
>
120+
{Phoenix.HTML.raw(Markdown.render(job.description))}
117121
</div>
118122
<div class="pt-2 flex flex-wrap gap-2">
119123
<%= for tech <- job.tech_stack do %>

0 commit comments

Comments
 (0)