From 8c424f587bae763ca444dd87f80a39d3f6ffa675 Mon Sep 17 00:00:00 2001 From: Nick Mooney Date: Fri, 7 Feb 2014 13:30:40 -0800 Subject: [PATCH] Added hashtag-based tiers for payouts --- app/models/project.rb | 17 ++++++++++++++++- config/config.yml.sample | 12 +++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 2f632d87..39ea73ec 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -77,7 +77,7 @@ def tip_for commit tip = Tip.create({ project: self, user: user, - amount: next_tip_amount, + amount: next_tip_amount * (multiplier_for commit), commit: commit.sha }) @@ -94,6 +94,21 @@ def tip_for commit end + def multiplier_for commit + hashtag = commit.commit.message[/#[a-z]*/i] + + if hashtag + hashtag = hashtag[1..-1].downcase + if CONFIG['tiers'].has_key?(hashtag) + CONFIG['tiers'][hashtag] + else + 1 + end + else + 1 + end + end + def available_amount self.deposits.where("confirmations > 0").map(&:available_amount).sum - tips_paid_amount end diff --git a/config/config.yml.sample b/config/config.yml.sample index 992b3052..e3dc1910 100644 --- a/config/config.yml.sample +++ b/config/config.yml.sample @@ -28,6 +28,16 @@ smtp_settings: # api_key: 111111111111 # host: errbit.tip4commit.com + +# Payout tiers, multipliers on the below tip amount +tiers: + free: 0 + tiny: 0.1 + small: 0.5 + average: 1 + large: 2 + huge: 10 + tip: 0.01 min_payout: 100000 -our_fee: 0.05 \ No newline at end of file +our_fee: 0.05