@@ -97,8 +97,6 @@ class MapFragment : Fragment() {
9797 var statusBarController: MapStatusBarController ? = null
9898 var bottomSheetController: BottomSheetController ? = null
9999
100- private var dbCallCount = 0
101- private var lastDbCallTimeMs = 0L
102100 private var lastMerchantsGeoJson: String? = null
103101 private var lastEventsGeoJson: String? = null
104102 private var lastExchangesGeoJson: String? = null
@@ -631,8 +629,6 @@ class MapFragment : Fragment() {
631629 merchantsCache = PlaceCache ()
632630 exchangesCache = PlaceCache ()
633631 eventsCache = EventCache ()
634- dbCallCount = 0
635- lastDbCallTimeMs = 0L
636632
637633 when (filter) {
638634 Filter .MERCHANTS -> showMerchants()
@@ -663,8 +659,6 @@ class MapFragment : Fragment() {
663659 val expandedBounds = expandBounds(bounds)
664660 viewLifecycleOwner.lifecycleScope.launch {
665661 if (! merchantsCache.contains(expandedBounds)) {
666- dbCallCount++
667- val startTime = System .currentTimeMillis()
668662 val newMerchants = withContext(Dispatchers .IO ) {
669663 db().place.selectMerchantsByBounds(
670664 expandedBounds.latitudeSouth,
@@ -675,7 +669,6 @@ class MapFragment : Fragment() {
675669 .minusYears(prefs.verifiedFilterYears.toLong()),
676670 )
677671 }
678- lastDbCallTimeMs = System .currentTimeMillis() - startTime
679672 merchantsCache = merchantsCache.add(newMerchants, expandedBounds)
680673 }
681674 val geoJson = merchantsCache.features.toGeoJson()
@@ -695,8 +688,6 @@ class MapFragment : Fragment() {
695688 val expandedBounds = expandBounds(bounds)
696689 viewLifecycleOwner.lifecycleScope.launch {
697690 if (! eventsCache.contains(expandedBounds)) {
698- dbCallCount++
699- val startTime = System .currentTimeMillis()
700691 val newEvents = withContext(Dispatchers .IO ) {
701692 db().event.selectByBounds(
702693 expandedBounds.latitudeSouth,
@@ -705,7 +696,6 @@ class MapFragment : Fragment() {
705696 expandedBounds.longitudeEast,
706697 )
707698 }
708- lastDbCallTimeMs = System .currentTimeMillis() - startTime
709699 eventsCache = eventsCache.add(newEvents, expandedBounds)
710700 }
711701 val geoJson = eventsCache.features.toEventsGeoJson()
@@ -725,8 +715,6 @@ class MapFragment : Fragment() {
725715 val expandedBounds = expandBounds(bounds)
726716 viewLifecycleOwner.lifecycleScope.launch {
727717 if (! exchangesCache.contains(expandedBounds)) {
728- dbCallCount++
729- val startTime = System .currentTimeMillis()
730718 val newExchanges = withContext(Dispatchers .IO ) {
731719 db().place.selectExchangesByBounds(
732720 expandedBounds.latitudeSouth,
@@ -735,7 +723,6 @@ class MapFragment : Fragment() {
735723 expandedBounds.longitudeEast,
736724 )
737725 }
738- lastDbCallTimeMs = System .currentTimeMillis() - startTime
739726 exchangesCache = exchangesCache.add(newExchanges, expandedBounds)
740727 }
741728 val geoJson = exchangesCache.features.toGeoJson()
@@ -786,7 +773,10 @@ class MapFragment : Fragment() {
786773 binding.debugStats.apply {
787774 text =
788775 " memcache: %d items\n memcache bounds: %s\n db queries: %d\n last query: %dms" .format(
789- cacheSize, viewportInfo, dbCallCount, lastDbCallTimeMs
776+ cacheSize,
777+ viewportInfo,
778+ db().place.selectMerchantsByBoundsCallCount,
779+ db().place.selectMerchantsByBoundsLastCallDurationMs,
790780 )
791781 isVisible = true
792782 }
0 commit comments