diff --git a/LaDOSE.Src/LaDOSE.DTO/TournamentDTO.cs b/LaDOSE.Src/LaDOSE.DTO/TournamentDTO.cs index 072cd34..5941f3e 100644 --- a/LaDOSE.Src/LaDOSE.DTO/TournamentDTO.cs +++ b/LaDOSE.Src/LaDOSE.DTO/TournamentDTO.cs @@ -6,6 +6,7 @@ namespace LaDOSE.DTO public class TournamentDTO { public int Id { get; set; } + public int ChallongeId { get; set; } public string Name { get; set; } public string Game { get; set; } public List Participents {get;set;} @@ -14,6 +15,7 @@ namespace LaDOSE.DTO public class ParticipentDTO { public int Id { get; set; } + public int ChallongeId { get; set; } public string Name { get; set; } public int Rank { get; set; } public bool? IsMember{ get; set; } diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs index 9fa30bd..7424aed 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs @@ -206,7 +206,7 @@ namespace LaDOSE.DesktopApp.ViewModels { WpfUtil.Await(() => { - var tournamentsIds = SelectedTournaments.Select(e => e.Id).ToList(); + var tournamentsIds = SelectedTournaments.Select(e => e.ChallongeId).ToList(); var resultsDto = this.RestService.GetResults(tournamentsIds); this.Results = resultsDto; ComputeDataGrid(); diff --git a/LaDOSE.Src/LaDOSE.Entity/Challonge/ChallongeParticipent.cs b/LaDOSE.Src/LaDOSE.Entity/Challonge/ChallongeParticipent.cs new file mode 100644 index 0000000..3f78f25 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Entity/Challonge/ChallongeParticipent.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace LaDOSE.Entity.Challonge +{ + public class ChallongeParticipent : Context.Entity + + { + public ChallongeTournament ChallongeTournament { get; set; } + public int ChallongeTournamentId { get; set; } + public int ChallongeId { get; set; } + public string Name { get; set; } + public int? Rank { get; set; } + public bool? IsMember { get; set; } + + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/Challonge/ChallongeTournament.cs b/LaDOSE.Src/LaDOSE.Entity/Challonge/ChallongeTournament.cs new file mode 100644 index 0000000..ebe6c99 --- /dev/null +++ b/LaDOSE.Src/LaDOSE.Entity/Challonge/ChallongeTournament.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace LaDOSE.Entity.Challonge +{ + public class ChallongeTournament : Context.Entity + { + public int ChallongeId { get; set; } + public string Name { get; set; } + public Game Game { get; set; } + public List Participents { get; set; } + public string Url { get; set; } + + public DateTime Sync { get; set; } + } +} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/Challonge/Participent.cs b/LaDOSE.Src/LaDOSE.Entity/Challonge/Participent.cs deleted file mode 100644 index 7e0c477..0000000 --- a/LaDOSE.Src/LaDOSE.Entity/Challonge/Participent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace LaDOSE.Entity.Challonge -{ - public class Participent - { - public int Id { get; set; } - public string Name { get; set; } - public int? Rank { get; set; } - public bool? IsMember { get; set; } - } -} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/Challonge/Tournament.cs b/LaDOSE.Src/LaDOSE.Entity/Challonge/Tournament.cs deleted file mode 100644 index 33c900a..0000000 --- a/LaDOSE.Src/LaDOSE.Entity/Challonge/Tournament.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; - -namespace LaDOSE.Entity.Challonge -{ - public class Tournament - { - public int Id { get; set; } - public string Name { get; set; } - public Game Game { get; set; } - public List Participents { get; set; } - public string Url { get; set; } - } -} \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Entity/Challonge/TournamentsResult.cs b/LaDOSE.Src/LaDOSE.Entity/Challonge/TournamentsResult.cs index f18f411..c4aba7b 100644 --- a/LaDOSE.Src/LaDOSE.Entity/Challonge/TournamentsResult.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Challonge/TournamentsResult.cs @@ -5,7 +5,7 @@ namespace LaDOSE.Entity.Challonge { public class TournamentsResult { - public List Participents { get; set; } + public List Participents { get; set; } public List Games{ get; set; } public List Results { get; set; } diff --git a/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs index a97575e..158e8d4 100644 --- a/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs +++ b/LaDOSE.Src/LaDOSE.Entity/Context/LaDOSEDbContext.cs @@ -1,4 +1,5 @@ -using LaDOSE.Entity.Wordpress; +using LaDOSE.Entity.Challonge; +using LaDOSE.Entity.Wordpress; using Microsoft.EntityFrameworkCore; namespace LaDOSE.Entity.Context @@ -20,6 +21,8 @@ namespace LaDOSE.Entity.Context #endregion public DbSet SeasonGame { get; set; } public DbSet EventGame { get; set; } + public DbSet ChallongeParticipent { get; set; } + public DbSet ChallongeTournament { get; set; } public LaDOSEDbContext(DbContextOptions options) : base(options) { @@ -87,6 +90,12 @@ namespace LaDOSE.Entity.Context .HasForeignKey(pt => pt.WPUserId); #endregion + #region Challonge + modelBuilder.Entity() + .HasOne(pt => pt.ChallongeTournament) + .WithMany(p => p.Participents) + .HasForeignKey(pt => pt.ChallongeTournamentId); + #endregion } } diff --git a/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs b/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs index a864fb0..02a67a1 100644 --- a/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs +++ b/LaDOSE.Src/LaDOSE.Service/Interface/IChallongeProvider.cs @@ -13,9 +13,9 @@ namespace LaDOSE.Business.Interface Task CreateTournament(string name, string url, DateTime? startAt); Task AddPlayer(int tournamentId, string userName); - Task> GetTournaments(DateTime? start, DateTime? end); - Task> GetParticipents(int idTournament); - Task GetTournament(int idTournament); - Task GetTournament(string urlTournament); + Task> GetTournaments(DateTime? start, DateTime? end); + Task> GetParticipents(int idTournament); + Task GetTournament(int idTournament); + Task GetTournament(string urlTournament); } } \ No newline at end of file diff --git a/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs b/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs index 469ca76..0f34f9c 100644 --- a/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Interface/ITournamentService.cs @@ -7,7 +7,7 @@ namespace LaDOSE.Business.Interface { public interface ITournamentService { - Task> GetTournaments(DateTime? start, DateTime? end); + Task> GetTournaments(DateTime? start, DateTime? end); Task GetTournamentsResult(List ids); } diff --git a/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs b/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs index dd570cd..f70c76f 100644 --- a/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs +++ b/LaDOSE.Src/LaDOSE.Service/Provider/ChallongeProvider.cs @@ -46,7 +46,7 @@ namespace LaDOSE.Business.Provider } - public async Task> GetTournaments(DateTime? start, DateTime? end) + public async Task> GetTournaments(DateTime? start, DateTime? end) { List tournamentResultList = await new TournamentsQuery() @@ -58,28 +58,29 @@ namespace LaDOSE.Business.Provider } .call(this.ApiCaller); - List tournaments = new List(); - tournamentResultList.ForEach(w => tournaments.Add(new Tournament() + List tournaments = new List(); + tournamentResultList.ForEach(w => tournaments.Add(new ChallongeTournament() { - Id = w.id, + ChallongeId = w.id, Name = w.name, - Participents = new List() + Participents = new List() })); return tournaments; } - public async Task> GetParticipents(int idTournament) + public async Task> GetParticipents(int idTournament) { var participentResults = await new ParticipantsQuery(){tournamentID = idTournament }.call(ApiCaller); - List participants = new List(); + List participants = new List(); participentResults.ForEach(w => { if (w.active) { - participants.Add(new Participent() + participants.Add(new ChallongeParticipent() { - Id = w.id, + ChallongeTournamentId = idTournament, + ChallongeId = w.id, Name = w.name, Rank = w.final_rank, IsMember = false, @@ -90,32 +91,32 @@ namespace LaDOSE.Business.Provider return participants; } - public async Task GetTournament(int idTournament) + public async Task GetTournament(int idTournament) { var tournamentResult = await new TournamentQuery(idTournament).call(ApiCaller); - return new Tournament() + return new ChallongeTournament() { - Id = tournamentResult.id, + ChallongeId = tournamentResult.id, Name = tournamentResult.name, Url = tournamentResult.url, - Participents = new List() + Participents = new List() }; } - public async Task GetTournament(string urlTournament) + public async Task GetTournament(string urlTournament) { var tournamentResult = await new TournamentQuery(urlTournament).call(ApiCaller); - return new Tournament() + return new ChallongeTournament() { - Id = tournamentResult.id, + ChallongeId = tournamentResult.id, Name = tournamentResult.name, Url = tournamentResult.url, - Participents = new List() + Participents = new List() }; diff --git a/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs b/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs index c49ac4a..e9bfd3e 100644 --- a/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs +++ b/LaDOSE.Src/LaDOSE.Service/Service/TournamentService.cs @@ -3,15 +3,20 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using LaDOSE.Business.Interface; +using LaDOSE.Entity; using LaDOSE.Entity.Challonge; using LaDOSE.Entity.Context; using LaDOSE.Entity.Wordpress; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; namespace LaDOSE.Business.Service { - public class TournamentService : ITournamentService + public class TournamentService : BaseService,ITournamentService { + private IChallongeProvider _challongeProvider; + + #region Rules private class Rules { public int PlayerMin { get; set; } @@ -37,9 +42,7 @@ namespace LaDOSE.Business.Service } } - private LaDOSEDbContext _context; - private IChallongeProvider _challongeProvider; - + //Rules Definitions (Min Players,Max Players,First Reward,Second Reward,Third / Fourth Reward, Top 8 reward, Top 16 Reward private List TournamentRules = new List() { new Rules(0, 8, 5, 3, 2, 0, 0), @@ -47,59 +50,51 @@ namespace LaDOSE.Business.Service new Rules(16, 32, 12, 8, 5, 3, 2), new Rules(32, Int32.MaxValue, 18, 12, 8, 5, 3), }; + #endregion - public TournamentService(LaDOSEDbContext context, IChallongeProvider challongeProvider) + public TournamentService(LaDOSEDbContext context, IChallongeProvider challongeProvider) : base(context) { this._context = context; this._challongeProvider = challongeProvider; } - public async Task> GetTournaments(DateTime? start, DateTime? end) - { - List wpUsers = _context.WPUser.ToList(); - var tournaments = await _challongeProvider.GetTournaments(start, end); - - foreach (var tournament in tournaments) - { - List participents = await _challongeProvider.GetParticipents(tournament.Id); - tournament.Participents = participents; - } - - return tournaments; + public async Task> GetTournaments(DateTime? start, DateTime? end) + { + return await _challongeProvider.GetTournaments(start, end); + //Useless + //foreach (var tournament in tournaments) + //{ + // List participents = await _challongeProvider.GetParticipents(tournament.ChallongeId); + // tournament.Participents = participents; + //} } public async Task GetTournamentsResult(List ids) { TournamentsResult result = new TournamentsResult(); result.Results = new List(); - var tournaments = new List(); - foreach (var idTournament in ids) - { - var tournament = await _challongeProvider.GetTournament(idTournament); - tournament.Participents = await _challongeProvider.GetParticipents(tournament.Id); - tournaments.Add(tournament); - } - - var games = _context.Game.ToList(); var players = _context.WPUser.ToList(); + var games = _context.Game.ToList(); + var tournaments = await GetChallongeTournaments(ids,games); var allParticipent = tournaments.SelectMany(e => e.Participents).Distinct((a, b) => a.Name == b.Name) .ToList(); - foreach (var participent in allParticipent) - { - var player = players.FirstOrDefault(e => e.Name.Contains(participent.Name)); - if (player != null) - { - participent.IsMember = true; - } - } + + //USELESS + //foreach (var participent in allParticipent) + //{ + // var player = players.FirstOrDefault(e => e.Name.Contains(participent.Name)); + // if (player != null) + // { + // participent.IsMember = true; + // } + //} result.Participents = allParticipent; foreach (var tournament in tournaments) { - var game = games.First(g => tournament.Name.Contains(g.Name)); - tournament.Game = game; + var playerCount = tournament.Participents.Count; var lesSacs = tournament.Participents; @@ -117,18 +112,18 @@ namespace LaDOSE.Business.Service var Top8 = tournament.Participents.Where(p => p.Rank > 4 && p.Rank < 9).ToList(); var Top16 = tournament.Participents.Where(p => p.Rank > 8 && p.Rank <= 16).ToList(); - result.Results.Add(new Result(first.Name, tournament.Game.Id, tournament.Id, tournament.Url, currentRule.FirstPoint)); + result.Results.Add(new Result(first.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.FirstPoint)); lesSacs.Remove(first); - result.Results.Add(new Result(second.Name, tournament.Game.Id, tournament.Id, tournament.Url, currentRule.SecondPoint)); + result.Results.Add(new Result(second.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.SecondPoint)); lesSacs.Remove(second); thirdFourth.ForEach(r => - result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.Id, tournament.Url, + result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.ThirdFourthPoint))); thirdFourth.ForEach(p => lesSacs.Remove(p)); if (currentRule.Top8Point != 0) { Top8.ForEach(r => - result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.Id, tournament.Url, currentRule.Top8Point))); + result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.Top8Point))); Top8.ForEach(p => lesSacs.Remove(p)); } @@ -136,12 +131,12 @@ namespace LaDOSE.Business.Service { Top16.ForEach(r => result.Results.Add( - new Result(r.Name, tournament.Game.Id, tournament.Id, tournament.Url, currentRule.Top16Point))); + new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.Top16Point))); Top16.ForEach(p => lesSacs.Remove(p)); } lesSacs.ForEach(r => - result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.Id, tournament.Url, + result.Results.Add(new Result(r.Name, tournament.Game.Id, tournament.ChallongeId, tournament.Url, currentRule.Participation))); } @@ -149,5 +144,43 @@ namespace LaDOSE.Business.Service return result; } + /// + /// Check if the tournament exist in database otherwise call Challonge. + /// + /// tournaments ids + /// List of the challonge's tournament with participents + private async Task> GetChallongeTournaments(List ids, List games) + { + var tournaments = new List(); + foreach (var idTournament in ids) + { + if (!TournamentExist(idTournament)) + { + ChallongeTournament challongeTournament = await _challongeProvider.GetTournament(idTournament); + challongeTournament.Participents = + await _challongeProvider.GetParticipents(challongeTournament.ChallongeId); + + var game = games.FirstOrDefault(g => challongeTournament.Name.Contains(g.Name)); + if (game != null) challongeTournament.Game = game; + challongeTournament.Sync = DateTime.Now; + + tournaments.Add(challongeTournament); + _context.ChallongeTournament.Add(challongeTournament); + _context.SaveChanges(); + } + else + { + tournaments.Add(_context.ChallongeTournament.Where(e => e.ChallongeId == idTournament) + .Include(e => e.Participents).First()); + } + } + + return tournaments; + } + + private bool TournamentExist(int idTournament) + { + return this._context.ChallongeTournament.Any(e => e.ChallongeId == idTournament); + } } } \ No newline at end of file diff --git a/Sql/Dump20190806.sql b/Sql/Dump20190806.sql new file mode 100644 index 0000000..26eab6f --- /dev/null +++ b/Sql/Dump20190806.sql @@ -0,0 +1,190 @@ +-- -------------------------------------------------------- +-- Hôte : api.ladose.net +-- Version du serveur: 5.7.25-log - Gentoo Linux mysql-5.7.25 +-- SE du serveur: Linux +-- HeidiSQL Version: 10.2.0.5599 +-- -------------------------------------------------------- + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8mb4 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; + + +-- Listage de la structure de la base pour ladoseapi +CREATE DATABASE IF NOT EXISTS `ladoseapi` /*!40100 DEFAULT CHARACTER SET utf8 */; +USE `ladoseapi`; + +-- Listage de la structure de la table ladoseapi. ApplicationUser +CREATE TABLE IF NOT EXISTS `ApplicationUser` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `FirstName` varchar(45) DEFAULT NULL, + `LastName` varchar(45) DEFAULT NULL, + `UserName` varchar(45) DEFAULT NULL, + `PasswordHash` blob, + `PasswordSalt` blob, + PRIMARY KEY (`Id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. ChallongeParticipent +CREATE TABLE IF NOT EXISTS `ChallongeParticipent` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `ChallongeId` int(11) NOT NULL DEFAULT '0', + `ChallongeTournamentId` int(11) NOT NULL DEFAULT '0', + `Name` varchar(500) NOT NULL DEFAULT '0', + `Rank` int(11) DEFAULT '0', + `IsMember` bit(1) DEFAULT NULL, + PRIMARY KEY (`Id`) +) ENGINE=InnoDB AUTO_INCREMENT=687 DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. ChallongeTournament +CREATE TABLE IF NOT EXISTS `ChallongeTournament` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `ChallongeId` int(11) NOT NULL DEFAULT '0', + `Name` varchar(500) DEFAULT NULL, + `GameId` int(11) DEFAULT NULL, + `Url` varchar(255) DEFAULT NULL, + `Sync` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`Id`), + KEY `ChallongeTournament_GameIdPK` (`GameId`), + CONSTRAINT `ChallongeTournament_GameIdPK` FOREIGN KEY (`GameId`) REFERENCES `Game` (`Id`) +) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. Event +CREATE TABLE IF NOT EXISTS `Event` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `Name` varchar(255) NOT NULL, + `Date` datetime NOT NULL, + `SeasonId` int(11) NOT NULL, + `Ranking` tinyint(4) DEFAULT NULL, + PRIMARY KEY (`Id`), + KEY `SeasonPK_idx` (`SeasonId`), + CONSTRAINT `SeasonsPK` FOREIGN KEY (`SeasonId`) REFERENCES `Season` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. EventGame +CREATE TABLE IF NOT EXISTS `EventGame` ( + `EventId` int(11) NOT NULL, + `GameId` int(11) NOT NULL, + `ChallongeId` int(11) DEFAULT NULL, + `ChallongeUrl` varchar(250) DEFAULT NULL, + PRIMARY KEY (`EventId`,`GameId`), + KEY `GamePK_idx` (`GameId`), + CONSTRAINT `EventGame_EventPK` FOREIGN KEY (`EventId`) REFERENCES `Event` (`Id`), + CONSTRAINT `EventGame_GamePk` FOREIGN KEY (`GameId`) REFERENCES `Game` (`Id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. Game +CREATE TABLE IF NOT EXISTS `Game` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `Name` varchar(45) CHARACTER SET utf8 DEFAULT NULL, + `ImgUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL, + `WordPressTag` varchar(255) DEFAULT NULL, + `WordPressTagOs` varchar(255) DEFAULT NULL, + `Order` int(11) NOT NULL DEFAULT '0', + `LongName` varchar(255) DEFAULT NULL, + PRIMARY KEY (`Id`), + UNIQUE KEY `name_UNIQUE` (`Name`) +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la procédure ladoseapi. ImportEvent +DELIMITER // +CREATE DEFINER=`ladoseapi`@`%` PROCEDURE `ImportEvent`() +BEGIN + INSERT INTO WPEvent (Id, Name,Slug,Date ) + select event_id, event_name,event_slug, event_start_date from ladose.wp_em_events + where event_id not in (select Id from WPEvent); + + INSERT INTO WPUser (Id, Name, WPUSerLogin, WPMail) + select ID, display_name, user_login , user_email from ladose.wp_users + where ID not in (select Id from WPUser); + + INSERT INTO WPBooking (WPEventId, WPUserId, Message, Meta) + select event_id, person_id, booking_comment , booking_meta from ladose.wp_em_bookings + where (event_id , person_id) not in (select WPEventId,WPUserId from WPBooking); +END// +DELIMITER ; + +-- Listage de la structure de la table ladoseapi. Season +CREATE TABLE IF NOT EXISTS `Season` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `Name` varchar(45) DEFAULT NULL, + `StartDate` datetime DEFAULT NULL, + `EndDate` datetime DEFAULT NULL, + PRIMARY KEY (`Id`), + UNIQUE KEY `Name_UNIQUE` (`Name`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. SeasonGame +CREATE TABLE IF NOT EXISTS `SeasonGame` ( + `SeasonId` int(11) NOT NULL, + `GameId` int(11) NOT NULL, + PRIMARY KEY (`SeasonId`,`GameId`), + KEY `GamePK_idx` (`GameId`), + CONSTRAINT `GamePK` FOREIGN KEY (`GameId`) REFERENCES `Game` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `SeasonPK` FOREIGN KEY (`SeasonId`) REFERENCES `Season` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. Todo +CREATE TABLE IF NOT EXISTS `Todo` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `User` varchar(45) NOT NULL, + `Task` mediumtext, + `Done` tinyint(4) NOT NULL DEFAULT '0', + `Created` datetime NOT NULL, + `Deleted` datetime DEFAULT NULL, + PRIMARY KEY (`Id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. WPBooking +CREATE TABLE IF NOT EXISTS `WPBooking` ( + `WPEventId` int(11) DEFAULT NULL, + `WPUserId` int(11) DEFAULT NULL, + `Message` varchar(5000) DEFAULT NULL, + `Meta` varchar(5000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. WPEvent +CREATE TABLE IF NOT EXISTS `WPEvent` ( + `Id` int(11) NOT NULL, + `Name` varchar(255) DEFAULT NULL, + `Slug` varchar(255) DEFAULT NULL, + `Date` date DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +-- Listage de la structure de la table ladoseapi. WPUser +CREATE TABLE IF NOT EXISTS `WPUser` ( + `Id` int(11) NOT NULL, + `Name` varchar(45) DEFAULT NULL, + `WPUserLogin` varchar(45) DEFAULT NULL, + `WPMail` varchar(45) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Les données exportées n'étaient pas sélectionnées. + +/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; +/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;