|
@@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
7
|
7
|
use Symfony\Component\Console\Input\InputInterface;
|
8
|
8
|
use Symfony\Component\Console\Input\InputOption;
|
9
|
9
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
10
|
+use Muzich\CoreBundle\Entity\EventArchive;
|
10
|
11
|
|
11
|
12
|
class RecalculateReputationCommand extends ContainerAwareCommand
|
12
|
13
|
{
|
|
@@ -63,7 +64,9 @@ class RecalculateReputationCommand extends ContainerAwareCommand
|
63
|
64
|
{
|
64
|
65
|
$user_points = 0;
|
65
|
66
|
|
66
|
|
- // On calcule pour les éléments
|
|
67
|
+ /*
|
|
68
|
+ * On calcule pour les éléments
|
|
69
|
+ */
|
67
|
70
|
$elements = $em->createQuery(
|
68
|
71
|
"SELECT e FROM MuzichCoreBundle:Element e"
|
69
|
72
|
. " WHERE e.owner = :uid"
|
|
@@ -78,7 +81,9 @@ class RecalculateReputationCommand extends ContainerAwareCommand
|
78
|
81
|
$element_points += $element->getPoints();
|
79
|
82
|
}
|
80
|
83
|
|
81
|
|
- // On calcule pour les favoris
|
|
84
|
+ /*
|
|
85
|
+ * On calcule pour les favoris
|
|
86
|
+ */
|
82
|
87
|
$coef_element_fav = $this->getContainer()->getParameter('reputation_element_favorite_value');
|
83
|
88
|
$count_favs = 0;
|
84
|
89
|
$fav = $em->createQuery(
|
|
@@ -97,7 +102,9 @@ class RecalculateReputationCommand extends ContainerAwareCommand
|
97
|
102
|
}
|
98
|
103
|
}
|
99
|
104
|
|
100
|
|
- // Calcul pour les utilisateurs suivis
|
|
105
|
+ /*
|
|
106
|
+ * Calcul pour les utilisateurs suivis
|
|
107
|
+ */
|
101
|
108
|
$coef_follow = $this->getContainer()->getParameter('reputation_element_follow_value');
|
102
|
109
|
$count_follow = 0;
|
103
|
110
|
$fol = $em->createQuery(
|
|
@@ -115,9 +122,32 @@ class RecalculateReputationCommand extends ContainerAwareCommand
|
115
|
122
|
}
|
116
|
123
|
}
|
117
|
124
|
|
118
|
|
- $points = ($element_points * $coef_element_point)
|
119
|
|
- + ($count_favs * $coef_element_fav)
|
120
|
|
- + ($count_follow * $coef_follow)
|
|
125
|
+ /*
|
|
126
|
+ * Calcul pour les tags proposés sur des éléments
|
|
127
|
+ */
|
|
128
|
+ $coef_tag_prop = $this->getContainer()->getParameter('reputation_element_tags_element_prop_value');
|
|
129
|
+
|
|
130
|
+ try {
|
|
131
|
+
|
|
132
|
+ $count_tag_prop = $em->createQuery(
|
|
133
|
+ "SELECT a.count FROM MuzichCoreBundle:EventArchive a"
|
|
134
|
+ . " WHERE a.user = :uid AND a.type = :type"
|
|
135
|
+ )->setParameters(array(
|
|
136
|
+ 'uid' => $user->getId(),
|
|
137
|
+ 'type' => EventArchive::PROP_TAGS_ELEMENT_ACCEPTED
|
|
138
|
+ ))
|
|
139
|
+ ->getSingleScalarResult()
|
|
140
|
+ ;
|
|
141
|
+
|
|
142
|
+ } catch (\Doctrine\ORM\NoResultException $exc) {
|
|
143
|
+ $count_tag_prop = 0;
|
|
144
|
+ }
|
|
145
|
+
|
|
146
|
+ $points =
|
|
147
|
+ ($element_points * $coef_element_point)
|
|
148
|
+ + ($count_favs * $coef_element_fav)
|
|
149
|
+ + ($count_follow * $coef_follow)
|
|
150
|
+ + ($count_tag_prop * $coef_tag_prop)
|
121
|
151
|
;
|
122
|
152
|
|
123
|
153
|
$user->setReputation($points);
|