feat: Ajout de la classe SeedDataLocal pour peupler les entités Artiste, Style, Titre et Commentaire avec des données fictives #39 #37 #36
This commit is contained in:
@@ -1,5 +1,145 @@
|
|||||||
namespace Webzine.EntitiesContext;
|
namespace Webzine.Entity.Fixtures;
|
||||||
|
|
||||||
|
using Webzine.Entity;
|
||||||
|
using Faker;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public class SeedDataLocal
|
public class SeedDataLocal
|
||||||
{
|
{
|
||||||
|
public Dictionary<string, (string TrackUrl, string ImageUrl)> RealMusicData { get; set; }
|
||||||
|
= new Dictionary<string, (string TrackUrl, string ImageUrl)>
|
||||||
|
{
|
||||||
|
// Juliana Chahayed - Calm covers
|
||||||
|
{ "juliana_chahayed_1", ("https://open.spotify.com/intl-fr/track/0qYLUdJQMhrCFA9dNZGcnm?si=b4fd45727a354a31",
|
||||||
|
"https://i.scdn.co/image/ab67616d0000b2738e8e7b8f8f8f8f8f8f8f8f8") },
|
||||||
|
|
||||||
|
// Mister V - Chanson beauf
|
||||||
|
{ "mister_v_1", ("https://youtu.be/JeqUw7sGUK8?si=FnmFR2EgkVY6MhqQ",
|
||||||
|
"https://img.youtube.com/vi/JeqUw7sGUK8/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
// La Compagnie Créole
|
||||||
|
{ "compagnie_creole_1", ("https://youtu.be/wfxt1SGWAI8",
|
||||||
|
"https://img.youtube.com/vi/wfxt1SGWAI8/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
// FEMTOGO - Un autre jour
|
||||||
|
{ "femto_1", ("https://open.spotify.com/intl-fr/track/0qYLUdJQMhrCFA9dNZGcnm?si=b4fd45727a354a31",
|
||||||
|
"https://i.scdn.co/image/ab67616d0000b2738e8e7b8f8f8f8f8f8f8f8f8") },
|
||||||
|
|
||||||
|
// Chat Noir style songs (Théo De Sousa shares)
|
||||||
|
{ "chat_noir_1", ("https://youtu.be/OTi4-q-_Tj0?si=SNnLd-6Y893nL5Au",
|
||||||
|
"https://img.youtube.com/vi/OTi4-q-_Tj0/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
{ "chat_noir_2", ("https://youtu.be/X-rJ01EyiAI?si=gH9m_U8oXI35OgWu",
|
||||||
|
"https://img.youtube.com/vi/X-rJ01EyiAI/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
{ "chat_noir_3", ("https://youtu.be/7lIM0wSx7kQ?si=S-RAsLzd4SiCQhE4",
|
||||||
|
"https://img.youtube.com/vi/7lIM0wSx7kQ/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
{ "chat_noir_4", ("https://youtu.be/dbxyKR1P8vA?si=aRzdYBhwvKptV8Ff",
|
||||||
|
"https://img.youtube.com/vi/dbxyKR1P8vA/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
{ "chat_noir_5", ("https://youtu.be/DDHvKo5NnII?si=NFRkdVQL2mELP0yn",
|
||||||
|
"https://img.youtube.com/vi/DDHvKo5NnII/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
{ "chat_noir_6", ("https://youtu.be/J9LgHNf2Qy0?si=YGO1ggiLkefa9901",
|
||||||
|
"https://img.youtube.com/vi/J9LgHNf2Qy0/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
{ "chat_noir_7", ("https://youtu.be/oadhHk2xs6c?si=mbnJCA6SGsoYXnUK",
|
||||||
|
"https://img.youtube.com/vi/oadhHk2xs6c/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
{ "chat_noir_8", ("https://youtu.be/6K1zCgkBaoE?si=quq9vQLJ-AmzjRJJ",
|
||||||
|
"https://img.youtube.com/vi/6K1zCgkBaoE/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
// German rapper (Baptiste Nodon)
|
||||||
|
{ "german_rapper_1", ("https://www.youtube.com/watch?v=DWpg71HJt24",
|
||||||
|
"https://img.youtube.com/vi/DWpg71HJt24/maxresdefault.jpg") },
|
||||||
|
|
||||||
|
// Nizard Verdenal share
|
||||||
|
{ "nizard_1", ("https://youtu.be/1fjA68k8DAU?si=2PuZSquVQGvfmQkZ",
|
||||||
|
"https://img.youtube.com/vi/1fjA68k8DAU/maxresdefault.jpg") },
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<Artiste> GenerateArtists(int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Style> GenerateStyles(int count)
|
||||||
|
{
|
||||||
|
var styleNames = new[] { "Rock", "Pop", "Rap", "Électro", "Jazz", "Classique", "Reggae", "Blues", "Metal", "Folk", "Chanson française", "Hip-Hop", "R&B", "Soul", "Punk" };
|
||||||
|
var styles = new List<Style>();
|
||||||
|
|
||||||
|
for (int i = 0; i < Math.Min(count, styleNames.Length); i++)
|
||||||
|
{
|
||||||
|
styles.Add(new Style
|
||||||
|
{
|
||||||
|
IdStyle = i + 1,
|
||||||
|
Libelle = styleNames[i]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return styles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Titre> GenerateTitres(int count, List<Artiste> artists)
|
||||||
|
{
|
||||||
|
var titres = new List<Titre>();
|
||||||
|
var random = new Random();
|
||||||
|
var musicItems = RealMusicData.Values.ToList();
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var randomMusic = musicItems[random.Next(musicItems.Count)];
|
||||||
|
var randomArtist = artists[random.Next(artists.Count)];
|
||||||
|
|
||||||
|
titres.Add(new Titre
|
||||||
|
{
|
||||||
|
IdTitre = i + 1,
|
||||||
|
IdArtiste = randomArtist.IdArtiste,
|
||||||
|
Artiste = randomArtist,
|
||||||
|
Libelle = Lorem.Words(3).ToString(),
|
||||||
|
Chronique = Lorem.Paragraph(),
|
||||||
|
DateCreation = DateTime.Now.AddDays(-random.Next(1, 365)),
|
||||||
|
Duree = random.Next(120, 360), // 2 to 6 minutes in seconds
|
||||||
|
DateSortie = DateTime.Now.AddYears(-random.Next(0, 5)).AddDays(-random.Next(1, 365)),
|
||||||
|
UrlJaquette = randomMusic.ImageUrl,
|
||||||
|
UrlEcoute = randomMusic.TrackUrl,
|
||||||
|
NbLectures = random.Next(1000, 1000000),
|
||||||
|
NbLikes = random.Next(100, 100000),
|
||||||
|
Album = $"Album {random.Next(1, 10)}",
|
||||||
|
Commentaires = new List<Commentaire>()
|
||||||
|
});
|
||||||
|
|
||||||
|
randomArtist.Titres.Add(titres.Last());
|
||||||
|
}
|
||||||
|
|
||||||
|
return titres;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Commentaire> GenerateCommentaires(int count, List<Titre> titres)
|
||||||
|
{
|
||||||
|
var commentaires = new List<Commentaire>();
|
||||||
|
var random = new Random();
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var randomTitre = titres[random.Next(titres.Count)];
|
||||||
|
|
||||||
|
commentaires.Add(new Commentaire
|
||||||
|
{
|
||||||
|
IdCommentaire = i + 1,
|
||||||
|
Contenu = Lorem.Paragraph(),
|
||||||
|
Auteur = Name.FullName(),
|
||||||
|
DateCreation = DateTime.Now.AddDays(-random.Next(1, 30)),
|
||||||
|
IdTitre = randomTitre.IdTitre,
|
||||||
|
Titre = randomTitre
|
||||||
|
});
|
||||||
|
|
||||||
|
randomTitre.Commentaires.Add(commentaires.Last());
|
||||||
|
}
|
||||||
|
|
||||||
|
return commentaires;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// using Webzine.Entity;
|
using Webzine.Entity;
|
||||||
|
|
||||||
namespace Webzine.Repository.Contracts
|
namespace Webzine.Repository.Contracts
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user