package Ġde . r ki . cor on aw arn app . presence tracing . risk . storage Ċ Ċ import Ġandroidx . room . Column Info Ċ import Ġandroidx . room . Dao Ċ import Ġandroidx . room . Entity Ċ import Ġandroidx . room . Insert Ċ import Ġandroidx . room . On Conflict Strategy Ċ import Ġandroidx . room . PrimaryKey Ċ import Ġandroidx . room . Query Ċ import Ġandroidx . room . Type Converter Ċ import Ġde . r ki . cor on aw arn app . presence tracing . risk . Pt Risk Level Result Ċ import Ġde . r ki . cor on aw arn app . presence tracing . risk . Trace Location Check In Risk Ċ import Ġde . r ki . cor on aw arn app . presence tracing . risk . calculation . Check In Warning Overlap Ċ import Ġde . r ki . cor on aw arn app . presence tracing . risk . calculation . Presence Tracing Day Risk Ċ import Ġde . r ki . cor on aw arn app . risk . Risk State Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġorg . joda . time . Instant Ċ Ċ /* Ċ * ĠStores Ġmatches Ġfrom Ġthe Ġlast Ġsuccessful Ġexecution Ċ * Ġ*/ Ċ @ Dao Ċ interface ĠTrace Time Interval Match Dao Ġ{ ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM ĠTrace Time Interval Match Entity ") ĊĠĠĠ Ġfun Ġall Matches (): ĠFlow < List < Trace Time Interval Match Entity >> ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM ĠTrace Time Interval Match Entity ") ĊĠĠĠ Ġsuspend Ġfun Ġdelete All () ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM ĠTrace Time Interval Match Entity ĠWHERE ĠendTime Millis Ġ< Ġ: endTime Millis ") ĊĠĠĠ Ġsuspend Ġfun Ġdelete Ol der Than ( endTime Millis : ĠLong ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM ĠTrace Time Interval Match Entity ĠWHERE Ġtrace Warning Package Id Ġ= Ġ: warning Package Id ") ĊĠĠĠ Ġsuspend Ġfun Ġdelete Matches For Package ( warning Package Id : ĠString ) ĊĊĠĠĠ Ġ@ Insert ĊĠĠĠ Ġsuspend Ġfun Ġinsert ( entities : ĠList < Trace Time Interval Match Entity >) Ċ } Ċ Ċ @ Entity Ċ data Ġclass ĠTrace Time Interval Match Entity ( ĊĠĠĠ Ġ@ PrimaryKey ( auto Generate Ġ= Ġtrue ) Ġ@ Column Info ( name Ġ= Ġ" id ") Ġval Ġid : ĠLong ? Ġ= Ġnull , ĊĠĠĠ Ġ@ Column Info ( name Ġ= Ġ" check In Id ") Ġval Ġcheck In Id : ĠLong , ĊĠĠĠ Ġ@ Column Info ( name Ġ= Ġ" trace Warning Package Id ") Ġval Ġtrace Warning Package Id : ĠString , ĊĠĠĠ Ġ@ Column Info ( name Ġ= Ġ" transmission Risk Level ") Ġval Ġtransmission Risk Level : ĠInt , ĊĠĠĠ Ġ@ Column Info ( name Ġ= Ġ" startTime Millis ") Ġval ĠstartTime Millis : ĠLong , ĊĠĠĠ Ġ@ Column Info ( name Ġ= Ġ" endTime Millis ") Ġval ĠendTime Millis : ĠLong Ċ ) Ċ Ċ internal Ġfun ĠCheck In Warning Overlap . to Trace Time Interval Match Entity () Ġ= ĠTrace Time Interval Match Entity ( ĊĠĠĠ Ġcheck In Id Ġ= Ġcheck In Id , ĊĠĠĠ Ġtrace Warning Package Id Ġ= Ġtrace Warning Package Id , ĊĠĠĠ Ġtransmission Risk Level Ġ= Ġtransmission Risk Level , ĊĠĠĠ ĠstartTime Millis Ġ= ĠstartTime . millis , ĊĠĠĠ ĠendTime Millis Ġ= ĠendTime . millis Ċ ) Ċ Ċ internal Ġfun ĠTrace Time Interval Match Entity . to Check In Warning Overlap () Ġ= ĠCheck In Warning Overlap ( ĊĠĠĠ Ġcheck In Id Ġ= Ġcheck In Id , ĊĠĠĠ Ġtrace Warning Package Id Ġ= Ġtrace Warning Package Id , ĊĠĠĠ Ġtransmission Risk Level Ġ= Ġtransmission Risk Level , ĊĠĠĠ ĠstartTime Ġ= ĠInstant . of Epoch Milli ( startTime Millis ), ĊĠĠĠ ĠendTime Ġ= ĠInstant . of Epoch Milli ( endTime Millis ) Ċ ) Ċ Ċ @ Suppress (" Max Line Length ") Ċ @ Dao Ċ interface ĠPres ence Tracing Risk Level Result Dao Ġ{ ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM ĠPres ence Tracing Risk Level Result Entity ĠORDER ĠBY Ġcalculated At Millis ĠDESC ĠLIMIT Ġ: limit ") ĊĠĠĠ Ġfun Ġlatest Entries ( limit : ĠInt ): ĠFlow < List < Presence Tracing Risk Level Result Entity >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM ĠPres ence Tracing Risk Level Result Entity ") ĊĠĠĠ Ġfun Ġall Entries (): ĠFlow < List < Presence Tracing Risk Level Result Entity >> ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġinsert ( entity : ĠPres ence Tracing Risk Level Result Entity ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM ĠPres ence Tracing Risk Level Result Entity ĠWHERE Ġcalculated At Millis Ġ< Ġ: calculated At Millis ") ĊĠĠĠ Ġsuspend Ġfun Ġdelete Ol der Than ( calculated At Millis : ĠLong ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM ĠPres ence Tracing Risk Level Result Entity ") ĊĠĠĠ Ġsuspend Ġfun Ġdelete All () Ċ } Ċ Ċ @ Entity Ċ data Ġclass ĠPres ence Tracing Risk Level Result Entity ( ĊĠĠĠ Ġ@ PrimaryKey Ġ@ Column Info ( name Ġ= Ġ" calculated At Millis ") Ġval Ġcalculated At Millis : ĠLong , ĊĠĠĠ Ġ@ Column Info ( name Ġ= Ġ" risk State Code ") Ġval Ġrisk State : ĠR isk State , ĊĠĠĠ Ġ@ Column Info ( name Ġ= Ġ" calculated From Millis ") Ġval Ġcalculated From Millis : ĠLong , Ċ ) Ċ Ċ internal Ġfun ĠPres ence Tracing Risk Level Result Entity . to Risk Level Result ( ĊĠĠĠ Ġpresence Tracing Day R is ks : ĠList < Presence Tracing Day Risk >? Ġ= Ġnull , ĊĠĠĠ Ġtrace Location Check In Risk States : ĠList < Trace Location Check In Risk >? Ġ= Ġnull , ĊĠĠĠ Ġcheck In Warning Overlap s : ĠList < Check In Warning Overlap >? Ġ= Ġnull Ċ ) Ġ= ĠPt Risk Level Result ( ĊĠĠĠ Ġcalculated At Ġ= ĠInstant . of Epoch Milli (( calculated At Millis )), ĊĠĠĠ Ġrisk State Ġ= Ġrisk State , ĊĠĠĠ Ġpresence Tracing Day Risk Ġ= Ġpresence Tracing Day R is ks , ĊĠĠĠ Ġtrace Location Check In Risk States Ġ= Ġtrace Location Check In Risk States , ĊĠĠĠ Ġcheck In Warning Overlap s Ġ= Ġcheck In Warning Overlap s , ĊĠĠĠ Ġcalculated From Ġ= ĠInstant . of Epoch Milli (( calculated From Millis )), Ċ ) Ċ Ċ internal Ġfun ĠPt Risk Level Result . to Risk Level Entity () Ġ= ĠPres ence Tracing Risk Level Result Entity ( ĊĠĠĠ Ġcalculated At Millis Ġ= Ġcalculated At . millis , ĊĠĠĠ Ġrisk State Ġ= Ġrisk State , ĊĠĠĠ Ġcalculated From Millis Ġ= Ġcalculated From . millis , Ċ ) Ċ Ċ class ĠR isk State Converter Ġ{ ĊĠĠĠ Ġ@ Type Converter ĊĠĠĠ Ġfun Ġto Risk State Code ( value : ĠInt ?): ĠR isk State ? Ġ= Ġvalue ?. to Risk State () ĊĊĠĠĠ Ġ@ Type Converter ĊĠĠĠ Ġfun Ġfrom Risk State Code ( code : ĠR isk State ?): ĠInt ? Ġ= Ġcode ?. to Code () ĊĊĠĠĠ Ġprivate Ġfun ĠR isk State . to Code () Ġ= Ġwhen Ġ( this ) Ġ{ ĊĠĠĠĠĠĠĠ ĠR isk State . CAL C UL ATION _ FAILED Ġ-> ĠCAL C UL ATION _ FAILED ĊĠĠĠĠĠĠĠ ĠR isk State . LOW _ R IS K Ġ-> ĠLOW _ R IS K ĊĠĠĠĠĠĠĠ ĠR isk State . INCRE ASE D _ R IS K Ġ-> ĠIN CRE ASE D _ R IS K ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠInt . to Risk State () Ġ= Ġwhen Ġ( this ) Ġ{ ĊĠĠĠĠĠĠĠ ĠCAL C UL ATION _ FAILED Ġ-> ĠR isk State . CAL C UL ATION _ FAILED ĊĠĠĠĠĠĠĠ ĠLOW _ R IS K Ġ-> ĠR isk State . LOW _ R IS K ĊĠĠĠĠĠĠĠ ĠIN CRE ASE D _ R IS K Ġ-> ĠR isk State . INCRE ASE D _ R IS K ĊĠĠĠĠĠĠĠ Ġelse Ġ-> Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠCAL C UL ATION _ FAILED Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠLOW _ R IS K Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠIN CRE ASE D _ R IS K Ġ= Ġ 2 ĊĠĠĠ Ġ} Ċ } Ċ