Skip to content

Commit c15aa42

Browse files
committed
Lookup messages for a MailingList rather than a particular archive
1 parent 83006ae commit c15aa42

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/controllers/Api.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ class Api @Inject() (cached: Cached) extends Controller {
1616

1717
def messageLookup(repoId: RepoId, query: String) = cached(s"$repoId $query") {
1818
Action.async {
19-
val archives = Project.byRepoId(repoId).mailingList.archives
2019
for {
21-
messagesOpt <- Future.find(archives.map(_.lookupMessage(query)))(_.nonEmpty)
22-
} yield Ok(toJson(messagesOpt.toSeq.flatten: Seq[MessageSummary]))
20+
messagesOpt <- Project.byRepoId(repoId).mailingList.lookupMessage(query)
21+
} yield Ok(toJson(messagesOpt: Seq[MessageSummary]))
2322
}
2423
}
2524

app/lib/ProjectRepo.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package lib
22

33
import com.madgag.github.RepoId
4+
import lib.model.MessageSummary
45

5-
case class MailingList(emailAddress: String, archives: Seq[MailArchive])
6+
import scala.concurrent.{ExecutionContext, Future}
7+
8+
case class MailingList(emailAddress: String, archives: Seq[MailArchive]) {
9+
def lookupMessage(query: String)(implicit ec: ExecutionContext): Future[Seq[MessageSummary]] =
10+
Future.find(archives.map(_.lookupMessage(query)))(_.nonEmpty).map(_.toSeq.flatten)
11+
}
612

713
object Project {
814
val Git = Project(

0 commit comments

Comments
 (0)