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.

refactor(job-thread): use tag instead of model field#376

Merged
mydearxym merged 5 commits intodevfromrefactor-job-thread
May 31, 2021
Merged
Show file tree
Hide file tree
Changes fromall 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
59 changes: 6 additions & 53 deletionslib/groupher_server/cms/delegates/article_curd.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,52 +254,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
ORM.find_by(Author, user_id: changeset.data.user_id)
end

defp domain_filter_query(CMS.Job = queryable, filter) do
Enum.reduce(filter, queryable, fn
{:salary, salary}, queryable ->
queryable |> where([content], content.salary == ^salary)

{:field, field}, queryable ->
queryable |> where([content], content.field == ^field)

{:finance, finance}, queryable ->
queryable |> where([content], content.finance == ^finance)

{:scale, scale}, queryable ->
queryable |> where([content], content.scale == ^scale)

{:exp, exp}, queryable ->
if exp == "不限", do: queryable, else: queryable |> where([content], content.exp == ^exp)

{:education, education}, queryable ->
cond do
education == "大专" ->
queryable
|> where([content], content.education == "大专" or content.education == "不限")

education == "本科" ->
queryable
|> where([content], content.education != "不限")
|> where([content], content.education != "大专")

education == "硕士" ->
queryable
|> where([content], content.education != "不限")
|> where([content], content.education != "大专")
|> where([content], content.education != "本科")

education == "不限" ->
queryable

true ->
queryable |> where([content], content.education == ^education)
end

{_, _}, queryable ->
queryable
end)
end

defp domain_filter_query(CMS.Repo = queryable, filter) do
Enum.reduce(filter, queryable, fn
{:sort, :most_github_star}, queryable ->
Expand DownExpand Up@@ -327,12 +281,11 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
defp add_pin_articles_ifneed(articles, querable, %{community: community} = filter) do
thread = module_to_thread(querable)

with{:ok, _} <- should_add_pin?(filter),
withtrue <- should_add_pin?(filter),
true <- 1 == Map.get(articles, :page_number),
{:ok, pinned_articles} <-
PinnedArticle
|> join(:inner, [p], c in assoc(p, :community))
# |> join(:inner, [p], article in assoc(p, ^filter.thread))
|> join(:inner, [p], article in assoc(p, ^thread))
|> where([p, c, article], c.raw == ^community)
|> select([p, c, article], article)
Expand All@@ -347,13 +300,13 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
defp add_pin_articles_ifneed(articles, _querable, _filter), do: articles

# if filter contains like: tags, sort.., then don't add pin article
# TODO: tag
# defp should_add_pin?(%{page: 1, article_tag: :all, sort: :desc_inserted} = _filter) do
defp should_add_pin?(%{page: 1, sort: :desc_inserted} = _filter) do
{:ok, :pass}
defp should_add_pin?(%{page: 1, sort: :desc_inserted} = filter) do
skip_pinned_fields = [:article_tag, :article_tags]

not Enum.any?(Map.keys(filter), &(&1 in skip_pinned_fields))
end

defp should_add_pin?(_filter), do:{:error, :pass}
defp should_add_pin?(_filter), do:false

defp concat_articles(%{total_count: 0}, non_pinned_articles), do: non_pinned_articles

Expand Down
14 changes: 2 additions & 12 deletionslib/groupher_server/cms/job.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,30 +13,20 @@ defmodule GroupherServer.CMS.Job do
alias Helper.HTML

@timestamps_opts [type: :utc_datetime_usec]
@required_fields ~w(title companycompany_logobody digest length)a
@required_fields ~w(title company body digest length)a
@article_cast_fields general_article_fields(:cast)
@optional_fields @article_cast_fields ++
~w(desc company_link link_addr copy_right salary exp education field finance scale)a
@optional_fields @article_cast_fields ++ ~w(desc company_link link_addr copy_right)a

@type t :: %Job{}
schema "cms_jobs" do
field(:title, :string)
field(:company, :string)
field(:company_logo, :string)
field(:company_link, :string)
field(:desc, :string)
field(:body, :string)

field(:link_addr, :string)
field(:copy_right, :string)

field(:salary, :string)
field(:exp, :string)
field(:education, :string)
field(:field, :string)
field(:finance, :string)
field(:scale, :string)

field(:digest, :string)
field(:length, :integer)

Expand Down
1 change: 1 addition & 0 deletionslib/groupher_server_web/schema/Helper/fields.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,7 @@ defmodule GroupherServerWeb.Schema.Helper.Fields do
field(:when, :when_enum)
field(:length, :length_enum)
field(:article_tag, :string)
field(:article_tags, list_of(:string))
field(:community, :string)
end
end
Expand Down
113 changes: 0 additions & 113 deletionslib/groupher_server_web/schema/account/account_misc.ex
View file
Open in desktop

This file was deleted.

7 changes: 0 additions & 7 deletionslib/groupher_server_web/schema/cms/cms_metrics.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -206,13 +206,6 @@ defmodule GroupherServerWeb.Schema.CMS.Metrics do
pagination_args()
article_filter_fields()
field(:sort, :sort_enum)

field(:salary, :string)
field(:exp, :string)
field(:education, :string)
field(:field, :string)
field(:finance, :string)
field(:scale, :string)
end

@desc "article_filter doc"
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp