mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-338866 Set time scope for feedback collection for tips of the day
(cherry picked from commit 8826a4cc3a5484b07c5223eb5693ef8da93af481) IJ-CR-121256 GitOrigin-RevId: 966b6fb35426abf42415ec0d1ec6d5b36bfeac74
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7e4b6b7aed
commit
9106b0a3c8
@@ -40,6 +40,7 @@
|
||||
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
|
||||
<orderEntry type="library" name="kotlinx-serialization-core" level="project" />
|
||||
<orderEntry type="library" name="kotlinx-serialization-json" level="project" />
|
||||
<orderEntry type="library" name="kotlinx-datetime-jvm" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.feedback" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -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<TipsFeedback.State>(State()) {
|
||||
private val timeScopeForResultCollectionInDays = 120
|
||||
|
||||
fun getLikenessState(tipId: String): Boolean? {
|
||||
return state.tipToLikeness[tipId]
|
||||
}
|
||||
@@ -35,6 +41,12 @@ class TipsFeedback : SimplePersistentStateComponent<TipsFeedback.State>(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)
|
||||
|
||||
Reference in New Issue
Block a user