package Ġcom . th om ask io ko . tv man iac . discover . implementation . cache Ċ Ċ import Ġcom . squareup . sql de light . runtime . coroutines . as Flow Ċ import Ġcom . squareup . sql de light . runtime . coroutines . map ToList Ċ import Ġcom . th om ask io ko . tv man iac . datasource . cache . Select Shows Ċ import Ġcom . th om ask io ko . tv man iac . datasource . cache . Show _ category Ċ import Ġcom . th om ask io ko . tv man iac . datasource . cache . Tv Man iac Database Ċ import Ġcom . th om ask io ko . tv man iac . discover . api . cache . Show Category Cache Ċ import Ġkotlinx . coroutines . flow . Flow Ċ Ċ class ĠShow Category Cache Impl ( ĊĠĠĠ Ġprivate Ġval Ġdatabase : ĠT v Man iac Database Ċ ) Ġ: ĠShow Category Cache Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġshow Category Query Ġget () Ġ= Ġdatabase . show Category Queries ĊĊĠĠĠ Ġoverride Ġfun Ġinsert ( category : ĠShow _ category ) Ġ{ ĊĠĠĠĠĠĠĠ Ġshow Category Query . insert Or Replace ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow _ id Ġ= Ġcategory . show _ id , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcategory _ id Ġ= Ġcategory . category _ id ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Show sBy Category ID ( id : ĠInt ): ĠList < Select Shows > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġshow Category Query . select Shows ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcategory _ id Ġ= Ġid . to Long () ĊĠĠĠĠĠĠĠ Ġ). execute As List () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġobserve Show sBy Category ID ( id : ĠInt ): ĠFlow < List < Select Shows >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġshow Category Query . select Shows ( category _ id Ġ= Ġid . to Long ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. as Flow () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map ToList () ĊĠĠĠ Ġ} Ċ } Ċ