From 9106b0a3c80d8e39102e2f0b3cec270a10a4ed7a Mon Sep 17 00:00:00 2001 From: Dmitry Pogrebnoy Date: Thu, 30 Nov 2023 19:52:39 +0100 Subject: [PATCH] IDEA-338866 Set time scope for feedback collection for tips of the day (cherry picked from commit 8826a4cc3a5484b07c5223eb5693ef8da93af481) IJ-CR-121256 GitOrigin-RevId: 966b6fb35426abf42415ec0d1ec6d5b36bfeac74 --- platform/tips-of-the-day/intellij.platform.tips.iml | 1 + .../src/com/intellij/ide/util/TipsFeedback.kt | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/platform/tips-of-the-day/intellij.platform.tips.iml b/platform/tips-of-the-day/intellij.platform.tips.iml index b46f1b17fa10..3be5bb0b72eb 100644 --- a/platform/tips-of-the-day/intellij.platform.tips.iml +++ b/platform/tips-of-the-day/intellij.platform.tips.iml @@ -40,6 +40,7 @@ + \ No newline at end of file diff --git a/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt b/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt index bdcdd19c9e8b..b5e54cc824ff 100644 --- a/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt +++ b/platform/tips-of-the-day/src/com/intellij/ide/util/TipsFeedback.kt @@ -9,12 +9,18 @@ import com.intellij.platform.feedback.impl.FeedbackRequestData import com.intellij.platform.feedback.impl.FeedbackRequestType import com.intellij.platform.feedback.impl.submitFeedback import com.intellij.util.xmlb.annotations.XMap +import kotlinx.datetime.Clock +import kotlinx.datetime.TimeZone +import kotlinx.datetime.periodUntil +import kotlinx.datetime.toKotlinInstant import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put @Service @State(name = "TipsFeedback", storages = [Storage(value = "tips-feedback.xml", roamingType = RoamingType.DISABLED)]) class TipsFeedback : SimplePersistentStateComponent(State()) { + private val timeScopeForResultCollectionInDays = 120 + fun getLikenessState(tipId: String): Boolean? { return state.tipToLikeness[tipId] } @@ -35,6 +41,12 @@ class TipsFeedback : SimplePersistentStateComponent(State()) } fun scheduleFeedbackSending(tipId: String, likenessState: Boolean) { + val buildDate = ApplicationInfo.getInstance().buildDate + val buildToCurrentPeriod = buildDate.toInstant().toKotlinInstant().periodUntil(Clock.System.now(), TimeZone.currentSystemDefault()) + if (buildToCurrentPeriod.days > timeScopeForResultCollectionInDays) { + return + } + val dataJsonObject = buildJsonObject { put("format_version", FEEDBACK_FORMAT_VERSION) put("tip_id", tipId)