Skip to content

Commit

Permalink
tweak when CheckExistence is triggered
Browse files Browse the repository at this point in the history
based on automated analysis of how people answered this quests: few people who halved asking time for parkings quite often found ones not existing ones
and basically all questions about traffic calming just confirmed their existence

therefore traffic calming is now asked later, parking are asked about earlier now to use mapper time more effectively

also, add test confirming I have not broken the element filter
  • Loading branch information
matkoniecz committed Mar 31, 2023
1 parent 36fe514 commit 47f41be
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class CheckExistence(
amenity = bench
or amenity = lounger
or amenity = waste_basket
or traffic_calming ~ bump|mini_bumps|hump|cushion|rumble_strip|dip|double_dip
or traffic_calming = table and !highway and !crossing
or amenity = recycling and recycling_type = container
or amenity = toilets
or amenity = drinking_water
Expand All @@ -68,7 +66,13 @@ class CheckExistence(
(
amenity ~ bicycle_parking|motorcycle_parking|taxi
)
and (${lastChecked(12.0)})
and (${lastChecked(10.0)})
) or (
(
traffic_calming ~ bump|mini_bumps|hump|cushion|rumble_strip|dip|double_dip
or traffic_calming = table and !highway and !crossing
)
and (${lastChecked(14.0)})
))
and access !~ no|private
and (!seasonal or seasonal = no)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
package de.westnordost.streetcomplete.quests.existence

import de.westnordost.osmfeatures.FeatureDictionary
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryAdd
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryDelete
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryModify
import de.westnordost.streetcomplete.osm.nowAsCheckDateString
import de.westnordost.streetcomplete.quests.verifyAnswer
import de.westnordost.streetcomplete.testutils.mock
import de.westnordost.streetcomplete.testutils.node
import de.westnordost.streetcomplete.testutils.on
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
import org.junit.Assert
import org.junit.Test
import java.util.concurrent.FutureTask

class CheckExistenceTest {
private val questType = CheckExistence(mock())
private val questType = CheckExistence(mockOfFeatureDictionary())

private fun mockOfFeatureDictionary(): FutureTask<FeatureDictionary> {
// another option is following CheckExistenceLabelTest
// and doing it as an androidTest
val matchFound: FeatureDictionary.QueryByTagBuilder = mock()
on(matchFound.find()).thenReturn(listOf(mock()))
on(matchFound.isSuggestion(false)).thenReturn(matchFound)

val noMatches: FeatureDictionary.QueryByTagBuilder = mock()
on(noMatches.find()).thenReturn(emptyList())
on(noMatches.isSuggestion(false)).thenReturn(noMatches)

val tagFinder: FeatureDictionary = mock()
on(tagFinder.byTags(mapOf("amenity" to "telephone"))).thenReturn(matchFound)
on(tagFinder.byTags(mapOf("shop" to "weird_value"))).thenReturn(noMatches)

val tagFinderFutureTask: FutureTask<FeatureDictionary> = mock()
on(tagFinderFutureTask.get()).thenReturn(tagFinder)
return tagFinderFutureTask
}

@Test fun `apply answer adds check date`() {
questType.verifyAnswer(
Expand All @@ -35,4 +61,29 @@ class CheckExistenceTest {
StringMapEntryDelete("survey_date", "d"),
)
}

@Test fun `isApplicableTo returns false for known places with recently edited amenity=telephone`() {
Assert.assertFalse(
questType.isApplicableTo(
node(
tags = mapOf(
"amenity" to "telephone",
), timestamp = nowAsEpochMilliseconds()
)
)
)
}

@Test fun `isApplicableTo returns true for known places with old amenity=telephone`() {
val milisecondsFor800Days: Long = 1000L * 60 * 60 * 24 * 800
Assert.assertTrue(
questType.isApplicableTo(
node(
tags = mapOf(
"amenity" to "telephone",
), timestamp = nowAsEpochMilliseconds() - milisecondsFor800Days
)
)
)
}
}

0 comments on commit 47f41be

Please sign in to comment.