Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
161
Issues
161
List
Boards
Labels
Service Desk
Milestones
Merge Requests
41
Merge Requests
41
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
762224c1
Commit
762224c1
authored
14 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(chore): apply contibutions score to prospect too
parent
42b080b8
epic/referrals
1 merge request
!236
epic/referrals
Pipeline
#71657809
passed with stages
in 8 minutes and 41 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
4 deletions
+56
-4
ContributionValues.php
Core/Rewards/Contributions/ContributionValues.php
+1
-0
Manager.php
Core/Rewards/Contributions/Manager.php
+9
-0
ReferralDelegate.php
Core/Rewards/Delegates/ReferralDelegate.php
+23
-1
RewardsProvider.php
Core/Rewards/RewardsProvider.php
+4
-0
ReferralDelegateSpec.php
Spec/Core/Rewards/Delegates/ReferralDelegateSpec.php
+19
-3
No files found.
Core/Rewards/Contributions/ContributionValues.php
View file @
762224c1
...
...
@@ -10,6 +10,7 @@ class ContributionValues
'votes'
=>
1
,
'subscribers'
=>
4
,
'referrals'
=>
50
,
'referrals_welcome'
=>
50
,
'checkin'
=>
2
,
'jury_duty'
=>
25
,
];
...
...
This diff is collapsed.
Click to expand it.
Core/Rewards/Contributions/Manager.php
View file @
762224c1
...
...
@@ -96,6 +96,15 @@ class Manager
return
$contributions
;
}
/**
* Add a contibution score row manually
* @param Contribution $contribution
* @return bool
*/
public
function
add
(
Contribution
$contribution
)
:
bool
{
return
$this
->
repository
->
add
(
$contribution
);
}
public
function
issueCheckins
(
$count
)
{
...
...
This diff is collapsed.
Click to expand it.
Core/Rewards/Delegates/ReferralDelegate.php
View file @
762224c1
...
...
@@ -7,6 +7,8 @@ namespace Minds\Core\Rewards\Delegates;
use
Minds\Core\Di\Di
;
use
Minds\Entities\User
;
use
Minds\Core\Referrals\Referral
;
use
Minds\Core\Rewards\Contributions\Contribution
;
use
Minds\Core\Rewards\Contributions\ContributionValues
;
class
ReferralDelegate
{
...
...
@@ -14,9 +16,10 @@ class ReferralDelegate
/** @var Manager $manager */
private
$manager
;
public
function
__construct
(
$manager
=
null
)
public
function
__construct
(
$manager
=
null
,
$contributionsManager
=
null
)
{
$this
->
manager
=
$manager
?:
Di
::
_
()
->
get
(
'Referrals\Manager'
);
$this
->
contributionsManager
=
$contributionsManager
??
Di
::
_
()
->
get
(
'Rewards\Contributions\Manager'
);
}
/**
...
...
@@ -33,6 +36,25 @@ class ReferralDelegate
$this
->
manager
->
update
(
$referral
);
// TODO: This should be in its own delegate?
$this
->
issueContributionScore
(
$user
);
}
/**
* Issue contribution score when referred
* TODO: Move to own delegate?
* @param User $user
* @return void
*/
private
function
issueContributionScore
(
User
$user
)
:
void
{
$ts
=
strtotime
(
'midnight'
);
$contribution
=
new
Contribution
();
$contribution
->
setTimestamp
(
$ts
)
->
setUser
(
$user
)
->
setScore
(
ContributionValues
::
$multipliers
[
'referrals_welcome'
])
->
setAmount
(
1
);
$this
->
contributionsManager
->
add
(
$contribution
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Core/Rewards/RewardsProvider.php
View file @
762224c1
...
...
@@ -7,6 +7,10 @@ class RewardsProvider extends Provider
{
public
function
register
()
{
$this
->
di
->
bind
(
'Rewards\Contributions\Manager'
,
function
(
$di
)
{
return
new
Contributions\Manager
();
},
[
'useFactory'
=>
true
]);
$this
->
di
->
bind
(
'Rewards\Contributions\Repository'
,
function
(
$di
)
{
return
new
Contributions\Repository
();
},
[
'useFactory'
=>
true
]);
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Rewards/Delegates/ReferralDelegateSpec.php
View file @
762224c1
...
...
@@ -7,23 +7,30 @@ use Minds\Core\Referrals\Referral;
use
Minds\Core\Referrals\Manager
;
use
Minds\Entities\User
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Rewards\Contributions
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
class
ReferralDelegateSpec
extends
ObjectBehavior
{
/** @var Manager $manager */
private
$manager
;
/** @var $contributionsManager */
private
$contributionsManager
;
/** @var User $user */
private
$user
;
function
let
(
Manager
$manager
,
User
$user
User
$user
,
Contributions\Manager
$contributionsManager
)
{
$this
->
beConstructedWith
(
$manager
,
$
us
er
);
$this
->
beConstructedWith
(
$manager
,
$
contributionsManag
er
);
$this
->
manager
=
$manager
;
$this
->
contributionsManager
=
$contributionsManager
;
$this
->
user
=
$user
;
}
...
...
@@ -32,8 +39,9 @@ class ReferralDelegateSpec extends ObjectBehavior
$this
->
shouldHaveType
(
ReferralDelegate
::
class
);
}
function
it_should_tell_manager_to_update_referral
(
User
$user
)
function
it_should_tell_manager_to_update_referral
()
{
$user
=
new
User
();
$user
->
referrer
=
123
;
$user
->
guid
=
456
;
...
...
@@ -50,6 +58,14 @@ class ReferralDelegateSpec extends ObjectBehavior
$this
->
manager
->
update
(
$referral
)
->
shouldBeCalled
();
$this
->
contributionsManager
->
add
(
Argument
::
that
(
function
(
$contribution
)
{
return
$contribution
->
getScore
()
===
50
&&
$contribution
->
getAmount
()
===
1
&&
$contribution
->
getUser
()
->
guid
===
456
&&
$contribution
->
getTimestamp
()
===
strtotime
(
'midnight'
);
}))
->
willReturn
(
true
);
$this
->
onReferral
(
$user
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment