Skip to content

Commit

Permalink
implement tmdb, reduce load time
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinschumacher committed May 26, 2024
1 parent f2b06b6 commit 67763f4
Show file tree
Hide file tree
Showing 29 changed files with 726 additions and 125 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,4 @@ FodyWeavers.xsd
*.db-shm
*.db-wal
*.json
*.update
8 changes: 0 additions & 8 deletions CleanupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ public class CleanupService(KinohannoverContext context, ILogger<CleanupService>
{
public async Task CleanupAsync()
{
var cinemas = context.Cinema.Where(e => e.Movies.Count == 0);
logger.LogInformation("Removing {CinemaCount} cinemas", cinemas.Count());
context.Cinema.RemoveRange(cinemas);

var movies = context.Movies.Where(e => e.Cinemas.Count == 0 || e.ShowTimes.Count == 0);
logger.LogInformation("Removing {MovieCount} movies", movies.Count());
context.Movies.RemoveRange(movies);

var showTimes = context.ShowTime.Where(e => e.StartTime < DateTime.Now.AddHours(-1));
logger.LogInformation("Removing {ShowTimeCount} showtimes", showTimes.Count());
context.ShowTime.RemoveRange(showTimes);
Expand Down
6 changes: 3 additions & 3 deletions Data/KinohannoverContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public class KinohannoverContext(DbContextOptions<KinohannoverContext> options)

public DbSet<Models.ShowTime> ShowTime { get; set; } = default!;

protected override void OnModelCreating(ModelBuilder modelBuilder)
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
modelBuilder.Entity<Models.Movie>().HasMany(m => m.ShowTimes).WithOne(s => s.Movie).OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Models.Cinema>().HasMany(c => c.Movies).WithMany(m => m.Cinemas);
configurationBuilder.Properties<string>().UseCollation("NOCASE");
base.ConfigureConventions(configurationBuilder);
}
}
}
191 changes: 191 additions & 0 deletions Migrations/20240526235511_AddMovieMetadata.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 67763f4

Please sign in to comment.