Skip to content

Commit 8a9cd17

Browse files
committed
Extract fridayVideosByYtId
1 parent a2f2265 commit 8a9cd17

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/Bot/Friday.hs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
@@ -323,13 +320,15 @@ videoQueueCommand =
323320
cmapR (const "Freshness invalidated 👌") $ Reaction replyMessage)
324321
]
325322

323+
fridayVideosByYtId :: T.Text -> Effect [Entity FridayVideo]
324+
fridayVideosByYtId ytId =
325+
selectEntities Proxy $
326+
Filter (PropertyTextLike "name" ("%" <> ytId <> "%")) All
327+
326328
fridayCountCommand :: Reaction Message T.Text
327329
fridayCountCommand =
328330
cmapR ytLinkId $
329331
replyOnNothing "Please submit a YouTube link" $
330-
liftR
331-
(\ytId ->
332-
selectEntities (Proxy :: Proxy FridayVideo) $
333-
Filter (PropertyTextLike "name" ("%" <> ytId <> "%")) All) $
332+
liftR fridayVideosByYtId $
334333
cmapR (\dups -> [qms|This video was suggested {length dups} times|]) $
335334
Reaction replyMessage

0 commit comments

Comments
 (0)