Skip to content

Commit

Permalink
put the filter in a more reasonable place
Browse files Browse the repository at this point in the history
  • Loading branch information
Metraberryy committed Aug 28, 2024
1 parent 9ac7431 commit cdddfca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ public async Task<IActionResult> LuckyDipSlots([FromQuery] int seed)
PaginationData pageData = this.Request.GetPaginationData();

SlotQueryBuilder queryBuilder = this.FilterFromRequest(token);
queryBuilder.AddFilter(new LockedSlotFilter());

pageData.TotalElements = await StatisticsHelper.SlotCount(this.database, queryBuilder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ void ParseLbp3Query(string key, Action allMust, Action noneCan, Action dontCare)

if (!queryBuilder.GetFilters(typeof(CrossControlFilter)).Any())
queryBuilder.AddFilter(new ExcludeCrossControlFilter());

if (controller.Request.Path.Value != null && controller.Request.Path.Value.EndsWith("lbp2luckydip"))
queryBuilder.AddFilter(new LockedSlotFilter());

queryBuilder.AddFilter(new SubLevelFilter(token.UserId));
queryBuilder.AddFilter(new HiddenSlotFilter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Filter;
using LBPUnion.ProjectLighthouse.Filter.Filters;
using LBPUnion.ProjectLighthouse.Filter.Sorts;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
Expand All @@ -16,7 +17,10 @@ public class LuckyDipCategory : SlotCategory
public override string Endpoint { get; set; } = "lucky_dip";
public override string Tag => "lucky_dip";

public override IQueryable<SlotEntity> GetItems(DatabaseContext database, GameTokenEntity token, SlotQueryBuilder queryBuilder) =>
database.Slots.Where(queryBuilder.Build())
public override IQueryable<SlotEntity> GetItems(DatabaseContext database, GameTokenEntity token, SlotQueryBuilder queryBuilder)
{
queryBuilder.AddFilter(new LockedSlotFilter());
return database.Slots.Where(queryBuilder.Build())
.ApplyOrdering(new SlotSortBuilder<SlotEntity>().AddSort(new RandomFirstUploadedSort()));
}
}

0 comments on commit cdddfca

Please sign in to comment.