@@ -46,6 +46,7 @@ public function findByPoll(int $pollId, bool $getDeleted = false): array {
46
46
}
47
47
48
48
$ this ->joinUserVoteCount ($ qb , self ::TABLE );
49
+ $ this ->joinAnon ($ qb , self ::TABLE );
49
50
50
51
return $ this ->findEntities ($ qb );
51
52
}
@@ -107,6 +108,7 @@ public function findByPollAndUser(int $pollId, string $userId, bool $findDeleted
107
108
$ qb ->andWhere ($ qb ->expr ()->eq (self ::TABLE . '.deleted ' , $ qb ->createNamedParameter (0 , IQueryBuilder::PARAM_INT )));
108
109
}
109
110
$ this ->joinUserVoteCount ($ qb , self ::TABLE );
111
+ $ this ->joinAnon ($ qb , self ::TABLE );
110
112
111
113
try {
112
114
return $ this ->findEntity ($ qb );
@@ -131,6 +133,7 @@ public function findByToken(string $token, bool $getDeleted = false): Share {
131
133
}
132
134
133
135
$ this ->joinUserVoteCount ($ qb , self ::TABLE );
136
+ $ this ->joinAnon ($ qb , self ::TABLE );
134
137
135
138
try {
136
139
return $ this ->findEntity ($ qb );
@@ -183,4 +186,22 @@ protected function joinUserVoteCount(IQueryBuilder &$qb, string $fromAlias): voi
183
186
);
184
187
}
185
188
189
+ /**
190
+ * Joins anonymous setting of poll
191
+ */
192
+ protected function joinAnon (IQueryBuilder &$ qb , string $ fromAlias ): void {
193
+ $ joinAlias = 'anon ' ;
194
+
195
+ $ qb ->selectAlias ($ joinAlias . '.anonymous ' , 'anonymizedVotes ' )
196
+ ->addGroupBy (
197
+ $ joinAlias . '.anonymous ' ,
198
+ );
199
+
200
+ $ qb ->leftJoin (
201
+ $ fromAlias ,
202
+ Poll::TABLE ,
203
+ $ joinAlias ,
204
+ $ qb ->expr ()->eq ($ joinAlias . '.id ' , $ fromAlias . '.poll_id ' ),
205
+ );
206
+ }
186
207
}
0 commit comments