From 5450e109e74caad26b7ab51159c55aeda65d1c3c Mon Sep 17 00:00:00 2001 From: daprof1 Date: Mon, 25 Mar 2019 16:15:04 -0500 Subject: [PATCH] Update OilSource.scala So found this bug on my retro server. It only shows up when the actual cycle sim time is less than the scheduled time. Main sim runs the cycle then increments the week. This causes the current oil prices (for contracts, etc) not be able to load (and then defaults to 70) as it's requesting "NEXT WEEK" if you check prices during the time the simulator has finished with the last week but hasn't started the next week. Of course you could just change the order of the main sim actor so it increments first then triggers start cycle, but due to consistency concerns I did it this way. --- .../src/main/scala/com/patson/data/OilSource.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/airline-data/src/main/scala/com/patson/data/OilSource.scala b/airline-data/src/main/scala/com/patson/data/OilSource.scala index 5dcdbddb8..a64704d42 100644 --- a/airline-data/src/main/scala/com/patson/data/OilSource.scala +++ b/airline-data/src/main/scala/com/patson/data/OilSource.scala @@ -140,9 +140,14 @@ object OilSource { def loadOilPriceByCycle(cycle : Int) : Option[OilPrice] = { var queryString = "SELECT * FROM " + OIL_PRICE_TABLE + " WHERE cycle = ?" - val result = loadOilPricesByQueryString(queryString, List(cycle)) + var result = loadOilPricesByQueryString(queryString, List(cycle)) if (result.isEmpty) { - None + result = loadOilPricesByQueryString(queryString, List(cycle-1)) + if (result.isEmpty) { + None + } else { + Some(result(0)) + } } else { Some(result(0)) } @@ -365,4 +370,4 @@ object OilSource { } } - \ No newline at end of file +