Exemplo n.º 1
0
        public async Task <ActionResult <TimelineResponse> > GetTimeline(TimelineRequest request)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            TimelineResponse response;

            if (request.Filter == null || request.Filter.isDefault)
            {
                string hash = request.GenHash();
                if (!memoryCache.TryGetValue(hash, out response))
                {
                    response = StatsService.GetTimeline(request, await GetCmdrStats(request.Player));
                    memoryCache.Set(hash, response, CacheService.RankingCacheOptions);
                }
                else
                {
                    logger.LogInformation("timeline from cache");
                }
            }
            else
            {
                response = await StatsService.GetCustomTimeline(context, request);
            }

            await SetLeaverQuit(request, response);

            sw.Stop();
            logger.LogInformation($"Get Timeline in {sw.ElapsedMilliseconds} ms");

            return(response);
        }
Exemplo n.º 2
0
        public async Task <DsResponse> LoadData(DsRequest request)
        {
            DsResponse response;

            if (request.Filter == null || request.Filter.isDefault)
            {
                response = request.Mode switch
                {
                    "Winrate" => StatsService.GetWinrate(request, await GetStats(request.Player)),
                    "Timeline" => StatsService.GetTimeline(new TimelineRequest(request.Mode, request.Timespan, request.Player, request.Interest, request.Versus)
                                                           , await GetStats(request.Player)),
                    "MVP" => request.Player ? await StatsService.GetCustomMvp(request, context) : StatsService.GetMvp(request, await GetStats(request.Player)),
                    "DPS" => StatsService.GetDps(request, await GetStats(request.Player)),
                    "Synergy" => await StatsService.GetSynergy(context, request),
                    "AntiSynergy" => await StatsService.GetAntiSynergy(context, request),
                    "Duration" => await StatsService.GetDuration(context, request),
                    "Standard" => await StatsService.GetStandardTeamWinrate(request, context),
                    _ => StatsService.GetWinrate(request, await GetStats(request.Player))
                };
            }
            else
            {
                response = request.Mode switch
                {
                    "Winrate" => await StatsService.GetCustomWinrate(request, context),
                    "Timeline" => await StatsService.GetCustomTimeline(context, new TimelineRequest(request.Mode, request.Timespan, request.Player, request.Interest, request.Versus)),
                    "MVP" => await StatsService.GetCustomMvp(request, context),
                    "DPS" => await StatsService.GetCustomDps(request, context),
                    "Synergy" => await StatsService.GetSynergy(context, request),
                    "AntiSynergy" => await StatsService.GetAntiSynergy(context, request),
                    "Duration" => await StatsService.GetDuration(context, request),
                    "Standard" => await StatsService.GetStandardTeamWinrate(request, context),
                    _ => await StatsService.GetCustomWinrate(request, context),
                };
            }
            response.CountResponse = await GetCountResponse(request);

            return(response);
        }