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 +