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(reaction): fields test kit#343

Merged
mydearxym merged 4 commits intodevfromreaction-fields-test-kit
May 9, 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
2 changes: 1 addition & 1 deletioncover/excoveralls.json
View file
Open in desktop

Large diffs are not rendered by default.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ defmodule GroupherServer.Accounts.Delegate.CollectFolder do
user collect folder related
"""
import Ecto.Query, warn: false
import GroupherServer.CMS.Utils.Matcher2
import GroupherServer.CMS.Helper.Matcher2

alias Helper.Types, as: T
alias Helper.QueryBuilder
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/accounts/delegates/publish.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
# import Helper.ErrorCode
import ShortMaps

import GroupherServer.CMS.Utils.Matcher
import GroupherServer.CMS.Helper.Matcher

alias Helper.{ORM, QueryBuilder}
# alias GroupherServer.{Accounts, Repo}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ defmodule GroupherServer.Accounts.Delegate.UpvotedArticles do
@moduledoc """
get contents(posts, jobs ...) that user upvotes
"""
# import GroupherServer.CMS.Utils.Matcher
# import GroupherServer.CMS.Helper.Matcher
import Ecto.Query, warn: false
import Helper.Utils, only: [done: 1]
import ShortMaps
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
defmodule GroupherServer.Accounts.Utils.Loader do
defmodule GroupherServer.Accounts.Helper.Loader do
@moduledoc """
dataloader for accounts
"""
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/accounts/user.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ defmodule GroupherServer.Accounts.User do

use Ecto.Schema

# import GroupherServerWeb.Schema.Utils.Helper
# import GroupherServerWeb.Schema.Helper.Fields
import Ecto.Changeset

alias GroupherServer.Accounts.{
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/cms/delegates/abuse_report.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do
import Ecto.Query, warn: false
# import Helper.Utils, only: [done: 1]

import GroupherServer.CMS.Utils.Matcher2
import GroupherServer.CMS.Helper.Matcher2
# import ShortMaps

alias Helper.{ORM}
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/cms/delegates/article_comment.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
import Helper.Utils, only: [done: 1]
import Helper.ErrorCode

import GroupherServer.CMS.Utils.Matcher2
import GroupherServer.CMS.Helper.Matcher2
import ShortMaps

alias Helper.Types, as: T
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
import GroupherServer.CMS.Delegate.ArticleComment,
only: [add_participator_to_article: 2, do_create_comment: 4, update_article_comments_count: 2]

import GroupherServer.CMS.Utils.Matcher2
import GroupherServer.CMS.Helper.Matcher2

alias Helper.Types, as: T
alias Helper.ORM
Expand Down
4 changes: 2 additions & 2 deletionslib/groupher_server/cms/delegates/article_curd.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
"""
import Ecto.Query, warn: false

import GroupherServer.CMS.Utils.Matcher2
import GroupherServer.CMS.Utils.Matcher, only: [match_action: 2]
import GroupherServer.CMS.Helper.Matcher2
import GroupherServer.CMS.Helper.Matcher, only: [match_action: 2]

import Helper.Utils, only: [done: 1, pick_by: 2, integerfy: 1, strip_struct: 1]
import Helper.ErrorCode
Expand Down
4 changes: 2 additions & 2 deletionslib/groupher_server/cms/delegates/article_operation.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,13 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do
@moduledoc """
set / unset operations for Article-like resource
"""
import GroupherServer.CMS.Utils.Matcher
import GroupherServer.CMS.Helper.Matcher
import Ecto.Query, warn: false

import Helper.ErrorCode
import ShortMaps
import Helper.Utils, only: [strip_struct: 1]
import GroupherServer.CMS.Utils.Matcher2
import GroupherServer.CMS.Helper.Matcher2

alias Helper.Types, as: T
alias Helper.ORM
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/cms/delegates/article_reaction.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleReaction do
@moduledoc """
reaction[upvote, collect, watch ...] on article [post, job...]
"""
import GroupherServer.CMS.Utils.Matcher2
import GroupherServer.CMS.Helper.Matcher2
import Ecto.Query, warn: false
import Helper.Utils, only: [done: 1, strip_struct: 1]
# import Helper.ErrorCode
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/cms/delegates/comment_curd.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ defmodule GroupherServer.CMS.Delegate.CommentCURD do
import Helper.Utils, only: [done: 1]
import Helper.ErrorCode

import GroupherServer.CMS.Utils.Matcher
import GroupherServer.CMS.Helper.Matcher
import ShortMaps

