2222use OCP \AppFramework \Http ;
2323use OCP \AppFramework \Http \Attribute \FrontpageRoute ;
2424use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
25+ use OCP \AppFramework \Http \Attribute \OpenAPI ;
2526use OCP \AppFramework \Http \JSONResponse ;
2627use OCP \IRequest ;
2728
@@ -56,6 +57,7 @@ public function __construct(
5657 * }>
5758 */
5859 #[NoAdminRequired]
60+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
5961 #[FrontpageRoute(verb: 'GET ' , url: '/polls ' )]
6062 public function listPolls (): JSONResponse {
6163 return $ this ->response (function () {
@@ -78,6 +80,7 @@ public function listPolls(): JSONResponse {
7880 * psalm-return JSONResponse<array{poll: Poll}>
7981 */
8082 #[NoAdminRequired]
83+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
8184 #[FrontpageRoute(verb: 'GET ' , url: '/poll/{pollId}/poll ' )]
8285 public function get (int $ pollId ): JSONResponse {
8386 return $ this ->response (fn () => [
@@ -100,6 +103,7 @@ public function get(int $pollId): JSONResponse {
100103 *
101104 */
102105 #[NoAdminRequired]
106+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
103107 #[FrontpageRoute(verb: 'GET ' , url: '/poll/{pollId} ' )]
104108 public function getFull (int $ pollId ): JSONResponse {
105109 return $ this ->response (fn () => $ this ->getFullPoll ($ pollId , true ), Http::STATUS_OK );
@@ -117,6 +121,9 @@ private function getFullPoll(int $pollId, bool $withTimings = false): array {
117121 $ votes = $ this ->voteService ->list ($ pollId );
118122 $ timerMicro ['votes ' ] = microtime (true );
119123
124+ $ orphaned = $ this ->voteService ->getOprhanedVotes ($ pollId );
125+ $ timerMicro ['orphaned ' ] = microtime (true );
126+
120127 $ comments = $ this ->commentService ->list ($ pollId );
121128 $ timerMicro ['comments ' ] = microtime (true );
122129
@@ -130,7 +137,8 @@ private function getFullPoll(int $pollId, bool $withTimings = false): array {
130137 $ diffMicro ['poll ' ] = $ timerMicro ['poll ' ] - $ timerMicro ['start ' ];
131138 $ diffMicro ['options ' ] = $ timerMicro ['options ' ] - $ timerMicro ['poll ' ];
132139 $ diffMicro ['votes ' ] = $ timerMicro ['votes ' ] - $ timerMicro ['options ' ];
133- $ diffMicro ['comments ' ] = $ timerMicro ['comments ' ] - $ timerMicro ['votes ' ];
140+ $ diffMicro ['orphaned ' ] = $ timerMicro ['orphaned ' ] - $ timerMicro ['votes ' ];
141+ $ diffMicro ['comments ' ] = $ timerMicro ['comments ' ] - $ timerMicro ['orphaned ' ];
134142 $ diffMicro ['shares ' ] = $ timerMicro ['shares ' ] - $ timerMicro ['comments ' ];
135143 $ diffMicro ['subscribed ' ] = $ timerMicro ['subscribed ' ] - $ timerMicro ['shares ' ];
136144
@@ -139,6 +147,7 @@ private function getFullPoll(int $pollId, bool $withTimings = false): array {
139147 'poll ' => $ poll ,
140148 'options ' => $ options ,
141149 'votes ' => $ votes ,
150+ 'orphaned ' => count ($ orphaned ),
142151 'comments ' => $ comments ,
143152 'shares ' => $ shares ,
144153 'subscribed ' => $ subscribed ,
@@ -149,6 +158,7 @@ private function getFullPoll(int $pollId, bool $withTimings = false): array {
149158 'poll ' => $ poll ,
150159 'options ' => $ options ,
151160 'votes ' => $ votes ,
161+ 'orphaned ' => count ($ orphaned ),
152162 'comments ' => $ comments ,
153163 'shares ' => $ shares ,
154164 'subscribed ' => $ subscribed ,
@@ -164,6 +174,7 @@ private function getFullPoll(int $pollId, bool $withTimings = false): array {
164174 * psalm-return JSONResponse<array{poll: Poll}>
165175 */
166176 #[NoAdminRequired]
177+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
167178 #[FrontpageRoute(verb: 'POST ' , url: '/poll/add ' )]
168179 public function add (string $ type , string $ title , string $ votingVariant = Poll::VARIANT_SIMPLE ): JSONResponse {
169180 return $ this ->response (
@@ -182,6 +193,7 @@ public function add(string $type, string $title, string $votingVariant = Poll::V
182193 * psalm-return JSONResponse<array{poll: Poll}>
183194 */
184195 #[NoAdminRequired]
196+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
185197 #[FrontpageRoute(verb: 'PUT ' , url: '/poll/{pollId} ' )]
186198 public function update (int $ pollId , array $ poll ): JSONResponse {
187199 return $ this ->response (fn () => [
@@ -194,6 +206,7 @@ public function update(int $pollId, array $poll): JSONResponse {
194206 * @param int $pollId Poll id
195207 */
196208 #[NoAdminRequired]
209+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
197210 #[FrontpageRoute(verb: 'PUT ' , url: '/poll/{pollId}/lockAnonymous ' )]
198211 public function lockAnonymous (int $ pollId ): JSONResponse {
199212 return $ this ->response (fn () => [
@@ -206,6 +219,7 @@ public function lockAnonymous(int $pollId): JSONResponse {
206219 * @param int $pollId Poll id
207220 */
208221 #[NoAdminRequired]
222+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
209223 #[FrontpageRoute(verb: 'POST ' , url: '/poll/{pollId}/confirmation ' )]
210224 public function sendConfirmation (int $ pollId ): JSONResponse {
211225 return $ this ->response (fn () => [
@@ -218,6 +232,7 @@ public function sendConfirmation(int $pollId): JSONResponse {
218232 * @param int $pollId Poll id
219233 */
220234 #[NoAdminRequired]
235+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
221236 #[FrontpageRoute(verb: 'PUT ' , url: '/poll/{pollId}/toggleArchive ' )]
222237 public function toggleArchive (int $ pollId ): JSONResponse {
223238 return $ this ->response (fn () => [
@@ -230,6 +245,7 @@ public function toggleArchive(int $pollId): JSONResponse {
230245 * @param int $pollId Poll id
231246 */
232247 #[NoAdminRequired]
248+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
233249 #[FrontpageRoute(verb: 'DELETE ' , url: '/poll/{pollId} ' )]
234250 public function delete (int $ pollId ): JSONResponse {
235251 return $ this ->response (fn () => [
@@ -242,6 +258,7 @@ public function delete(int $pollId): JSONResponse {
242258 * @param int $pollId Poll id
243259 */
244260 #[NoAdminRequired]
261+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
245262 #[FrontpageRoute(verb: 'PUT ' , url: '/poll/{pollId}/close ' )]
246263 public function close (int $ pollId ): JSONResponse {
247264 return $ this ->response (fn () => [
@@ -254,6 +271,7 @@ public function close(int $pollId): JSONResponse {
254271 * @param int $pollId Poll id
255272 */
256273 #[NoAdminRequired]
274+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
257275 #[FrontpageRoute(verb: 'PUT ' , url: '/poll/{pollId}/reopen ' )]
258276 public function reopen (int $ pollId ): JSONResponse {
259277 return $ this ->response (fn () => [
@@ -284,6 +302,7 @@ private function clonePoll(int $pollId): Poll {
284302 * @param string $sourceUserId User id to transfer polls from
285303 * @param string $targetUserId User id to transfer polls to
286304 */
305+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
287306 #[FrontpageRoute(verb: 'PUT ' , url: '/poll/transfer/{sourceUserId}/{targetUserId} ' )]
288307 public function transferPolls (string $ sourceUserId , string $ targetUserId ): JSONResponse {
289308 return $ this ->response (fn () => $ this ->pollService ->transferPolls ($ sourceUserId , $ targetUserId ));
@@ -295,6 +314,7 @@ public function transferPolls(string $sourceUserId, string $targetUserId): JSONR
295314 * @param string $targetUserId User to transfer polls to
296315 */
297316 #[NoAdminRequired]
317+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
298318 #[FrontpageRoute(verb: 'PUT ' , url: '/poll/{pollId}/changeowner/{targetUserId} ' )]
299319 public function changeOwner (int $ pollId , string $ targetUserId ): JSONResponse {
300320 return $ this ->response (fn () => $ this ->pollService ->transferPoll ($ pollId , $ targetUserId ));
@@ -305,8 +325,23 @@ public function changeOwner(int $pollId, string $targetUserId): JSONResponse {
305325 * @param int $pollId Poll id
306326 */
307327 #[NoAdminRequired]
328+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
308329 #[FrontpageRoute(verb: 'GET ' , url: '/poll/{pollId}/addresses ' )]
309330 public function getParticipantsEmailAddresses (int $ pollId ): JSONResponse {
310331 return $ this ->response (fn () => $ this ->pollService ->getParticipantsEmailAddresses ($ pollId ));
311332 }
333+
334+ /**
335+ * Delete orphaned votes
336+ * @param int $pollId poll id
337+ */
338+ #[NoAdminRequired]
339+ #[OpenAPI(OpenAPI::SCOPE_IGNORE )]
340+ #[FrontpageRoute(verb: 'DELETE ' , url: '/poll/{pollId}/votes/orphaned/all ' )]
341+ public function deleteOrphaned (int $ pollId ): JSONResponse {
342+ return $ this ->response (fn () => [
343+ 'deleted ' => $ this ->voteService ->deleteOrphanedVotes ($ pollId )
344+ ]);
345+ }
346+
312347}
0 commit comments