From 342ca8a239f7b159578c6bdd1b85693eb82e4373 Mon Sep 17 00:00:00 2001 From: Vladimir Koshelev Date: Tue, 7 Nov 2023 14:45:29 +0100 Subject: [PATCH] [python] fix fus logging for daemon imports PY-63929 GitOrigin-RevId: 93402487cd40ceea9a2b1023e030a82a4979f84c --- .../jetbrains/python/statistics/PyPackageDaemonListener.kt | 5 +++-- .../python/statistics/PyPackageInEditorUsageCollector.kt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/statistics/PyPackageDaemonListener.kt b/python/src/com/jetbrains/python/statistics/PyPackageDaemonListener.kt index 72147f9c91f5..d8c132eb0fc4 100644 --- a/python/src/com/jetbrains/python/statistics/PyPackageDaemonListener.kt +++ b/python/src/com/jetbrains/python/statistics/PyPackageDaemonListener.kt @@ -67,8 +67,9 @@ internal class TaskExecutor(private val cs: CoroutineScope) { } ?: emptyMap() psiFile.children.filterIsInstance().mapNotNull { import -> - import.importElements.firstNotNullOfOrNull { it.importedQName?.firstComponent }?.let { firstModule -> - val packageName = PyPsiPackageUtil.moduleToPackageName(firstModule) + // all imports from the same statement should start with the same module + import.fullyQualifiedObjectNames.firstOrNull()?.let { firstModule -> + val packageName = PyPsiPackageUtil.moduleToPackageName(firstModule.split('.').first()) PackageUsage( name = packageName, version = packages2Versions[packageName] ?: "0.0", diff --git a/python/src/com/jetbrains/python/statistics/PyPackageInEditorUsageCollector.kt b/python/src/com/jetbrains/python/statistics/PyPackageInEditorUsageCollector.kt index f831e175b5ff..54bb64e29f47 100644 --- a/python/src/com/jetbrains/python/statistics/PyPackageInEditorUsageCollector.kt +++ b/python/src/com/jetbrains/python/statistics/PyPackageInEditorUsageCollector.kt @@ -12,7 +12,7 @@ class PyPackageInEditorUsageCollector : ProjectUsagesCollector() { val keys = PyPackageUsageStatistics.getInstance(project).getStatisticsAndResetState().keys return keys.map { packageUsage -> PYTHON_PACKAGES_IN_EDITOR.metric(PACKAGE_FIELD.with(packageUsage.name), - PACKAGE_VERSION_FIELD.with(packageUsage.name), + PACKAGE_VERSION_FIELD.with(packageUsage.version), INTERPRETER_TYPE.with(packageUsage.interpreterTypeValue), EXECUTION_TYPE.with(packageUsage.targetTypeValue), HAS_SDK.with(packageUsage.hasSdk!!)