alias Helper.{ORM, QueryBuilder}
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/cms/delegates/community_curd.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do
community curd
"""
import Ecto.Query, warn: false
import GroupherServer.CMS.Utils.Matcher
import GroupherServer.CMS.Helper.Matcher
import Helper.Utils, only: [done: 1, map_atom_value: 2]
import GroupherServer.CMS.Delegate.ArticleCURD, only: [ensure_author_exists: 1]
import ShortMaps
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server/cms/delegates/seeds.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ defmodule GroupherServer.CMS.Delegate.Seeds do
import Ecto.Query, warn: false

@oss_endpoint "https://cps-oss.oss-cn-shanghai.aliyuncs.com"
# import GroupherServer.CMS.Utils.Matcher
# import GroupherServer.CMS.Helper.Matcher
# import Helper.Utils, only: [done: 1, map_atom_value: 2]
# import GroupherServer.CMS.Delegate.ArticleCURD, only: [ensure_author_exists: 1]
import ShortMaps
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
defmodule GroupherServer.CMS.Utils.Loader do
defmodule GroupherServer.CMS.Helper.Loader do
@moduledoc """
dataloader for cms context
"""
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
defmodule GroupherServer.CMS.Utils.Matcher do
defmodule GroupherServer.CMS.Helper.Matcher do
@moduledoc """
this module defined the matches and handy guard ...
"""
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
defmodule GroupherServer.CMS.Utils.Matcher2 do
defmodule GroupherServer.CMS.Helper.Matcher2 do
@moduledoc """
this module defined the matches and handy guard ...
"""
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server_web/middleware/passport_loader.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ defmodule GroupherServerWeb.Middleware.PassportLoader do
"""
@behaviour Absinthe.Middleware

import GroupherServer.CMS.Utils.Matcher
import GroupherServer.CMS.Helper.Matcher
import Helper.Utils
import Helper.ErrorCode
import ShortMaps
Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server_web/resolvers/cms_resolver.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
defmodule GroupherServerWeb.Resolvers.CMS do
@moduledoc false

import GroupherServer.CMS.Utils.Matcher
import GroupherServer.CMS.Helper.Matcher
import ShortMaps
import Ecto.Query, warn: false

Expand Down
8 changes: 4 additions & 4 deletionslib/groupher_server_web/schema.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,12 +6,12 @@ defmodule GroupherServerWeb.Schema do
# use ApolloTracing

alias GroupherServerWeb.Middleware, as: M
alias GroupherServerWeb.Schema.{Account, Billing, CMS, Delivery, Statistics,Utils}
alias GroupherServerWeb.Schema.{Account, Billing, CMS, Delivery, Statistics,Helper}

import_types(Absinthe.Type.Custom)

# utils
import_types(Utils.CommonTypes)
import_types(Helper.Metrics)

# account
import_types(Account.Types)
Expand DownExpand Up@@ -91,8 +91,8 @@ defmodule GroupherServerWeb.Schema do
alias GroupherServer.{Accounts, CMS}

Dataloader.new()
|> Dataloader.add_source(Accounts, Accounts.Utils.Loader.data())
|> Dataloader.add_source(CMS, CMS.Utils.Loader.data())
|> Dataloader.add_source(Accounts, Accounts.Helper.Loader.data())
|> Dataloader.add_source(CMS, CMS.Helper.Loader.data())
end

def context(ctx) do
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
defmodule GroupherServerWeb.Schema.Utils.Helper do
defmodule GroupherServerWeb.Schema.Helper.Fields do
@moduledoc """
common fields
"""
Expand DownExpand Up@@ -97,46 +97,6 @@ defmodule GroupherServerWeb.Schema.Utils.Helper do
end
end

@doc """
query generator for threads, like:

post, page_posts ...
"""
defmacro article_queries(thread) do
quote do
@desc unquote("get #{thread} by id")
field unquote(thread), non_null(unquote(thread)) do
arg(:id, non_null(:id))
arg(:thread, unquote(:"#{thread}_thread"), default_value: unquote(thread))

resolve(&R.CMS.read_article/3)
end

@desc unquote("get paged #{thread}s")
field unquote(:"paged_#{thread}s"), unquote(:"paged_#{thread}s") do
arg(:thread, unquote(:"#{thread}_thread"), default_value: unquote(thread))
arg(:filter, non_null(unquote(:"paged_#{thread}s_filter")))

middleware(M.PageSizeProof)
resolve(&R.CMS.paged_articles/3)
end
end
end

defmacro article_reacted_users_query(action, resolver) do
quote do
@desc unquote("get paged #{action}ed users of an article")
field unquote(:"#{action}ed_users"), :paged_users do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:filter, non_null(:paged_filter))

middleware(M.PageSizeProof)
resolve(unquote(resolver))
end
end
end

defmacro comments_fields do
quote do
field(:id, :id)
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
defmodule GroupherServerWeb.Schema.Utils.CommonTypes do
defmodule GroupherServerWeb.Schema.Helper.Metrics do
@moduledoc """
common types might be used in all context
"""
import GroupherServerWeb.Schema.Utils.Helper
import GroupherServerWeb.Schema.Helper.Fields

