Ranking reforge. SplitRanking is not implemented yet !!!

This commit is contained in:
2025-06-30 19:02:19 +02:00
parent 81bf37639b
commit 11e695f379
13 changed files with 218 additions and 104 deletions

View File

@ -6,37 +6,6 @@
#include "Types/Objects/DTFluxContestStorage.h"
// const FDateTime UDTFluxModelAsset::GetMassStart(const int& ContestId, const int& StageId)
// {
// }
// void UDTFluxModelAsset::InsertOrUpdateRaceData(const TSharedPtr<FJsonObject>& Response)
// {
//
// }
//
// void UDTFluxModelAsset::InsertOrUpdateContestRanking(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::InsertOrUpdateStageRanking(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::InsertOrUpdateSplitRanking(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::InsertOrUpdateTeamList(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::SplitSensorTriggered(const TSharedPtr<FJsonObject>& Response)
// {
// }
UDTFluxModelAsset::UDTFluxModelAsset(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
}
@ -93,3 +62,47 @@ bool UDTFluxModelAsset::PersonExists(const FDTFluxPerson& InPerson) const
return Person == InPerson;
});
}
FString UDTFluxModelAsset::GetContestNameForId(const int InContestID)
{
FDTFluxContest Contest;
if(!GetContestById(InContestID, Contest))
{
UE_LOG(logDTFluxCore, Warning, TEXT("GetContestNameForId(%i) [unable to find a contest] result will be empty !!!"),
InContestID);
}
return Contest.Name;
}
void UDTFluxModelAsset::AddContestRanking(const FDTFluxContestRankings& NewContestRankings)
{
ContestRankings.Add(NewContestRankings.ContestId, NewContestRankings);
}
bool UDTFluxModelAsset::UpdateStageRanking(const FDTFluxStageRankings& InStageRankings)
{
const int ContestId = InStageRankings.ContestId;
const int StageId = InStageRankings.StageId;
int Index = 0;
int StageRankingArraySize = StageRankings.Num()-1;
for(auto Ranking : StageRankings)
{
if(Ranking.ContestId == ContestId && Ranking.StageId == StageId)
{
Index++;
break;
}
Index++;
}
if(Index != StageRankingArraySize )
{
StageRankings[Index] = InStageRankings;
return true;
}
return false;
}
bool UDTFluxModelAsset::UpdateSplitRanking(const FDTFluxStageRankings& InStageRankings)
{
return true;
}

View File

@ -99,17 +99,17 @@ void UDTFluxContestStorage::AddSplit(const int InContest, const FDTFluxSplit& In
#pragma region SplitRankingRegion
void UDTFluxContestStorage::AddSplitRanking(const int InContest, const FDTFluxSplitRanking& InSplitRanking)
void UDTFluxContestStorage::AddSplitRanking(const int InContest, const FDTFluxStageRanking& InSplitRanking)
{
}
void UDTFluxContestStorage::GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId,
const int InStageId, const FDTFluxSplitRanking& OutSplitRankingForBib)
const int InStageId, const FDTFluxStageRanking& OutSplitRankingForBib)
{
}
void UDTFluxContestStorage::GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId,
const FDTFluxSplitRanking& OutSplitRankingForBib)
const FDTFluxStageRanking& OutSplitRankingForBib)
{
}

View File

@ -20,10 +20,10 @@ void FDTFluxStageRanking::Dump() const
void FDTFluxSplitRanking::Dump() const
{
UE_LOG(logDTFluxCore, Log, TEXT("SplitGapItem"))
// Participant.Dump();
UE_LOG(logDTFluxCore, Log, TEXT("Bib %02d Rank %02d Gap %s Time %s"), Bib, Rank, *Gap, *Time);
}
// void FDTFluxSplitRanking::Dump() const
// {
// UE_LOG(logDTFluxCore, Log, TEXT("SplitGapItem"))
// // Participant.Dump();
// UE_LOG(logDTFluxCore, Log, TEXT("Bib %02d Rank %02d Gap %s Time %s"), Bib, Rank, *Gap, *Time);
// }

View File

