Closed Betree closed 3 years ago
How should this look like ? Just a plain number ?
How should this look like ? Just a plain number ?
@steelstyle i suggest this:
Great, sorry for the late reply.
@Betree as I'm not sure what is the convention to transit such information in this app. Can you tell me if a vanilla rpc would be okay, of if there is another way you wrap this kind of data ? Would like to have an idea to know how much of an effort this is.
The moderation feature is unfortunately still plugged on the legacy REST endpoints.
The new way to communicate between frontend & API is through GraphQL. You can try it there: https://graphql.staging.captainfact.io/graphiql
Because there's no REST endpoint to get the total number of pending moderation items, I would recommend to implement it directly on GraphQL. Here's a suggestion on how that can be done:
count_items_to_review(user)
function in apps/cf/lib/moderation/moderation.ex
(feel free to find a better name). You can copy paste most of the code from random!(user)
to implement it.apps/cf_graphql/lib/schema/types/user.ex
, add a pending_moderation_items_count
field, with a resolver that calls CF.Moderation.count_items_to_review(user)
. Eventually pass it through a middleware(Middleware.RequireAuthentication)
?On the frontend, you'll then be able to fetch this field with a useQuery
(see Apollo's documentation)
Edit: just saw your PR @steelstyle, sounds like you found the solution by yourself :wink: I'll review now!
Merci beaucoup @steelstyle @Betree ! Cela va énormément faciliter la vie des modérateurs :)