Smash test
test debug Result Disctinct by selector Refactoring Smash/Challonge Test Resultat Html for Kiouze
This commit is contained in:
@@ -10,7 +10,7 @@ using ChallongeCSharpDriver.Core.Results;
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Entity.Challonge;
|
||||
|
||||
namespace LaDOSE.Business.Provider
|
||||
namespace LaDOSE.Business.Provider.ChallongProvider
|
||||
{
|
||||
public class ChallongeProvider : IChallongeProvider
|
||||
{
|
||||
@@ -30,9 +30,9 @@ namespace LaDOSE.Business.Provider
|
||||
DernierTournois = "Aucun tournois.";
|
||||
}
|
||||
|
||||
public async Task<TournamentResult> CreateTournament(string name, string url,DateTime? startAt = null)
|
||||
public async Task<TournamentResult> CreateTournament(string name, string url, DateTime? startAt = null)
|
||||
{
|
||||
var result = await new CreateTournamentQuery(name, startAt , TournamentType.Double_Elimination, url).call(ApiCaller);
|
||||
var result = await new CreateTournamentQuery(name, startAt, TournamentType.Double_Elimination, url).call(ApiCaller);
|
||||
return result;
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ namespace LaDOSE.Business.Provider
|
||||
{
|
||||
|
||||
List<TournamentResult> tournamentResultList = await new TournamentsQuery()
|
||||
{
|
||||
state = TournamentState.Ended,
|
||||
createdAfter = start,
|
||||
createdBefore = DateTime.Now,
|
||||
{
|
||||
state = TournamentState.Ended,
|
||||
createdAfter = start,
|
||||
createdBefore = DateTime.Now,
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
.call(this.ApiCaller);
|
||||
List<ChallongeTournament> tournaments = new List<ChallongeTournament>();
|
||||
tournamentResultList.ForEach(w => tournaments.Add(new ChallongeTournament()
|
||||
@@ -70,7 +70,7 @@ namespace LaDOSE.Business.Provider
|
||||
|
||||
public async Task<List<ChallongeParticipent>> GetParticipents(int idTournament)
|
||||
{
|
||||
var participentResults = await new ParticipantsQuery(){tournamentID = idTournament }.call(ApiCaller);
|
||||
var participentResults = await new ParticipantsQuery() { tournamentID = idTournament }.call(ApiCaller);
|
||||
|
||||
List<ChallongeParticipent> participants = new List<ChallongeParticipent>();
|
||||
participentResults.ForEach(w =>
|
||||
@@ -86,7 +86,7 @@ namespace LaDOSE.Business.Provider
|
||||
IsMember = false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
return participants;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace LaDOSE.Business.Provider
|
||||
Name = tournamentResult.name,
|
||||
Url = tournamentResult.url,
|
||||
Participents = new List<ChallongeParticipent>()
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -136,7 +136,7 @@ namespace LaDOSE.Business.Provider
|
||||
|
||||
|
||||
var lastDate = tournamentResultList.Max(e => e.completed_at);
|
||||
|
||||
|
||||
if (lastDate.HasValue)
|
||||
{
|
||||
var lastRankingDate = new DateTime(lastDate.Value.Year, lastDate.Value.Month, lastDate.Value.Day);
|
||||
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using GraphQL;
|
||||
using GraphQL.Client.Http;
|
||||
using GraphQL.Client.Serializer.Newtonsoft;
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Entity.Challonge;
|
||||
|
||||
namespace LaDOSE.Business.Provider.SmashProvider
|
||||
{
|
||||
public class SmashProvider : ISmashProvider
|
||||
{
|
||||
public string ApiKey { get; set; }
|
||||
public SmashProvider(string apiKey)
|
||||
{
|
||||
this.ApiKey = apiKey;
|
||||
}
|
||||
|
||||
public Task<List<ChallongeTournament>> GetTournaments(DateTime? start, DateTime? end)
|
||||
{
|
||||
var list = new List<ChallongeTournament>();
|
||||
var personAndFilmsRequest = new GraphQLRequest
|
||||
{
|
||||
Query = @"
|
||||
query TournamentsByOwner($perPage: Int!, $ownerId: ID!) {
|
||||
tournaments(query: {
|
||||
perPage: $perPage
|
||||
filter: {
|
||||
ownerId: $ownerId
|
||||
}
|
||||
}) {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
slug
|
||||
}
|
||||
}
|
||||
}",
|
||||
|
||||
OperationName = "PersonAndFilms",
|
||||
Variables = new
|
||||
{
|
||||
|
||||
ownerId = "161429",
|
||||
perPage = "4"
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return Task.FromResult(list);
|
||||
}
|
||||
|
||||
public async Task<ResponseType> GetTournament(string slug)
|
||||
{
|
||||
var graphQLClient = new GraphQLHttpClient("https://api.smash.gg/gql/alpha", new NewtonsoftJsonSerializer());
|
||||
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
var Event = new GraphQLRequest
|
||||
{
|
||||
Query = @"query TournamentQuery($slug: String) {
|
||||
tournament(slug: $slug){
|
||||
id
|
||||
name
|
||||
events {
|
||||
id
|
||||
name,
|
||||
state,
|
||||
videogame {
|
||||
id,
|
||||
name,
|
||||
displayName
|
||||
}
|
||||
standings(query: {page:0,perPage:500}){
|
||||
nodes{
|
||||
id,
|
||||
player{
|
||||
id,
|
||||
gamerTag,
|
||||
user {
|
||||
id,
|
||||
name,
|
||||
player {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
placement
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}",
|
||||
OperationName = "TournamentQuery",
|
||||
Variables = new
|
||||
{
|
||||
slug = slug,
|
||||
}
|
||||
};
|
||||
|
||||
//GraphQLHttpRequest preprocessedRequest = await graphQLClient.Options.PreprocessRequest(Event, graphQLClient);
|
||||
//var x = preprocessedRequest.ToHttpRequestMessage(graphQLClient.Options, new NewtonsoftJsonSerializer());
|
||||
//System.Diagnostics.Trace.WriteLine(x.Content.ReadAsStringAsync().Result);
|
||||
//var sendAsync = await graphQLClient.HttpClient.SendAsync(x);
|
||||
//System.Diagnostics.Trace.WriteLine(sendAsync.Content.ReadAsStringAsync().Result);
|
||||
|
||||
var graphQLResponse = await graphQLClient.SendQueryAsync<ResponseType>(Event);
|
||||
if (graphQLResponse.Errors != null)
|
||||
{
|
||||
//Event not done ?
|
||||
//throw new Exception("Error");
|
||||
}
|
||||
System.Diagnostics.Trace.Write(graphQLResponse.Data.Tournament.Name);
|
||||
|
||||
return graphQLResponse.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LaDOSE.Business.Provider.SmashProvider
|
||||
{
|
||||
public class ResponseType
|
||||
{
|
||||
public TournamentType Tournament { get; set; }
|
||||
public class TournamentType
|
||||
{
|
||||
public int id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<Event> Events { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class Event
|
||||
{
|
||||
public int id { get; set; }
|
||||
|
||||
public string name { get; set; }
|
||||
public string state { get; set; }
|
||||
|
||||
public VideoGame videogame { get; set; }
|
||||
public Node<Standing> standings { get; set; }
|
||||
}
|
||||
|
||||
public class VideoGame
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class Node<T>
|
||||
{
|
||||
public List<T> nodes { get; set; }
|
||||
|
||||
}
|
||||
public class Standing
|
||||
{
|
||||
public int id { get; set; }
|
||||
|
||||
public int placement { get; set; }
|
||||
|
||||
public Player player { get; set; }
|
||||
}
|
||||
public class Player
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string gamerTag { get; set; }
|
||||
public User user { get; set; }
|
||||
}
|
||||
public class User
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user