@ -34,10 +34,13 @@ public:
TMap<FString /* ContestName */, FDTFluxContest> Contests;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TArray<FDTFluxContestRanking> ContestRankings;
TMap<int /*ContestId*/, FDTFluxContestRankings> ContestRankings;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TMap<FString /*ContestName*/ ,FDTFluxStageRanking> StageRankings;
TArray<FDTFluxStageRankings> StageRankings;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TArray<FDTFluxStageRankings> SplitRankings;
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|ModelAsset")
void AddContest(const FDTFluxContest &Contest);
@ -51,6 +54,18 @@ public:
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Participant")
void AddParticipant(const FDTFluxParticipant& InParticipant, const int ContestId);
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Person")
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Person|Utils")
bool PersonExists(const FDTFluxPerson& InPerson) const;
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
FString GetContestNameForId(const int InContestID);
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
bool UpdateStageRanking(const FDTFluxStageRankings& InStageRankings);
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
bool UpdateSplitRanking(const FDTFluxStageRankings& InStageRankings);
UFUNCTION()
void AddContestRanking(const FDTFluxContestRankings& NewContestRankings);
};

View File

@ -88,13 +88,13 @@ public:
void AddSplit(const int InContest, const FDTFluxSplit& InSplit);
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
void AddSplitRanking(const int InContest, const FDTFluxSplitRanking& InSplitRanking);
void AddSplitRanking(const int InContest, const FDTFluxStageRanking& InSplitRanking);
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
void GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId, const int InStageId, const FDTFluxSplitRanking& OutSplitRankingForBib);
void GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId, const int InStageId, const FDTFluxStageRanking& OutSplitRankingForBib);
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
void GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId, const FDTFluxSplitRanking& OutSplitRankingForBib);
void GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId, const FDTFluxStageRanking& OutSplitRankingForBib);
#pragma endregion
#pragma region ParticipantSection

View File

@ -23,7 +23,7 @@ public:
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
int Bib = -1;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
FDTFluxSplitRanking SplitRanking;
FDTFluxStageRanking SplitRanking;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
FDTFluxStageRanking StageRanking;
};

View File

@ -23,7 +23,7 @@ public:
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
FString Name;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
TArray<FDTFluxSplitRanking> SplitRankings;
TArray<FDTFluxStageRanking> SplitRankings;
// void Dump() const;
// // void InsertOrReplace(const FDTFluxStageRankingResponseItem& SplitRankingItemResp);
// void SortByRank();

View File

@ -16,25 +16,43 @@ struct DTFLUXCORE_API FDTFluxContestRanking
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
int Bib;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
int Rank;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString Gap;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString Time;
UPROPERTY();
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere);
FString SpeedSwimAverage;
UPROPERTY();
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere);
FString SpeedRunningAverage;
UPROPERTY();
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere);
FString SpeedTotalAverage;
void Dump () const;
};
USTRUCT(BlueprintType)
struct FDTFluxContestRankings
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
TArray<FDTFluxContestRanking> Rankings;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int ContestId;
//TODO check if necessary ???
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
FString ContestName;
void SetName(const FString Name)
{
ContestName = Name;
}
};
/**
* @struct FDTFluxStageRanking
* Representing a stage ranking for a participant
@ -44,59 +62,48 @@ struct DTFLUXCORE_API FDTFluxStageRanking
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
int Bib;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
int Rank;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString Gap;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString Time;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString TimeSwim;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString TimeTransition;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString TimeRun;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FString TimeStart;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
FDateTime StartTime;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
float SpeedRunning;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
float SpeedTotal;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
float SpeedSwim;
void Dump() const;
};
/**
* @struct FDTFluxSplitRanking
* Representing a ranking of a participant in a split
*/
USTRUCT(BlueprintType, Category="DTFlux|Model")
struct DTFLUXCORE_API FDTFluxSplitRanking
USTRUCT(BlueprintType)
struct FDTFluxStageRankings
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
int Bib;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
int ContestId = 0;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
int StageId = 0;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
int SplitId = 0;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
FString Gap;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
FString Time;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
int Rank = 0;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
bool Display = false;
void Dump() const;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
TArray<FDTFluxStageRanking> Rankings;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int ContestId;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int StageId;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int SplitId;
};
};