use Absinthe.Schema.Notation

Expand Down
29 changes: 29 additions & 0 deletionslib/groupher_server_web/schema/Helper/mutations.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
defmodule GroupherServerWeb.Schema.Helper.Mutations do
@moduledoc """
common fields
"""
alias GroupherServerWeb.Middleware, as: M
alias GroupherServerWeb.Resolvers, as: R

defmacro article_upvote_mutation(thread) do
quote do
@desc unquote("upvote to #{thread}")
field unquote(:"upvote_#{thread}"), :article do
arg(:id, non_null(:id))
arg(:thread, unquote(:"#{thread}_thread"), default_value: unquote(thread))

middleware(M.Authorize, :login)
resolve(&R.CMS.upvote_article/3)
end

@desc unquote("undo upvote to #{thread}")
field unquote(:"undo_upvote_#{thread}"), :article do
arg(:id, non_null(:id))
arg(:thread, unquote(:"#{thread}_thread"), default_value: unquote(thread))

middleware(M.Authorize, :login)
resolve(&R.CMS.undo_upvote_article/3)
end
end
end
end
47 changes: 47 additions & 0 deletionslib/groupher_server_web/schema/Helper/queries.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
defmodule GroupherServerWeb.Schema.Helper.Queries do
@moduledoc """
common fields
"""
alias GroupherServerWeb.Middleware, as: M
alias GroupherServerWeb.Resolvers, as: R

@doc """
query generator for threads, like:

post, page_posts ...
"""
defmacro article_queries(thread) do
quote do
@desc unquote("get #{thread} by id")
field unquote(thread), non_null(unquote(thread)) do
arg(:id, non_null(:id))
arg(:thread, unquote(:"#{thread}_thread"), default_value: unquote(thread))

resolve(&R.CMS.read_article/3)
end

@desc unquote("get paged #{thread}s")
field unquote(:"paged_#{thread}s"), unquote(:"paged_#{thread}s") do
arg(:thread, unquote(:"#{thread}_thread"), default_value: unquote(thread))
arg(:filter, non_null(unquote(:"paged_#{thread}s_filter")))

middleware(M.PageSizeProof)
resolve(&R.CMS.paged_articles/3)
end
end
end

defmacro article_reacted_users_query(action, resolver) do
quote do
@desc unquote("get paged #{action}ed users of an article")
field unquote(:"#{action}ed_users"), :paged_users do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:filter, non_null(:paged_filter))

middleware(M.PageSizeProof)
resolve(unquote(resolver))
end
end
end
end
2 changes: 1 addition & 1 deletionlib/groupher_server_web/schema/account/account_misc.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ defmodule GroupherServerWeb.Schema.Account.Misc do
@moduledoc false

use Absinthe.Schema.Notation
import GroupherServerWeb.Schema.Utils.Helper
import GroupherServerWeb.Schema.Helper.Fields

@desc "article_filter doc"
input_object :paged_users_filter do
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ defmodule GroupherServerWeb.Schema.Account.Types do
"""
use Helper.GqlSchemaSuite

import GroupherServerWeb.Schema.Utils.Helper
import GroupherServerWeb.Schema.Helper.Fields
import Absinthe.Resolution.Helpers

alias GroupherServer.Accounts
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ defmodule GroupherServerWeb.Schema.Billing.Types do
"""
use Helper.GqlSchemaSuite

import GroupherServerWeb.Schema.Utils.Helper
import GroupherServerWeb.Schema.Helper.Fields

enum :bill_state_enum do
value(:pending)
Expand Down
5 changes: 4 additions & 1 deletionlib/groupher_server_web/schema/cms/cms_misc.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
defmodule GroupherServerWeb.Schema.CMS.Misc do
@moduledoc """
common metrics in queries
"""
use Absinthe.Schema.Notation

import GroupherServerWeb.Schema.Utils.Helper
import GroupherServerWeb.Schema.Helper.Fields

alias GroupherServer.CMS

Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server_web/schema/cms/cms_queries.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
@moduledoc """
CMS queries
"""
import GroupherServerWeb.Schema.Utils.Helper
import GroupherServerWeb.Schema.Helper.Queries

use Helper.GqlSchemaSuite

Expand Down
2 changes: 1 addition & 1 deletionlib/groupher_server_web/schema/cms/cms_types.ex
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
"""
use Helper.GqlSchemaSuite

import GroupherServerWeb.Schema.Utils.Helper
import GroupherServerWeb.Schema.Helper.Fields
import Ecto.Query, warn: false
import Absinthe.Resolution.Helpers, only: [dataloader: 2, on_load: 2]

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp