@@ -134,10 +134,7 @@ fridayCommand =
134134 [qms |Could not check friday video
135135 duplicates because there is no YouTube
136136 id in the message.|]) $
137- liftR
138- (\ ytId ->
139- selectEntities (Proxy :: Proxy FridayVideo ) $
140- Filter (PropertyTextLike " name" (" %" <> ytId <> " %" )) All ) $
137+ liftR fridayVideosByYtId $
141138 cmapR
142139 (\ dups ->
143140 [qms |Added to the suggested video.
@@ -216,11 +213,13 @@ videoCommand =
216213 liftR (const currentVideo) $
217214 replyOnNothing " No videos in the queue" $
218215 cmapR entityPayload $
216+ liftFst (fmap length . fridayVideosByYtId . fridayVideoName) $
219217 cmapR
220- (\ video ->
218+ (\ ( video, times) ->
221219 [qms |{fridayVideoDate video}
222220 <{fridayVideoAuthor video}>
223- {fridayVideoName video}|]) $
221+ {fridayVideoName video} —
222+ This video was suggested {times} times.|]) $
224223 Reaction replyMessage
225224
226225currentFridayState :: Effect (Entity FridayState )
@@ -323,13 +322,15 @@ videoQueueCommand =
323322 cmapR (const " Freshness invalidated 👌" ) $ Reaction replyMessage)
324323 ]
325324
325+ fridayVideosByYtId :: T. Text -> Effect [Entity FridayVideo ]
326+ fridayVideosByYtId ytId =
327+ selectEntities Proxy $
328+ Filter (PropertyTextLike " name" (" %" <> ytId <> " %" )) All
329+
326330fridayCountCommand :: Reaction Message T. Text
327331fridayCountCommand =
328332 cmapR ytLinkId $
329333 replyOnNothing " Please submit a YouTube link" $
330- liftR
331- (\ ytId ->
332- selectEntities (Proxy :: Proxy FridayVideo ) $
333- Filter (PropertyTextLike " name" (" %" <> ytId <> " %" )) All ) $
334+ liftR fridayVideosByYtId $
334335 cmapR (\ dups -> [qms |This video was suggested {length dups} times|]) $
335336 Reaction replyMessage
0 commit comments