-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
522 additions
and
913 deletions.
There are no files selected for viewing
84 changes: 0 additions & 84 deletions
84
src/com/github/tavlima/nubank/reward/invitations/altcontroller.clj
This file was deleted.
Oops, something went wrong.
This file contains 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
84 changes: 0 additions & 84 deletions
84
src/com/github/tavlima/nubank/reward/invitations/domain.clj
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/com/github/tavlima/nubank/reward/invitations/domain/user.clj
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(ns com.github.tavlima.nubank.reward.invitations.domain.user | ||
(:require [com.github.tavlima.nubank.reward.tree.domain | ||
[location :as l] | ||
[treenode :as n] | ||
[zippable :as z]])) | ||
|
||
(defprotocol User | ||
(addScore [user delta]) | ||
(verified? [user]) | ||
(verify! [user]) | ||
(addInvited [user invited])) | ||
|
||
(defrecord UserImpl [id score invited verified] | ||
n/TreeNode | ||
(match? [_ matchId] (= id matchId)) | ||
(uid [_] id) | ||
(fields [node ks] | ||
(select-keys node ks)) | ||
|
||
z/Zippable | ||
(children [_] invited) | ||
(make [user children] (assoc user :invited children)) | ||
(zipper [user] (l/->LocationImpl user [:nil] [:nil] [:nil])) | ||
|
||
User | ||
(addScore [user delta] (assoc user :score (+ score delta))) | ||
(verified? [_] verified) | ||
(verify! [user] (assoc user :verified true)) | ||
(addInvited [user invitedUser] (assoc user :invited (conj invited invitedUser)))) | ||
|
||
(defn create-user [id] | ||
(->UserImpl id 0 [] false)) |
11 changes: 11 additions & 0 deletions
11
src/com/github/tavlima/nubank/reward/invitations/domain/usertree.clj
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(ns com.github.tavlima.nubank.reward.invitations.domain.usertree | ||
(:require [com.github.tavlima.nubank.reward.tree.domain.tree :as t]) | ||
(:import (com.github.tavlima.nubank.reward.tree.domain.tree TreeImpl))) | ||
|
||
(defprotocol UserTree | ||
(users [tree])) | ||
|
||
(extend-protocol UserTree | ||
TreeImpl | ||
(users [tree] | ||
(t/nodes tree [:id :score :verified]))) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
(ns com.github.tavlima.nubank.reward.invitations.port | ||
(require [com.github.tavlima.nubank.reward.invitations.altcontroller :as controller])) | ||
(require [com.github.tavlima.nubank.reward.invitations.controller :as c])) | ||
|
||
(defn invite [tree inviterId inviteeId] | ||
(controller/invite tree inviterId inviteeId)) | ||
(c/invite tree inviterId inviteeId)) | ||
|
||
(defn create-tree [] | ||
(controller/create-tree)) | ||
(c/create-tree)) | ||
|
||
(defn ranking [tree] | ||
(controller/ranking tree)) | ||
(c/ranking tree)) | ||
|
||
(defn get-user [tree userId] | ||
(controller/get-user tree userId)) | ||
(c/get-user tree userId)) |
Oops, something went wrong.