@@ -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- defp domain_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- if exp == "不限" , do: queryable , else: queryable |> where ( [ content ] , content . exp == ^ exp )
273-
274- { :education , education } , queryable ->
275- cond do
276- education == "大专" ->
277- queryable
278- |> where ( [ content ] , content . education == "大专" or content . 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 defp domain_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 defp add_pin_articles_ifneed ( articles , querable , % { community: community } = filter ) do
328282 thread = module_to_thread ( querable )
329283
330- with { :ok , _ } <- should_add_pin? ( filter ) ,
284+ with true <- should_add_pin? ( filter ) ,
331285 true <- 1 == Map . get ( articles , :page_number ) ,
332286 { :ok , pinned_articles } <-
333287 PinnedArticle
334288 |> join ( :inner , [ p ] , c in assoc ( p , :community ) )
335- # |> join(:inner, [p], article in assoc(p, ^filter.thread))
336289 |> join ( :inner , [ p ] , article in assoc ( 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 defp add_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- defp should_add_pin? ( % { page: 1 , sort: :desc_inserted } = _filter ) do
353- { :ok , :pass }
303+ defp should_add_pin? ( % { page: 1 , sort: :desc_inserted } = filter ) do
304+ skip_pinned_fields = [ :article_tag , :article_tags ]
305+
306+ not Enum . any? ( Map . keys ( filter ) , & ( & 1 in skip_pinned_fields ) )
354307 end
355308
356- defp should_add_pin? ( _filter ) , do: { :error , :pass }
309+ defp should_add_pin? ( _filter ) , do: false
357310
358311 defp concat_articles ( % { total_count: 0 } , non_pinned_articles ) , do: non_pinned_articles
359312
0 commit comments