Skip to content

Commit 24c43ca

Browse files
committed
feat: add countries and regions fields to job postings and update job criteria retrieval
1 parent 001e87d commit 24c43ca

File tree

4 files changed

+226
-5
lines changed

4 files changed

+226
-5
lines changed

lib/algora/jobs/schemas/job_posting.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ defmodule Algora.Jobs.JobPosting do
1414
field :email, :string
1515
field :status, Ecto.Enum, values: [:initialized, :processing, :active, :expired], null: false, default: :initialized
1616
field :expires_at, :utc_datetime_usec
17+
# e.g. "SF Bay Area (Remote)"
1718
field :location, :string
19+
# e.g. ["US", "CA", "BR"]
20+
field :countries, {:array, :string}, default: []
21+
# e.g. ["LATAM", "NA"]
22+
field :regions, {:array, :string}, default: []
1823
field :compensation, :string
1924
field :seniority, :string
2025

@@ -38,7 +43,9 @@ defmodule Algora.Jobs.JobPosting do
3843
:user_id,
3944
:location,
4045
:compensation,
41-
:seniority
46+
:seniority,
47+
:countries,
48+
:regions
4249
])
4350
|> generate_id()
4451
|> validate_required([:url, :company_name, :company_url, :email])

lib/algora/psp/connect_countries.ex

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,198 @@ defmodule Algora.PSP.ConnectCountries do
139139
@spec account_type(String.t()) :: :standard | :express
140140
def account_type("BR"), do: :standard
141141
def account_type(_), do: :express
142+
143+
@spec regions() :: %{atom() => [String.t()]}
144+
def regions do
145+
%{
146+
"LATAM" => [
147+
"AR",
148+
"BO",
149+
"BR",
150+
"CL",
151+
"CO",
152+
"CR",
153+
"DO",
154+
"EC",
155+
"GT",
156+
"GY",
157+
"MX",
158+
"PA",
159+
"PE",
160+
"PY",
161+
"SV",
162+
"TT",
163+
"UY"
164+
],
165+
"APAC" => [
166+
"AU",
167+
"BD",
168+
"BN",
169+
"BT",
170+
"HK",
171+
"ID",
172+
"IN",
173+
"JP",
174+
"KH",
175+
"KR",
176+
"LA",
177+
"LK",
178+
"MO",
179+
"MM",
180+
"MN",
181+
"MY",
182+
"NZ",
183+
"PH",
184+
"PK",
185+
"SG",
186+
"TH",
187+
"TW",
188+
"VN"
189+
],
190+
"EMEA" => [
191+
"AE",
192+
"AL",
193+
"AM",
194+
"AO",
195+
"AT",
196+
"AZ",
197+
"BA",
198+
"BE",
199+
"BG",
200+
"BH",
201+
"BJ",
202+
"BW",
203+
"CH",
204+
"CI",
205+
"CY",
206+
"CZ",
207+
"DE",
208+
"DK",
209+
"DZ",
210+
"EE",
211+
"EG",
212+
"ES",
213+
"ET",
214+
"FI",
215+
"FR",
216+
"GA",
217+
"GB",
218+
"GH",
219+
"GI",
220+
"GM",
221+
"GR",
222+
"HR",
223+
"HU",
224+
"IE",
225+
"IL",
226+
"IS",
227+
"IT",
228+
"JO",
229+
"KE",
230+
"KW",
231+
"KZ",
232+
"LI",
233+
"LT",
234+
"LU",
235+
"LV",
236+
"MA",
237+
"MC",
238+
"MD",
239+
"MG",
240+
"MK",
241+
"MT",
242+
"MU",
243+
"MZ",
244+
"NA",
245+
"NG",
246+
"NL",
247+
"NO",
248+
"OM",
249+
"PL",
250+
"PT",
251+
"QA",
252+
"RO",
253+
"RS",
254+
"RW",
255+
"SA",
256+
"SE",
257+
"SI",
258+
"SK",
259+
"SM",
260+
"SN",
261+
"TN",
262+
"TR",
263+
"TZ",
264+
"ZA"
265+
],
266+
"NA" => [
267+
"US",
268+
"CA"
269+
],
270+
"EU" => [
271+
"AE",
272+
"AL",
273+
"AM",
274+
"AT",
275+
"AZ",
276+
"BA",
277+
"BE",
278+
"BG",
279+
"BH",
280+
"CH",
281+
"CY",
282+
"CZ",
283+
"DE",
284+
"DK",
285+
"EE",
286+
"EG",
287+
"ES",
288+
"FI",
289+
"FR",
290+
"GB",
291+
"GI",
292+
"GR",
293+
"HR",
294+
"HU",
295+
"IE",
296+
"IL",
297+
"IS",
298+
"IT",
299+
"JO",
300+
"KW",
301+
"KZ",
302+
"LI",
303+
"LT",
304+
"LU",
305+
"LV",
306+
"MA",
307+
"MC",
308+
"MD",
309+
"MK",
310+
"MT",
311+
"NL",
312+
"NO",
313+
"OM",
314+
"PL",
315+
"PT",
316+
"QA",
317+
"RO",
318+
"RS",
319+
"SA",
320+
"SE",
321+
"SI",
322+
"SK",
323+
"SM",
324+
"TN",
325+
"TR"
326+
]
327+
}
328+
end
329+
330+
def get_countries(region) do
331+
case regions()[region] do
332+
nil -> []
333+
countries -> countries
334+
end
335+
end
142336
end

lib/algora/settings/settings.ex

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule Algora.Settings do
66

77
alias Algora.Accounts
88
alias Algora.Accounts.User
9+
alias Algora.PSP.ConnectCountries
910
alias Algora.Repo
1011

1112
@primary_key {:key, :string, []}
@@ -118,10 +119,19 @@ defmodule Algora.Settings do
118119
set("job_criteria:#{job_id}", %{"criteria" => criteria})
119120
end
120121

121-
def get_job_criteria(job_id) do
122-
case get("job_criteria:#{job_id}") do
123-
%{"criteria" => criteria} when is_map(criteria) -> criteria
124-
_ -> %{}
122+
def get_job_criteria(job) do
123+
cond do
124+
job.countries != [] ->
125+
%{"countries" => job.countries}
126+
127+
job.regions != [] ->
128+
%{"regions" => job.regions}
129+
130+
true ->
131+
case get("job_criteria:#{job.id}") do
132+
%{"criteria" => criteria} when is_map(criteria) -> criteria
133+
_ -> %{}
134+
end
125135
end
126136
end
127137

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
defmodule Algora.Repo.Migrations.AddCountriesAndRegionsToJobPostings do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:job_postings) do
6+
add :countries, {:array, :string}, default: [], null: false
7+
add :regions, {:array, :string}, default: [], null: false
8+
end
9+
end
10+
end

0 commit comments

Comments
 (0)