Update Function to ensure ref is returned instead of copy for GetContest GetContestForTime
This commit is contained in:
@ -338,7 +338,8 @@ void SDTFluxStatusWidget::PopulateComboBoxItems()
|
||||
{
|
||||
FString Separator = " | ";
|
||||
FString RootSeparator = " -> ";
|
||||
TArray<FDTFluxContest> DataFromSubsystem = DTFluxCore->GetContests();
|
||||
TArray<FDTFluxContest> DataFromSubsystem = TArray<FDTFluxContest>();
|
||||
DTFluxCore->GetContests(DataFromSubsystem);
|
||||
|
||||
for (const auto& Contest : DataFromSubsystem)
|
||||
{
|
||||
|
||||
@ -554,24 +554,30 @@ TArray<int> UDTFluxCoreSubsystem::GetCurrentContestsId()
|
||||
return GetContestsIdForTime(FDateTime::Now());
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetCurrentContests()
|
||||
bool UDTFluxCoreSubsystem::GetCurrentContests(TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
return GetContestsForTime(FDateTime::Now());
|
||||
return GetContestsForTime(FDateTime::Now(), OutContests);
|
||||
}
|
||||
|
||||
TArray<int> UDTFluxCoreSubsystem::GetContestsIdForTime(const FDateTime Time) const
|
||||
TArray<int> UDTFluxCoreSubsystem::GetContestsIdForTime(const FDateTime Time)
|
||||
{
|
||||
TArray<int> Contests;
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
if (DataStorage)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
TArray<FDTFluxContest> Contests;
|
||||
if (GetContestsForTime(Time, Contests))
|
||||
{
|
||||
Contests.Add(ContestId);
|
||||
TArray<int> ContestIds = TArray<int>();
|
||||
for (const auto& Contest : Contests)
|
||||
{
|
||||
ContestIds.Add(Contest.ContestId);
|
||||
}
|
||||
return ContestIds;
|
||||
}
|
||||
return Contests;
|
||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No Contest running for Time [%s]"), *Time.ToString());
|
||||
return TArray<int>();
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return TArray<int>();
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::GetContestForId(const int Id, FDTFluxContest& OutContest)
|
||||
@ -588,34 +594,46 @@ bool UDTFluxCoreSubsystem::GetContestForId(const int Id, FDTFluxContest& OutCont
|
||||
return false;
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContestsForTime(const FDateTime Time)
|
||||
bool UDTFluxCoreSubsystem::GetContestsForTime(const FDateTime Time, TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
TArray<FDTFluxContest> Contests;
|
||||
if (DataStorage)
|
||||
{
|
||||
OutContests.Empty();
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
|
||||
//ils ont commencé.
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
{
|
||||
Contests.Add(Contest);
|
||||
// ils sont finis
|
||||
if (!Contest.IsFinished())
|
||||
{
|
||||
OutContests.Add(Contest);
|
||||
}
|
||||
}
|
||||
return Contests;
|
||||
}
|
||||
if (!OutContests.IsEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No Contest running for Time [%s]"), *Time.ToString());
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystem::RequestRankingsForStages(TArray<FDTFluxStage> RequestedStages) const
|
||||
{
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContests()
|
||||
bool UDTFluxCoreSubsystem::GetContests(TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
OutContests.Empty();
|
||||
if (DataStorage)
|
||||
{
|
||||
TArray<FDTFluxContest> OutContests;
|
||||
DataStorage->Contests.GenerateValueArray(OutContests);
|
||||
return OutContests;
|
||||
return !OutContests.IsEmpty();
|
||||
}
|
||||
return TArray<FDTFluxContest>();
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystem::GetContest(const int ContestId, FDTFluxContest& OutContest)
|
||||
|
||||
@ -107,20 +107,18 @@ public:
|
||||
TArray<FGuid> TrackedRequestSplitRankings(const TArray<FDTFluxSplitKey> ForSplits, bool bEnableCache = true);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
bool GetParticipant(int InBib, FDTFluxParticipant& OutParticipant);
|
||||
UFUNCTION()
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
TArray<int> GetCurrentContestsId();
|
||||
UFUNCTION()
|
||||
TArray<FDTFluxContest> GetCurrentContests();
|
||||
UFUNCTION()
|
||||
TArray<int> GetContestsIdForTime(const FDateTime Time) const;
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
bool GetCurrentContests(TArray<FDTFluxContest>& OutContests);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
TArray<int> GetContestsIdForTime(const FDateTime Time);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
bool GetContestForId(const int Id, FDTFluxContest& OutContest);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
||||
UFUNCTION()
|
||||
void RequestRankingsForStages(const TArray<FDTFluxStage> RequestedStages) const;
|
||||
UFUNCTION()
|
||||
TArray<FDTFluxContest> GetContests();
|
||||
bool GetContestsForTime(const FDateTime Time, TArray<FDTFluxContest>& OutContests);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
bool GetContests(TArray<FDTFluxContest>& OutContests);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void GetContest(const int ContestId, FDTFluxContest& OutContest);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
|
||||
Reference in New Issue
Block a user