[
https://issues.apache.org/jira/browse/PIO-110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16141265#comment-16141265
]
ASF GitHub Bot commented on PIO-110:
------------------------------------
Github user shimamoto commented on a diff in the pull request:
https://github.com/apache/incubator-predictionio/pull/425#discussion_r135180795
--- Diff:
data/src/main/scala/org/apache/predictionio/data/api/Webhooks.scala ---
@@ -62,22 +53,23 @@ private[predictionio] object Webhooks {
}
eventFuture.flatMap { eventOpt =>
- if (eventOpt.isEmpty) {
- Future successful {
- val message = s"webhooks connection for ${web} is not supported."
- (StatusCodes.NotFound, Map("message" -> message))
- }
- } else {
- val event = eventOpt.get
- val data = eventClient.futureInsert(event, appId, channelId).map {
id =>
- val result = (StatusCodes.Created, Map("eventId" -> s"${id}"))
-
- if (stats) {
- statsActorRef ! Bookkeeping(appId, result._1, event)
+ eventOpt match {
+ case None =>
+ Future successful {
+ val message = s"webhooks connection for ${web} is not
supported."
+ (StatusCodes.NotFound, Map("message" -> message))
--- End diff --
It's better to use in function args for pattern matching.
```scala
eventFuture.flatMap {
case None => ...
case Some(event) => ...
}
```
> Refactor common code shared by CreateServer and BatchPredict
> ------------------------------------------------------------
>
> Key: PIO-110
> URL: https://issues.apache.org/jira/browse/PIO-110
> Project: PredictionIO
> Issue Type: Improvement
> Components: Core
> Affects Versions: 0.12.0-incubating
> Reporter: Donald Szeto
> Assignee: Naoki Takezoe
> Labels: newbie
>
> {{BatchPredict}} was created in PIO-105 and has a substantial amount of
> shared code with {{CreateServer}}. It would be beneficial to refactor both of
> them to share as much common code as possible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)