Add editorconfig and analyzers, format backend code
This commit is contained in:
@@ -1,48 +1,49 @@
|
||||
namespace Musify.Domain.ValueObjects
|
||||
namespace Musify.Domain.ValueObjects;
|
||||
|
||||
|
||||
public static class GenreCompatibility
|
||||
{
|
||||
private static readonly HashSet<(Genre, Genre)> IncompatiblePairs = BuildIncompatiblePairs();
|
||||
|
||||
public static class GenreCompatibility
|
||||
private static HashSet<(Genre, Genre)> BuildIncompatiblePairs()
|
||||
{
|
||||
private static readonly HashSet<(Genre, Genre)> IncompatiblePairs = BuildIncompatiblePairs();
|
||||
var pairs = new HashSet<(Genre, Genre)>();
|
||||
|
||||
private static HashSet<(Genre, Genre)> BuildIncompatiblePairs()
|
||||
void Add(Genre a, Genre b)
|
||||
{
|
||||
var pairs = new HashSet<(Genre, Genre)>();
|
||||
|
||||
void Add(Genre a, Genre b)
|
||||
{
|
||||
pairs.Add((a, b));
|
||||
pairs.Add((b, a));
|
||||
}
|
||||
|
||||
var intense = new[] { Genre.Metal, Genre.Punk, Genre.Dubstep, Genre.DrumAndBass };
|
||||
var mellow = new[] { Genre.Classical, Genre.Ambient, Genre.Lofi };
|
||||
|
||||
foreach (var intenseGenre in intense)
|
||||
foreach (var mellowGenre in mellow)
|
||||
Add(intenseGenre, mellowGenre);
|
||||
|
||||
return pairs;
|
||||
pairs.Add((a, b));
|
||||
pairs.Add((b, a));
|
||||
}
|
||||
|
||||
public static bool AreCompatible(Genre a, Genre b) =>
|
||||
a == b || !IncompatiblePairs.Contains((a, b));
|
||||
var intense = new[] { Genre.Metal, Genre.Punk, Genre.Dubstep, Genre.DrumAndBass };
|
||||
var mellow = new[] { Genre.Classical, Genre.Ambient, Genre.Lofi };
|
||||
|
||||
public static IReadOnlyCollection<(Genre First, Genre Second)> FindConflicts(IEnumerable<Genre> tags)
|
||||
foreach (var intenseGenre in intense)
|
||||
{
|
||||
var distinctTags = tags.Distinct().ToList();
|
||||
var conflicts = new List<(Genre, Genre)>();
|
||||
|
||||
for (var i = 0; i < distinctTags.Count; i++)
|
||||
{
|
||||
for (var j = i + 1; j < distinctTags.Count; j++)
|
||||
{
|
||||
if (!AreCompatible(distinctTags[i], distinctTags[j]))
|
||||
conflicts.Add((distinctTags[i], distinctTags[j]));
|
||||
}
|
||||
}
|
||||
|
||||
return conflicts;
|
||||
foreach (var mellowGenre in mellow)
|
||||
Add(intenseGenre, mellowGenre);
|
||||
}
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
public static bool AreCompatible(Genre a, Genre b) =>
|
||||
a == b || !IncompatiblePairs.Contains((a, b));
|
||||
|
||||
public static IReadOnlyCollection<(Genre First, Genre Second)> FindConflicts(IEnumerable<Genre> tags)
|
||||
{
|
||||
var distinctTags = tags.Distinct().ToList();
|
||||
var conflicts = new List<(Genre, Genre)>();
|
||||
|
||||
for (var i = 0; i < distinctTags.Count; i++)
|
||||
{
|
||||
for (var j = i + 1; j < distinctTags.Count; j++)
|
||||
{
|
||||
if (!AreCompatible(distinctTags[i], distinctTags[j]))
|
||||
conflicts.Add((distinctTags[i], distinctTags[j]));
|
||||
}
|
||||
}
|
||||
|
||||
return conflicts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user