Exemplo n.º 1
0
    private async Task CacheAllRecordsOnMapAsync(DetailedMapOverviewModel map)
    {
        var fullOverview = await _tempusDataService.GetFullMapOverViewAsync(map.Name).ConfigureAwait(false);

        await CacheClassRecordAsync(3, map, fullOverview).ConfigureAwait(false);
        await CacheClassRecordAsync(4, map, fullOverview).ConfigureAwait(false);
    }
Exemplo n.º 2
0
 public static Embed GetMapInfoEmbed(DetailedMapOverviewModel map)
 {
     try
     {
         var builder = new EmbedBuilder();
         builder.WithTitle(map.Name);
         var tierText = $"Solly : T{map.TierInfo.Soldier}";
         if (!string.IsNullOrWhiteSpace(map.Videos.Soldier))
         {
             tierText += $" [Showcase]({TempusHelper.GetYoutubeUrl(map.Videos.Soldier)})";
         }
         tierText += $" | Demo : T{map.TierInfo.Demoman} ";
         if (!string.IsNullOrWhiteSpace(map.Videos.Demoman))
         {
             tierText += $"[Showcase]({TempusHelper.GetYoutubeUrl(map.Videos.Demoman)})";
         }
         builder.WithDescription(tierText + Environment.NewLine +
                                 DiscordHelper.FormatUrlMarkdown("Tempus.xyz",
                                                                 TempusHelper.GetMapUrl(map.Name)));
         return(builder.Build());
     }
     catch (Exception e)
     {
         return(Logger.LogException(e));
     }
 }
Exemplo n.º 3
0
    private async Task CacheClassRecordAsync(int classId, DetailedMapOverviewModel map, MapFullOverviewModel fullOverview)
    {
        try
        {
            // Map record
            var duration = fullOverview.GetClassRuns(classId).OrderByDuration().First().Duration;
            await CacheRecordAsync(map.Id, classId, duration, "map", 1).ConfigureAwait(false);

            // Course record
            for (var courseId = 1; courseId <= map.ZoneCounts.Course; courseId++)
            {
                try
                {
                    var runs = (await _tempusDataService.GetTopZonedTimes(map.Name, "course", courseId)
                                .ConfigureAwait(false)).Runs;
                    duration = runs.GetClassRuns(classId).OrderByDuration().First().Duration;
                    await CacheRecordAsync(map.Id, classId, duration, "course", courseId).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    _log.Error(e, "Unhandled exception while caching course records");
                }
            }

            // Bonus record
            for (int bonusId = 1; bonusId <= map.ZoneCounts.Bonus; bonusId++)
            {
                try
                {
                    var runs = (await _tempusDataService.GetTopZonedTimes(map.Name, "bonus", bonusId)
                                .ConfigureAwait(false)).Runs;
                    duration = runs.GetClassRuns(classId).OrderByDuration().First().Duration;
                    await CacheRecordAsync(map.Id, classId, duration, "bonus", bonusId).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    _log.Error(e, "Unhandled exception while caching bonus records");
                }
            }
        }
        catch (Exception e)
        {
            _log.Error(e, "Unhandled exception while caching class records");
        }
    }