identify claim winner based on user_login = winner_login

This commit is contained in:
Martin Klepsch 2018-04-05 11:52:47 +02:00 committed by Tetiana Churikova
parent 60fa38b89b
commit 87cd8733d7
2 changed files with 16 additions and 1 deletions

View File

@ -3,3 +3,7 @@
(defn parse-float [x] (defn parse-float [x]
#?(:cljs (js/parseFloat x) #?(:cljs (js/parseFloat x)
:clj (Float/parseFloat x))) :clj (Float/parseFloat x)))
(defn assert-first [xs]
(assert (first xs) "assert-first failure")
(first xs))

View File

@ -1,6 +1,7 @@
(ns commiteth.manage-payouts (ns commiteth.manage-payouts
(:require [reagent.core :as r] (:require [reagent.core :as r]
[re-frame.core :as rf] [re-frame.core :as rf]
[commiteth.util :as util]
[commiteth.routes :as routes] [commiteth.routes :as routes]
[commiteth.model.bounty :as bnt] [commiteth.model.bounty :as bnt]
[commiteth.common :as common :refer [human-time]])) [commiteth.common :as common :refer [human-time]]))
@ -139,7 +140,17 @@
[:div.ui.text "No items"] [:div.ui.text "No items"]
(into [:div] (into [:div]
(for [bounty bounties (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)} ^{:key (:issue_id bounty)}
[:div.mb2 [:div.mb2
[:div.pa3.bg-white.bb.b--light-gray [:div.pa3.bg-white.bb.b--light-gray