forked from LittleBigRefresh/Refresh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackfillReviewLabelsMigration.cs
More file actions
29 lines (24 loc) · 913 Bytes
/
Copy pathBackfillReviewLabelsMigration.cs
File metadata and controls
29 lines (24 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Refresh.Database.Models.Comments;
using Refresh.Database.Models.Levels;
using Refresh.Workers;
namespace Refresh.Interfaces.Workers.Migrations;
public class BackfillReviewLabelsMigration : MigrationJob<GameReview>
{
protected override int Migrate(WorkContext context, GameReview[] batch)
{
foreach (GameReview review in batch)
{
#pragma warning disable CS0618 // LabelsString is obsolete
if (string.IsNullOrWhiteSpace(review.LabelsString)) continue;
context.Database.Update(review);
review.Labels = LabelExtensions.FromLbpCommaList(review.LabelsString).ToList();
#pragma warning restore CS0618
}
context.Database.SaveChanges();
return batch.Length;
}
protected override IQueryable<GameReview> SortAndFilter(IQueryable<GameReview> query)
{
return query.OrderBy(l => l.ReviewId);
}
}