From 87cd8733d79247e7e61a62d680e4ddad62ccec03 Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Thu, 5 Apr 2018 11:52:47 +0200 Subject: [PATCH] identify claim winner based on user_login = winner_login --- src/cljc/commiteth/util.cljc | 4 ++++ src/cljs/commiteth/manage_payouts.cljs | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cljc/commiteth/util.cljc b/src/cljc/commiteth/util.cljc index 0a2d576..e7c882c 100644 --- a/src/cljc/commiteth/util.cljc +++ b/src/cljc/commiteth/util.cljc @@ -3,3 +3,7 @@ (defn parse-float [x] #?(:cljs (js/parseFloat x) :clj (Float/parseFloat x))) + +(defn assert-first [xs] + (assert (first xs) "assert-first failure") + (first xs)) diff --git a/src/cljs/commiteth/manage_payouts.cljs b/src/cljs/commiteth/manage_payouts.cljs index 04cf22d..d6df4be 100644 --- a/src/cljs/commiteth/manage_payouts.cljs +++ b/src/cljs/commiteth/manage_payouts.cljs @@ -1,6 +1,7 @@ (ns commiteth.manage-payouts (:require [reagent.core :as r] [re-frame.core :as rf] + [commiteth.util :as util] [commiteth.routes :as routes] [commiteth.model.bounty :as bnt] [commiteth.common :as common :refer [human-time]])) @@ -139,7 +140,17 @@ [:div.ui.text "No items"] (into [:div] (for [bounty bounties - :let [winning-claim (first (:claims bounty))]] ; TODO identify winning claim + ;; Identifying the winning claim like this is a bit + ;; imprecise if there have been two PRs for the same + ;; bounty by the same contributor + ;; Since the resulting payout is the same we can probably + ;; ignore this edge case for a first version + :let [winning-claim (->> (:claims bounty) + (filter #(do (prn bounty) + (prn %) + (= (:user_login %) + (:winner_login bounty)))) + util/assert-first)]] ^{:key (:issue_id bounty)} [:div.mb2 [:div.pa3.bg-white.bb.b--light-gray