forked from prayagupa/smartad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
package controllers | ||
|
||
import play.api._ | ||
import java.net.URLEncoder | ||
import play.api.mvc._ | ||
import play.api.libs.ws.WS | ||
import akka.util.Timeout | ||
import play.api.libs.concurrent.Execution.Implicits._ | ||
import scala.concurrent.{ Await, Future } | ||
import scala.concurrent.duration._ | ||
import play.Logger | ||
import play.api.libs.json.JsValue | ||
|
||
|
||
object Application extends Controller { | ||
|
||
def index = Action { | ||
val url = "http://localhost:8443/DasTest/esReport?clientId=2000&reportingBasis=ServiceDate&reportingTo=2013-10-31&reportingFrom=2012-11-01&comparisonFrom=2011-11-01&comparisonTo=2012-10-31&report=qualityMetric&reportingPaidThrough=2013-10-31&comparisonPaidThrough=2012-10-31&phiCSDate=11-10-2008&phiCEDate=10-31-2013&isParticipation=y&program_type=Wellness&program_type=ActivityTracker" | ||
val responseFuture = WS.url(url).get().map { response => | ||
Ok("Feed title: " + (response.json \ "title").as[String]) | ||
println("Response : " + response.json.as[String]) | ||
def index = Action { | ||
val start = java.lang.System.currentTimeMillis() | ||
implicit val timeout = Timeout(50000 milliseconds) | ||
val url = "http://localhost:8443/DasTest/esReport?clientId=2000&reportingBasis=ServiceDate&reportingTo=2013-10-31&reportingFrom=2012-11-01&comparisonFrom=2011-11-01&comparisonTo=2012-10-31&report=qualityMetric&reportingPaidThrough=2013-10-31&comparisonPaidThrough=2012-10-31&phiCSDate=11-10-2008&phiCEDate=10-31-2013&isParticipation=y&program_type=Wellness&program_type=Activity%20Tracker" | ||
Logger.info("url : {}",url) | ||
val responseFuture = WS.url(url).get() | ||
val future = responseFuture map { | ||
response => (response.json \\ "reporting") | ||
} | ||
val future = responseFuture.value | ||
Ok(views.html.index(future.toString)) | ||
val result = Await.result(future, timeout.duration).asInstanceOf[List[play.api.libs.json.JsObject]] | ||
|
||
val size = result.size | ||
var jsonVal: JsValue = null | ||
var json: String = "" | ||
val json_ = result.foreach(jsonObject => | ||
jsonObject.values.foreach(jsValue => { | ||
Logger.info("jsvalue : "+jsValue) | ||
jsonVal = jsValue | ||
json = jsValue.toString() | ||
} | ||
) | ||
) | ||
val end = java.lang.System.currentTimeMillis() | ||
Logger.info("size : {}", size.toString) | ||
Logger.info("Time taken : {} seconds", ((end - start)/1000).toString) | ||
Ok(views.html.index(size, json.toString)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
@(message: String) | ||
@(size : Int, message: String) | ||
|
||
@main("OnlyWallet") { | ||
|
||
@play20.welcome(message) | ||
|
||
@size | ||
@message | ||
} |