Browse Source

Changed the range of the id

Now the id value will be from 1 to 10000 inclusive. The 'nextInt(int maxValue)' returns results in the range [0, maxValue) i.e. maxValue is excluded.
Radoslav Petrov 9 years ago
parent
commit
c208042772

+ 1 - 1
frameworks/Scala/scruffy/src/main/scala/scruffy/examples/Test2Endpoint.scala

@@ -21,7 +21,7 @@ object Test2Endpoint extends HttpModule {
   //  collection.save(DBObject("_id" -> k, "id" -> k, "randomNumber" -> random.nextInt(10000).toDouble))
 
   get("db") { req =>
-    val id = ThreadLocalRandom.current.nextInt(10000)
+    val id = 1 + ThreadLocalRandom.current.nextInt(10000)
     val dbo = collection.findOne(DBObject("_id" -> id), fields)
     val randomNumber = Math.round(dbo.get("randomNumber").toString.toFloat)
     Output(id, randomNumber).json