Skip to content

Commit

Permalink
Support run's languages
Browse files Browse the repository at this point in the history
  • Loading branch information
kunyavskiy committed Aug 28, 2024
1 parent 86f7b58 commit 1f0aaa0
Show file tree
Hide file tree
Showing 40 changed files with 62,055 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ private fun OrganizationInfo.toClicsOrg() = Organization(
logo = listOfNotNull(logo?.toClicsMedia())
)

private fun LanguageInfo.toClicsLang() = Language(
id = id.value,
name = name,
extensions = extensions
)


private fun MediaType.toClicsMedia() = when (this) {
is MediaType.Object -> null
is MediaType.Image -> File("image", Url(url))
Expand Down Expand Up @@ -106,12 +113,12 @@ object ClicsExporter {
it.toJudgmentType()
}

private val unknownLanguage = Language(
"unknown",
private val unknownLanguage = LanguageInfo(
id = "unknown".toLanguageId(),
name = "unknown",
extensions = emptyList()
)

private val languages = listOf(unknownLanguage)

private suspend fun <ID, T> FlowCollector<EventProducer>.updateEvent(id: ID, data: T, block : (ID, String, T?) -> Event) = emit {
block(id, it, data)
}
Expand Down Expand Up @@ -216,7 +223,7 @@ object ClicsExporter {
run.id.toString(),
Submission(
id = run.id.toString(),
languageId = unknownLanguage.id,
languageId = (run.languageId ?: unknownLanguage.id).value,
problemId = run.problemId.value,
teamId = run.teamId.value,
time = info.startTimeOrZero + run.time,
Expand Down Expand Up @@ -251,6 +258,7 @@ object ClicsExporter {

private val groupsMap = mutableMapOf<GroupId, GroupInfo>()
private val orgsMap = mutableMapOf<OrganizationId, OrganizationInfo>()
private val languagesMap = mutableMapOf<LanguageId, LanguageInfo>()
private val problemsMap = mutableMapOf<ProblemId, ProblemInfo>()
private val teamsMap = mutableMapOf<TeamId, TeamInfo>()

Expand All @@ -262,18 +270,17 @@ object ClicsExporter {
for (type in judgmentTypes.values) {
updateEvent(type.id, type, ::JudgementTypeEvent)
}
for (language in languages) {
updateEvent(language.id, language, ::LanguageEvent)
}
}
diff(problemsMap, newInfo.problemList, { id }, { toClicsProblem() }) { id, token, data -> ProblemEvent(id.value, token, data) }
diffChange(groupsMap, newInfo.groupList, { id }, { toClicsGroup() }) { id, token, data -> GroupEvent(id.value, token, data) }
diffChange(orgsMap, newInfo.organizationList, { id }, { toClicsOrg() }) { id, token, data -> OrganizationEvent(id.value, token, data) }
diffChange(languagesMap, newInfo.languagesList + unknownLanguage, { id }, { toClicsLang() }) { id, token, data -> LanguageEvent(id.value, token, data) }

diff(teamsMap, newInfo.teamList, { id }, TeamInfo::toClicsTeam) { id, token, data -> TeamEvent(id.value, token, data) }

diffRemove(groupsMap, newInfo.groupList, { id }) { id, token, data -> GroupEvent(id.value, token, data) }
diffRemove(orgsMap, newInfo.organizationList, { id }) { id, token, data -> OrganizationEvent(id.value, token, data) }
diffRemove(languagesMap, newInfo.languagesList + unknownLanguage, { id }) { id, token, data -> LanguageEvent(id.value, token, data) }
}

private suspend fun FlowCollector<EventProducer>.processAnalytics(message: AnalyticsMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object PCMSExporter {
is RunResult.ICPC, is RunResult.InProgress -> "0"
is RunResult.IOI -> result.score.sum().toString()
})
//setAttribute("language-id", "")
setAttributeIfNotNull("language-id", info.languageId?.value)
setAttribute("run-id", info.id.toString())
setAttribute("outcome", convertOutcome((info.result as? RunResult.ICPC)?.verdict))
}
Expand Down
112 changes: 92 additions & 20 deletions src/cds/core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -545,17 +545,18 @@ public final class org/icpclive/cds/api/Color$Companion {

public final class org/icpclive/cds/api/ContestInfo {
public static final field Companion Lorg/icpclive/cds/api/ContestInfo$Companion;
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestResultType;Lkotlinx/datetime/Instant;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;JZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestResultType;Lkotlinx/datetime/Instant;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;JZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestResultType;Lkotlinx/datetime/Instant;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;JZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestResultType;Lkotlinx/datetime/Instant;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;JZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/lang/String;
public final fun component10 ()Lorg/icpclive/cds/api/PenaltyRoundingMode;
public final fun component11 ()D
public final fun component12 ()Lorg/icpclive/cds/api/AwardsSettings;
public final fun component13-UwyO8pc ()J
public final fun component14 ()Lorg/icpclive/cds/api/QueueSettings;
public final fun component15 ()Z
public final fun component10 ()Ljava/util/List;
public final fun component11 ()Lorg/icpclive/cds/api/PenaltyRoundingMode;
public final fun component12 ()D
public final fun component13 ()Lorg/icpclive/cds/api/AwardsSettings;
public final fun component14-UwyO8pc ()J
public final fun component15 ()Lorg/icpclive/cds/api/QueueSettings;
public final fun component16 ()Z
public final fun component2 ()Lorg/icpclive/cds/api/ContestStatus;
public final fun component3 ()Lorg/icpclive/cds/api/ContestResultType;
public final fun component4-UwyO8pc ()J
Expand All @@ -564,8 +565,8 @@ public final class org/icpclive/cds/api/ContestInfo {
public final fun component7 ()Ljava/util/List;
public final fun component8 ()Ljava/util/List;
public final fun component9 ()Ljava/util/List;
public final fun copy-rmJQ3-o (Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;Z)Lorg/icpclive/cds/api/ContestInfo;
public static synthetic fun copy-rmJQ3-o$default (Lorg/icpclive/cds/api/ContestInfo;Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;ZILjava/lang/Object;)Lorg/icpclive/cds/api/ContestInfo;
public final fun copy-YD_76-U (Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;Z)Lorg/icpclive/cds/api/ContestInfo;
public static synthetic fun copy-YD_76-U$default (Lorg/icpclive/cds/api/ContestInfo;Ljava/lang/String;Lorg/icpclive/cds/api/ContestStatus;Lorg/icpclive/cds/api/ContestResultType;JLkotlin/time/Duration;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lorg/icpclive/cds/api/PenaltyRoundingMode;DLorg/icpclive/cds/api/AwardsSettings;JLorg/icpclive/cds/api/QueueSettings;ZILjava/lang/Object;)Lorg/icpclive/cds/api/ContestInfo;
public fun equals (Ljava/lang/Object;)Z
public final fun getAwardsSettings ()Lorg/icpclive/cds/api/AwardsSettings;
public final fun getCdsSupportsFinalization ()Z
Expand All @@ -574,6 +575,8 @@ public final class org/icpclive/cds/api/ContestInfo {
public final fun getFreezeTime-FghU774 ()Lkotlin/time/Duration;
public final fun getGroupList ()Ljava/util/List;
public final fun getGroups ()Ljava/util/Map;
public final fun getLanguages ()Ljava/util/Map;
public final fun getLanguagesList ()Ljava/util/List;
public final fun getName ()Ljava/lang/String;
public final fun getOrganizationList ()Ljava/util/List;
public final fun getOrganizations ()Ljava/util/Map;
Expand Down Expand Up @@ -610,6 +613,7 @@ public final class org/icpclive/cds/api/ContestInfoKt {
public static final fun getCurrentContestTime (Lorg/icpclive/cds/api/ContestInfo;)J
public static final fun getStartTime (Lorg/icpclive/cds/api/ContestInfo;)Lkotlinx/datetime/Instant;
public static final fun getStartTimeOrZero (Lorg/icpclive/cds/api/ContestInfo;)Lkotlinx/datetime/Instant;
public static final fun languages (Ljava/util/List;)Ljava/util/List;
}

public final class org/icpclive/cds/api/ContestResultType : java/lang/Enum {
Expand Down Expand Up @@ -909,6 +913,72 @@ public final class org/icpclive/cds/api/IOIProblemResult$Companion {
public abstract interface annotation class org/icpclive/cds/api/InefficientContestInfoApi : java/lang/annotation/Annotation {
}

public final class org/icpclive/cds/api/LanguageId {
public static final field Companion Lorg/icpclive/cds/api/LanguageId$Companion;
public static final synthetic fun box-impl (Ljava/lang/String;)Lorg/icpclive/cds/api/LanguageId;
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z
public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z
public final fun getValue ()Ljava/lang/String;
public fun hashCode ()I
public static fun hashCode-impl (Ljava/lang/String;)I
public fun toString ()Ljava/lang/String;
public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String;
public final synthetic fun unbox-impl ()Ljava/lang/String;
}

public synthetic class org/icpclive/cds/api/LanguageId$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lorg/icpclive/cds/api/LanguageId$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun deserialize-hvNokaU (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/String;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public final fun serialize-MtJ6cpo (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/String;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}

public final class org/icpclive/cds/api/LanguageId$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class org/icpclive/cds/api/LanguageInfo {
public static final field Companion Lorg/icpclive/cds/api/LanguageInfo$Companion;
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-UUN7Iis ()Ljava/lang/String;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/util/List;
public final fun copy-VPaLHWc (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)Lorg/icpclive/cds/api/LanguageInfo;
public static synthetic fun copy-VPaLHWc$default (Lorg/icpclive/cds/api/LanguageInfo;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILjava/lang/Object;)Lorg/icpclive/cds/api/LanguageInfo;
public fun equals (Ljava/lang/Object;)Z
public final fun getExtensions ()Ljava/util/List;
public final fun getId-UUN7Iis ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public synthetic class org/icpclive/cds/api/LanguageInfo$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lorg/icpclive/cds/api/LanguageInfo$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lorg/icpclive/cds/api/LanguageInfo;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Lorg/icpclive/cds/api/LanguageInfo;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}

public final class org/icpclive/cds/api/LanguageInfo$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class org/icpclive/cds/api/LanguageKt {
public static final fun toLanguageId (I)Ljava/lang/String;
public static final fun toLanguageId (J)Ljava/lang/String;
public static final fun toLanguageId (Ljava/lang/String;)Ljava/lang/String;
}

public abstract class org/icpclive/cds/api/MediaType {
public static final field Companion Lorg/icpclive/cds/api/MediaType$Companion;
public synthetic fun <init> (ILkotlinx/serialization/internal/SerializationConstructorMarker;)V
Expand Down Expand Up @@ -1457,22 +1527,24 @@ public final class org/icpclive/cds/api/RunId$Companion {

public final class org/icpclive/cds/api/RunInfo {
public static final field Companion Lorg/icpclive/cds/api/RunInfo$Companion;
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;Lkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;Lkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-1iip4kg ()Ljava/lang/String;
public final fun component10 ()Z
public final fun component2 ()Lorg/icpclive/cds/api/RunResult;
public final fun component3-Xzdl60o ()Ljava/lang/String;
public final fun component4-ed2mA_4 ()Ljava/lang/String;
public final fun component5-UwyO8pc ()J
public final fun component6-FghU774 ()Lkotlin/time/Duration;
public final fun component7 ()Lorg/icpclive/cds/api/MediaType;
public final fun component8 ()Ljava/util/List;
public final fun component9 ()Z
public final fun copy-8G9nE0k (Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;Z)Lorg/icpclive/cds/api/RunInfo;
public static synthetic fun copy-8G9nE0k$default (Lorg/icpclive/cds/api/RunInfo;Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;ZILjava/lang/Object;)Lorg/icpclive/cds/api/RunInfo;
public final fun component6-GPqwlpk ()Ljava/lang/String;
public final fun component7-FghU774 ()Lkotlin/time/Duration;
public final fun component8 ()Lorg/icpclive/cds/api/MediaType;
public final fun component9 ()Ljava/util/List;
public final fun copy-9CUUfRs (Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;Lkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;Z)Lorg/icpclive/cds/api/RunInfo;
public static synthetic fun copy-9CUUfRs$default (Lorg/icpclive/cds/api/RunInfo;Ljava/lang/String;Lorg/icpclive/cds/api/RunResult;Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;Lkotlin/time/Duration;Lorg/icpclive/cds/api/MediaType;Ljava/util/List;ZILjava/lang/Object;)Lorg/icpclive/cds/api/RunInfo;
public fun equals (Ljava/lang/Object;)Z
public final fun getFeaturedRunMedia ()Lorg/icpclive/cds/api/MediaType;
public final fun getId-1iip4kg ()Ljava/lang/String;
public final fun getLanguageId-GPqwlpk ()Ljava/lang/String;
public final fun getProblemId-Xzdl60o ()Ljava/lang/String;
public final fun getReactionVideos ()Ljava/util/List;
public final fun getResult ()Lorg/icpclive/cds/api/RunResult;
Expand Down
Loading

0 comments on commit 1f0aaa0

Please sign in to comment.