Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit f732033

Browse files
committed
chore: update pkgs & rm all rest warnings
1 parent 445881c commit f732033

File tree

21 files changed

+103
-114
lines changed

21 files changed

+103
-114
lines changed

lib/helper/radar_search.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ defmodule Helper.RadarSearch do
4848
end
4949

5050
# not valid io, just ignore it
51-
def locate_city(_ip), do: {:error, "invalid ip"}
51+
# def locate_city(_ip), do: {:error, "invalid ip"}
5252

5353
defp handle_result({:ok, result}) do
5454
case result do

lib/mastani_server/accounts/delegates/achievements.ex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ defmodule MastaniServer.Accounts.Delegate.Achievements do
121121
end
122122
end
123123

124-
@spec safe_minus(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
125-
defp safe_minus(count, unit) when is_integer(count) and is_integer(unit) and unit > 0 do
126-
case count <= 0 do
127-
true ->
128-
0
129-
130-
false ->
131-
count - unit
132-
end
133-
end
124+
# @spec safe_minus(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
125+
# defp safe_minus(count, unit) when is_integer(count) and is_integer(unit) and unit > 0 do
126+
# case count <= 0 do
127+
# true ->
128+
# 0
129+
130+
# false ->
131+
# count - unit
132+
# end
133+
# end
134134

135135
@doc """
136136
list communities which the user is editor in it

lib/mastani_server/accounts/delegates/mails.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule MastaniServer.Accounts.Delegate.Mails do
1313
def fetch_mentions(%User{} = user, filter) do
1414
with {:ok, mentions} <- Delivery.fetch_mentions(user, filter),
1515
{:ok, washed_mentions} <- wash_data(MentionMail, mentions.entries) do
16-
result = MentionMail |> Repo.insert_all(washed_mentions)
16+
MentionMail |> Repo.insert_all(washed_mentions)
1717
MentionMail |> messages_fetcher(washed_mentions, user, filter)
1818
end
1919
end
@@ -43,7 +43,7 @@ defmodule MastaniServer.Accounts.Delegate.Mails do
4343
end
4444
end
4545

46-
defp messages_fetcher(queryable, washed_data, %User{id: user_id}, %{
46+
defp messages_fetcher(queryable, _washed_data, %User{id: user_id}, %{
4747
page: page,
4848
size: size,
4949
read: read

lib/mastani_server/cms/delegates/article_curd.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
132132
{:error, [message: "set community flag", code: ecode(:create_fails)]}
133133
end
134134

135-
defp create_content_result({:error, :set_topic, result, _steps}) do
135+
defp create_content_result({:error, :set_topic, _result, _steps}) do
136136
{:error, [message: "set topic", code: ecode(:create_fails)]}
137137
end
138138

@@ -227,7 +227,7 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
227227
|> join(:inner, [p], content in assoc(p, :post))
228228
|> where(
229229
[p, c, t, content],
230-
c.raw == ^filter.community and t.raw == ^Map.get(filter, :topic, "posts")
230+
c.raw == ^community and t.raw == ^Map.get(filter, :topic, "posts")
231231
)
232232
|> select([p, c, t, content], content)
233233
# 10 pined contents per community/thread, at most
@@ -241,19 +241,21 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
241241
end
242242
end
243243

244-
defp add_pin_contents_ifneed(contents, CMS.Job, %{community: community} = filter) do
244+
defp add_pin_contents_ifneed(contents, CMS.Job, %{community: _community} = filter) do
245245
merge_pin_contents(contents, :job, CMS.PinedJob, filter)
246246
end
247247

248-
defp add_pin_contents_ifneed(contents, CMS.Video, %{community: community} = filter) do
248+
defp add_pin_contents_ifneed(contents, CMS.Video, %{community: _community} = filter) do
249249
merge_pin_contents(contents, :video, CMS.PinedVideo, filter)
250250
end
251251

252-
defp add_pin_contents_ifneed(contents, CMS.Repo, %{community: community} = filter) do
252+
defp add_pin_contents_ifneed(contents, CMS.Repo, %{community: _community} = filter) do
253253
merge_pin_contents(contents, :repo, CMS.PinedRepo, filter)
254254
end
255255

256-
defp merge_pin_contents(contents, thread, pin_schema, %{community: community} = filter) do
256+
defp add_pin_contents_ifneed(contents, _querable, _filter), do: contents
257+
258+
defp merge_pin_contents(contents, thread, pin_schema, %{community: _community} = filter) do
257259
with {:ok, normal_contents} <- contents,
258260
true <- Map.has_key?(filter, :community),
259261
true <- 1 == Map.get(normal_contents, :page_number) do
@@ -274,8 +276,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
274276
end
275277
end
276278

277-
defp add_pin_contents_ifneed(contents, _querable, _filter), do: contents
278-
279279
defp concat_contents(pined_content, normal_contents) do
280280
case pined_content |> Map.get(:total_count) do
281281
0 ->

lib/mastani_server/cms/delegates/article_operation.ex

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
4141
end
4242
end
4343

44-
def undo_pin_content(%Post{id: post_id}, %Community{id: community_id}, topic) do
45-
with {:ok, %{id: topic_id}} <- ORM.find_by(Topic, %{raw: topic}),
46-
{:ok, pined} <- ORM.find_by(PinedPost, ~m(post_id community_id topic_id)a),
47-
{:ok, deleted} <- ORM.delete(pined) do
48-
Post |> ORM.find(deleted.post_id)
49-
end
50-
end
51-
5244
def pin_content(%Job{id: job_id}, %Community{id: community_id}) do
5345
attrs = ~m(job_id community_id)a
5446

@@ -57,13 +49,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
5749
end
5850
end
5951

60-
def undo_pin_content(%Job{id: job_id}, %Community{id: community_id}) do
61-
with {:ok, pined} <- ORM.find_by(PinedJob, ~m(job_id community_id)a),
62-
{:ok, deleted} <- ORM.delete(pined) do
63-
Job |> ORM.find(deleted.job_id)
64-
end
65-
end
66-
6752
def pin_content(%Video{id: video_id}, %Community{id: community_id}) do
6853
attrs = ~m(video_id community_id)a
6954

@@ -72,13 +57,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
7257
end
7358
end
7459

75-
def undo_pin_content(%Video{id: video_id}, %Community{id: community_id}) do
76-
with {:ok, pined} <- ORM.find_by(PinedVideo, ~m(video_id community_id)a),
77-
{:ok, deleted} <- ORM.delete(pined) do
78-
Video |> ORM.find(deleted.video_id)
79-
end
80-
end
81-
8260
def pin_content(%CMSRepo{id: repo_id}, %Community{id: community_id}) do
8361
attrs = ~m(repo_id community_id)a
8462

@@ -87,6 +65,28 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
8765
end
8866
end
8967

68+
def undo_pin_content(%Post{id: post_id}, %Community{id: community_id}, topic) do
69+
with {:ok, %{id: topic_id}} <- ORM.find_by(Topic, %{raw: topic}),
70+
{:ok, pined} <- ORM.find_by(PinedPost, ~m(post_id community_id topic_id)a),
71+
{:ok, deleted} <- ORM.delete(pined) do
72+
Post |> ORM.find(deleted.post_id)
73+
end
74+
end
75+
76+
def undo_pin_content(%Job{id: job_id}, %Community{id: community_id}) do
77+
with {:ok, pined} <- ORM.find_by(PinedJob, ~m(job_id community_id)a),
78+
{:ok, deleted} <- ORM.delete(pined) do
79+
Job |> ORM.find(deleted.job_id)
80+
end
81+
end
82+
83+
def undo_pin_content(%Video{id: video_id}, %Community{id: community_id}) do
84+
with {:ok, pined} <- ORM.find_by(PinedVideo, ~m(video_id community_id)a),
85+
{:ok, deleted} <- ORM.delete(pined) do
86+
Video |> ORM.find(deleted.video_id)
87+
end
88+
end
89+
9090
def undo_pin_content(%CMSRepo{id: repo_id}, %Community{id: community_id}) do
9191
with {:ok, pined} <- ORM.find_by(PinedRepo, ~m(repo_id community_id)a),
9292
{:ok, deleted} <- ORM.delete(pined) do
@@ -222,16 +222,16 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
222222

223223
# make sure the reuest tag is in the current community thread
224224
# example: you can't set a other thread tag to this thread's article
225-
defp tag_in_community_thread?(%Community{id: communityId}, thread, tag) do
226-
with {:ok, community} <- ORM.find(Community, communityId) do
227-
matched_tags =
228-
Tag
229-
|> where([t], t.community_id == ^community.id)
230-
# |> where([t], t.thread == ^(to_string(thread) |> String.upcase()))
231-
|> where([t], t.thread == ^to_string(thread))
232-
|> Repo.all()
233-
234-
tag in matched_tags
235-
end
236-
end
225+
226+
# defp tag_in_community_thread?(%Community{id: communityId}, thread, tag) do
227+
# with {:ok, community} <- ORM.find(Community, communityId) do
228+
# matched_tags =
229+
# Tag
230+
# |> where([t], t.community_id == ^community.id)
231+
# |> where([t], t.thread == ^to_string(thread))
232+
# |> Repo.all()
233+
234+
# tag in matched_tags
235+
# end
236+
# end
237237
end

lib/mastani_server/cms/delegates/community_curd.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ defmodule MastaniServer.CMS.Delegate.CommunityCURD do
7373

7474
with {:ok, %{id: topic_id}} = find_or_insert_topic(attrs) do
7575
Tag
76-
|> ORM.find_update(~m(id title color color topic_id)a)
76+
|> ORM.find_update(~m(id title color topic_id)a)
7777
end
7878
end
7979

lib/mastani_server/cms/delegates/passport_curd.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule MastaniServer.CMS.Delegate.PassportCURD do
3030
{:ok, passport} ->
3131
{:ok, passport.rules}
3232

33-
{:error, error} ->
33+
{:error, _error} ->
3434
{:ok, %{}}
3535
end
3636
end

lib/mastani_server/cms/delegates/search.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule MastaniServer.CMS.Delegate.Search do
1414
@doc """
1515
search community by title
1616
"""
17-
def search_items(:community, %{title: title} = args) do
17+
def search_items(:community, %{title: title} = _args) do
1818
Community
1919
|> where([c], ilike(c.title, ^"%#{title}%") or ilike(c.raw, ^"%#{title}%"))
2020
|> ORM.paginater(page: 1, size: @search_items_count)
@@ -24,7 +24,7 @@ defmodule MastaniServer.CMS.Delegate.Search do
2424
@doc """
2525
search post by title
2626
"""
27-
def search_items(:post, %{title: title} = args) do
27+
def search_items(:post, %{title: title} = _args) do
2828
Post
2929
|> where([c], ilike(c.title, ^"%#{title}%") or ilike(c.digest, ^"%#{title}%"))
3030
|> ORM.paginater(page: 1, size: @search_items_count)
@@ -34,7 +34,7 @@ defmodule MastaniServer.CMS.Delegate.Search do
3434
@doc """
3535
search job by title or company name
3636
"""
37-
def search_items(:job, %{title: title} = args) do
37+
def search_items(:job, %{title: title} = _args) do
3838
Job
3939
|> where([c], ilike(c.title, ^"%#{title}%") or ilike(c.company, ^"%#{title}%"))
4040
|> ORM.paginater(page: 1, size: @search_items_count)
@@ -44,7 +44,7 @@ defmodule MastaniServer.CMS.Delegate.Search do
4444
@doc """
4545
search video by title
4646
"""
47-
def search_items(:video, %{title: title} = args) do
47+
def search_items(:video, %{title: title} = _args) do
4848
Video
4949
|> where([c], ilike(c.title, ^"%#{title}%") or ilike(c.desc, ^"%#{title}%"))
5050
|> ORM.paginater(page: 1, size: @search_items_count)
@@ -54,7 +54,7 @@ defmodule MastaniServer.CMS.Delegate.Search do
5454
@doc """
5555
search repo by title
5656
"""
57-
def search_items(:repo, %{title: title} = args) do
57+
def search_items(:repo, %{title: title} = _args) do
5858
Repo
5959
|> where([c], ilike(c.title, ^"%#{title}%") or ilike(c.owner_name, ^"%#{title}%"))
6060
|> ORM.paginater(page: 1, size: @search_items_count)

lib/mastani_server/cms/delegates/seeds_config.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ defmodule MastaniServer.CMS.Delegate.SeedsConfig do
326326
|> Enum.map(fn attr -> Map.merge(%{thread: :video, topic: "videos"}, attr) end)
327327
end
328328

329+
def tags(_), do: []
330+
329331
def tags(:city, :post) do
330332
[
331333
%{
@@ -529,7 +531,6 @@ defmodule MastaniServer.CMS.Delegate.SeedsConfig do
529531
|> Enum.map(fn attr -> Map.merge(%{thread: :job, topic: "jobs"}, attr) end)
530532
end
531533

532-
def tags(_), do: []
533534
def tags(:home, _), do: []
534535

535536
defp city_tags do

lib/mastani_server/cms/post.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,4 @@ defmodule MastaniServer.CMS.Post do
8888
# |> foreign_key_constraint(:posts_tags, name: :posts_tags_tag_id_fkey)
8989
# |> foreign_key_constraint(name: :posts_tags_tag_id_fkey)
9090
end
91-
92-
@doc """
93-
for update flag
94-
"""
95-
# def flag_changeset(%Post{} = post, attrs) do
96-
# post
97-
# |> cast(attrs, ~w(pin trash)a)
98-
# end
9991
end

0 commit comments

Comments
 (0)