Last active
April 26, 2018 16:07
-
-
Save spejman/46ec03360e9f4ae1eeb1cfb593e01cee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule BFFWeb.V2.UnreadNotificationsController do | |
use BFFWeb, :controller | |
def index(conn, params) do | |
{conversations_count, offers_pending_count, jobs_pending_count} = | |
async with {:ok, candidate_id} <- Candidates.get_current_candidate_id(conn.assigns.auth_token), | |
{:ok, conversations_count} <- Conversations.count_unread_conversations(candidate_id), | |
{:ok, offers_pending_count} <- Transactions.count_offers_pending(candidate_id), | |
{:ok, jobs_pending_count} <- Transactions.count_jobs_pending(candidate_id) do | |
{conversations_count, offers_pending_count, jobs_pending_count} | |
else | |
_ -> {-1, -1, -1} | |
end | |
conn | |
|> assign(:unread_conversations_messages_count, conversations_count) | |
|> assign(:offers_pending_to_action_count, offers_pending_count) | |
|> assign(:jobs_pending_to_action_count, jobs_pending_count) | |
|> render("index.json") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment