Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit9725bcb

Browse files
authored
refactor(job-thread): use tag instead of model field (#376)
* refactor(job-thread): remove domain fields* refactor(job-thread): remove domain args on test* chore: remove unused files* feat(paged-articles): support multi tags query* refactor(paged-articles): improve should pin judge logic
1 parent157ac79 commit9725bcb

File tree

15 files changed

+101
-766
lines changed

15 files changed

+101
-766
lines changed

‎lib/groupher_server/cms/delegates/article_curd.ex‎

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -254,52 +254,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
254254
ORM.find_by(Author,user_id:changeset.data.user_id)
255255
end
256256

257-
defpdomain_filter_query(CMS.Job=queryable,filter)do
258-
Enum.reduce(filter,queryable,fn
259-
{:salary,salary},queryable->
260-
queryable|>where([content],content.salary==^salary)
261-
262-
{:field,field},queryable->
263-
queryable|>where([content],content.field==^field)
264-
265-
{:finance,finance},queryable->
266-
queryable|>where([content],content.finance==^finance)
267-
268-
{:scale,scale},queryable->
269-
queryable|>where([content],content.scale==^scale)
270-
271-
{:exp,exp},queryable->
272-
ifexp=="不限",do:queryable,else:queryable|>where([content],content.exp==^exp)
273-
274-
{:education,education},queryable->
275-
conddo
276-
education=="大专"->
277-
queryable
278-
|>where([content],content.education=="大专"orcontent.education=="不限")
279-
280-
education=="本科"->
281-
queryable
282-
|>where([content],content.education!="不限")
283-
|>where([content],content.education!="大专")
284-
285-
education=="硕士"->
286-
queryable
287-
|>where([content],content.education!="不限")
288-
|>where([content],content.education!="大专")
289-
|>where([content],content.education!="本科")
290-
291-
education=="不限"->
292-
queryable
293-
294-
true->
295-
queryable|>where([content],content.education==^education)
296-
end
297-
298-
{_,_},queryable->
299-
queryable
300-
end)
301-
end
302-
303257
defpdomain_filter_query(CMS.Repo=queryable,filter)do
304258
Enum.reduce(filter,queryable,fn
305259
{:sort,:most_github_star},queryable->
@@ -327,12 +281,11 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
327281
defpadd_pin_articles_ifneed(articles,querable,%{community:community}=filter)do
328282
thread=module_to_thread(querable)
329283

330-
with{:ok,_}<-should_add_pin?(filter),
284+
withtrue<-should_add_pin?(filter),
331285
true<-1==Map.get(articles,:page_number),
332286
{:ok,pinned_articles}<-
333287
PinnedArticle
334288
|>join(:inner,[p],cinassoc(p,:community))
335-
# |> join(:inner, [p], article in assoc(p, ^filter.thread))
336289
|>join(:inner,[p],articleinassoc(p,^thread))
337290
|>where([p,c,article],c.raw==^community)
338291
|>select([p,c,article],article)
@@ -347,13 +300,13 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
347300
defpadd_pin_articles_ifneed(articles,_querable,_filter),do:articles
348301

349302
# if filter contains like: tags, sort.., then don't add pin article
350-
# TODO: tag
351-
# defp should_add_pin?(%{page: 1, article_tag: :all, sort: :desc_inserted} = _filter) do
352-
defpshould_add_pin?(%{page:1,sort::desc_inserted}=_filter)do
353-
{:ok,:pass}
303+
defpshould_add_pin?(%{page:1,sort::desc_inserted}=filter)do
304+
skip_pinned_fields=[:article_tag,:article_tags]
305+
306+
notEnum.any?(Map.keys(filter),&(&1inskip_pinned_fields))
354307
end
355308

356-
defpshould_add_pin?(_filter),do:{:error,:pass}
309+
defpshould_add_pin?(_filter),do:false
357310

358311
defpconcat_articles(%{total_count:0},non_pinned_articles),do:non_pinned_articles
359312

‎lib/groupher_server/cms/job.ex‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,20 @@ defmodule GroupherServer.CMS.Job do
1313
aliasHelper.HTML
1414

1515
@timestamps_opts[type::utc_datetime_usec]
16-
@required_fields~w(title companycompany_logobody digest length)a
16+
@required_fields~w(title company body digest length)a
1717
@article_cast_fieldsgeneral_article_fields(:cast)
18-
@optional_fields@article_cast_fields++
19-
~w(desc company_link link_addr copy_right salary exp education field finance scale)a
18+
@optional_fields@article_cast_fields++~w(desc company_link link_addr copy_right)a
2019

2120
@typet::%Job{}
2221
schema"cms_jobs"do
2322
field(:title,:string)
2423
field(:company,:string)
25-
field(:company_logo,:string)
2624
field(:company_link,:string)
2725
field(:desc,:string)
2826
field(:body,:string)
2927

3028
field(:link_addr,:string)
3129
field(:copy_right,:string)
32-
33-
field(:salary,:string)
34-
field(:exp,:string)
35-
field(:education,:string)
36-
field(:field,:string)
37-
field(:finance,:string)
38-
field(:scale,:string)
39-
4030
field(:digest,:string)
4131
field(:length,:integer)
4232

‎lib/groupher_server_web/schema/Helper/fields.ex‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ defmodule GroupherServerWeb.Schema.Helper.Fields do
4141
field(:when,:when_enum)
4242
field(:length,:length_enum)
4343
field(:article_tag,:string)
44+
field(:article_tags,list_of(:string))
4445
field(:community,:string)
4546
end
4647
end

‎lib/groupher_server_web/schema/account/account_misc.ex‎

Lines changed: 0 additions & 113 deletions
This file was deleted.

‎lib/groupher_server_web/schema/cms/cms_metrics.ex‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ defmodule GroupherServerWeb.Schema.CMS.Metrics do
206206
pagination_args()
207207
article_filter_fields()
208208
field(:sort,:sort_enum)
209-
210-
field(:salary,:string)
211-
field(:exp,:string)
212-
field(:education,:string)
213-
field(:field,:string)
214-
field(:finance,:string)
215-
field(:scale,:string)
216209
end
217210

218211
@desc"article_filter doc"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp