Skip to content

Commit

Permalink
Merge pull request #2235 from hongwei1/bugfix/addedGuardForEmptyList
Browse files Browse the repository at this point in the history
bugfix/added the guard for emptyList of atms for MxOF
  • Loading branch information
simonredfern authored Jun 20, 2023
2 parents 8b522a5 + 38c03e7 commit 7043325
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package code.api.MxOF

import code.api.util.{APIUtil, CustomJsonFormats}
import code.api.util.APIUtil.{defaultBankId, listOrNone, stringOrNone}
import code.api.util.APIUtil.{defaultBankId, listOrNone, stringOrNone, theEpochTime}
import code.atms.MappedAtm
import code.bankattribute.BankAttribute
import com.openbankproject.commons.model.Bank
Expand Down Expand Up @@ -170,10 +170,16 @@ object JSONFactory_MXOF_0_0_1 extends CustomJsonFormats {
)
}
)
val lastUpdated: Date = MappedAtm.findAll(
val mappedAtmList: List[MappedAtm] = MappedAtm.findAll(
NotNullRef(MappedAtm.updatedAt),
OrderBy(MappedAtm.updatedAt, Descending),
).head.updatedAt.get
)

val lastUpdated: Date = if(mappedAtmList.nonEmpty) {
mappedAtmList.head.updatedAt.get
}else{
theEpochTime
}

val agreement = attributes.find(_.name.equals(BANK_ATTRIBUTE_AGREEMENT)).map(_.value).getOrElse("")
val license = attributes.find(_.name.equals(BANK_ATTRIBUTE_LICENSE)).map(_.value).getOrElse("")
Expand Down

0 comments on commit 7043325

Please sign in to comment.