Refactor ShowAudience handling across the application to align with MPAA rating system. Update ShowAudience enum to reflect new ratings (G, PG, PG-13, R, NC-17) and adjust related data models, API types, and frontend components to support nullable audience values. Enhance metadata handling to incorporate content ratings from external sources, ensuring proper audience filtering in scheduling logic. Update documentation to clarify changes in audience categorization and its implications for content management.
This commit is contained in:
@@ -16,12 +16,12 @@ public class PlanningRulesTests
|
||||
public void AudienceAt_DayWindow(int hour, int minute, bool inside)
|
||||
{
|
||||
var rules = new PlanningRules(
|
||||
[new AudienceWindow(new TimeOnly(6, 0), new TimeOnly(23, 0), ShowAudience.Teen)]
|
||||
[new AudienceWindow(new TimeOnly(6, 0), new TimeOnly(23, 0), ShowAudience.Pg13)]
|
||||
);
|
||||
|
||||
var result = rules.AudienceAt(new TimeOnly(hour, minute));
|
||||
|
||||
Assert.Equal(inside ? ShowAudience.Teen : null, result);
|
||||
Assert.Equal(inside ? ShowAudience.Pg13 : null, result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -32,12 +32,12 @@ public class PlanningRulesTests
|
||||
{
|
||||
// «С 23:00 до 06:00» — ночное окно, границы сравниваются в обратную сторону.
|
||||
var rules = new PlanningRules(
|
||||
[new AudienceWindow(new TimeOnly(23, 0), new TimeOnly(6, 0), ShowAudience.Adult)]
|
||||
[new AudienceWindow(new TimeOnly(23, 0), new TimeOnly(6, 0), ShowAudience.Nc17)]
|
||||
);
|
||||
|
||||
var result = rules.AudienceAt(new TimeOnly(hour, minute));
|
||||
|
||||
Assert.Equal(inside ? ShowAudience.Adult : null, result);
|
||||
Assert.Equal(inside ? ShowAudience.Nc17 : null, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -46,13 +46,13 @@ public class PlanningRulesTests
|
||||
// Широкое окно, случайно наложенное поверх детского, не должно его отменять.
|
||||
var rules = new PlanningRules(
|
||||
[
|
||||
new AudienceWindow(new TimeOnly(6, 0), new TimeOnly(23, 0), ShowAudience.General),
|
||||
new AudienceWindow(new TimeOnly(7, 0), new TimeOnly(10, 0), ShowAudience.Kids),
|
||||
new AudienceWindow(new TimeOnly(6, 0), new TimeOnly(23, 0), ShowAudience.R),
|
||||
new AudienceWindow(new TimeOnly(7, 0), new TimeOnly(10, 0), ShowAudience.G),
|
||||
]
|
||||
);
|
||||
|
||||
Assert.Equal(ShowAudience.Kids, rules.AudienceAt(new TimeOnly(8, 0)));
|
||||
Assert.Equal(ShowAudience.General, rules.AudienceAt(new TimeOnly(12, 0)));
|
||||
Assert.Equal(ShowAudience.G, rules.AudienceAt(new TimeOnly(8, 0)));
|
||||
Assert.Equal(ShowAudience.R, rules.AudienceAt(new TimeOnly(12, 0)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -65,7 +65,7 @@ public class PlanningRulesTests
|
||||
public void Json_RoundTrips()
|
||||
{
|
||||
var rules = new PlanningRules(
|
||||
[new AudienceWindow(new TimeOnly(6, 0), new TimeOnly(23, 0), ShowAudience.Teen)],
|
||||
[new AudienceWindow(new TimeOnly(6, 0), new TimeOnly(23, 0), ShowAudience.Pg13)],
|
||||
new RepeatLimitRule(7, 2),
|
||||
MaxBreakMinutesPerHour: 12,
|
||||
MaxGenreSharePercent: 40,
|
||||
@@ -84,6 +84,19 @@ public class PlanningRulesTests
|
||||
Assert.Equal(rules.MaxFallbackSharePercent, restored.MaxFallbackSharePercent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Json_WritesMpaaSpelling()
|
||||
{
|
||||
// Рейтинг уезжает в jsonb шаблона и в API ровно тем написанием, каким приходит от источников.
|
||||
// Round-trip этого не поймает: он одинаково зелёный и на «Pg13», а такое значение потом
|
||||
// придётся переводить на каждой границе.
|
||||
var json = new PlanningRules(
|
||||
[new AudienceWindow(new TimeOnly(6, 0), new TimeOnly(23, 0), ShowAudience.Pg13)]
|
||||
).ToJson();
|
||||
|
||||
Assert.Contains("\"PG-13\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FromJson_Garbage_IsNull()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user