Added 3 New LBP3 Categories - #1109
Conversation
|
I wrote a fairly simple recommendation system for the server which is VERY similar to how Sony used to handle it. I left my comments in there so you can easily read what everything does and why its there. If anything else is needed to change in this PR please let me know! I just figured I'd stack it on top of this pr as i built this on top of my already existing work. |
|
Is there a reason you're using |
|
Also, I forgot to thank you on here for the recommendation, as using /play was a far better way of tracking when a user actually enters a community level. I appreciate it! |
|
Also, this is my last commit to the PR unless an issue has been found.. which I'm sure there will 100% be issues, just feel free to let me know, and ask any questions if needed! |
Increased the limit of recently played slots from 20 to 30.
FeTetra
left a comment
There was a problem hiding this comment.
There is a lot more to review, but I'm going to leave this for now.
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using LBPUnion.ProjectLighthouse.Types.Users; |
There was a problem hiding this comment.
| using LBPUnion.ProjectLighthouse.Types.Users; |
This can be removed.
| public IActionResult GameState() | ||
| { | ||
| return this.Ok("VALID"); | ||
| } |
There was a problem hiding this comment.
| public IActionResult GameState() | |
| { | |
| return this.Ok("VALID"); | |
| } | |
| public IActionResult GameState() => this.Ok("VALID"); |
Why was this reformatted?
| public override string Name { get; set; } = "Newest Levels"; | ||
| public override string Description { get; set; } = "The most recently published content"; | ||
| public override string IconHash { get; set; } = "g820623"; | ||
| public override string Endpoint { get; set; } = "newest"; | ||
| public override string Tag => "newest"; | ||
| public override string[] Sorts { get; } = | ||
| { | ||
| "date" | ||
| }; |
There was a problem hiding this comment.
| public override string Name { get; set; } = "Newest Levels"; | |
| public override string Description { get; set; } = "The most recently published content"; | |
| public override string IconHash { get; set; } = "g820623"; | |
| public override string Endpoint { get; set; } = "newest"; | |
| public override string Tag => "newest"; | |
| public override string[] Sorts { get; } = | |
| { | |
| "date" | |
| }; | |
| public override string Name { get; set; } = "Newest Levels"; | |
| public override string Description { get; set; } = "The most recently published content"; | |
| public override string IconHash { get; set; } = "g820623"; | |
| public override string Endpoint { get; set; } = "newest"; | |
| public override string Tag => "newest"; | |
| public override string[] Sorts { get; } = | |
| { | |
| "date" | |
| }; |
| public override IQueryable<SlotEntity> GetItems(DatabaseContext database, GameTokenEntity token, SlotQueryBuilder queryBuilder) => | ||
| database.Slots.Where(queryBuilder.Build()) | ||
| .ApplyOrdering(new SlotSortBuilder<SlotEntity>().AddSort(new FirstUploadedSort())); |
There was a problem hiding this comment.
| public override IQueryable<SlotEntity> GetItems(DatabaseContext database, GameTokenEntity token, SlotQueryBuilder queryBuilder) => | |
| database.Slots.Where(queryBuilder.Build()) | |
| .ApplyOrdering(new SlotSortBuilder<SlotEntity>().AddSort(new FirstUploadedSort())); | |
| public override IQueryable<SlotEntity> GetItems(DatabaseContext database, GameTokenEntity token, SlotQueryBuilder queryBuilder) => | |
| database.Slots.Where(queryBuilder.Build()) | |
| .ApplyOrdering(new SlotSortBuilder<SlotEntity>().AddSort(new FirstUploadedSort())); |
There was a problem hiding this comment.
This file has tons of formatting issues, there are private fields at the top which should all be configuration options, you should consider making a new config file to store search and category query options. There are also a lot of db operations which could potentially become very expensive, especially if the number of things such as neighbors can potentially approach the set max neighbor value of 250. A lot of the variable naming choices are confusing, such as the repeated use of h in lambda expressions which can seemingly refer to a hearted user or a hearted slot of which can either be hearted by you, a user you hearted, or (in the case of only slots) a distinct user who hearted the same slot as the user you hearted. In every other case with categories, they directly return an IQueryable for the database, in this case, you do all the db work here, and then convert the list of results into an IQueryable. This sidesteps the purpose of returning an IQueryable to begin with, as it is intended to only provide the database query for code within the list controller to actually perform the returned query alongside other things like pagination. The code will always attempt to grab a maximum of 1000 slot candidates for the resulting list, making the later query pagination in the code totally pointless.
I added support for LBP3's recently played category.
Essentially, LBP2 tracks which levels you've played client side, and just reports it back whenever you click on "Recently Played". LBP3 on the original servers would handle all of this server sided. This essentially works by recording the recently played community levels via the games "gameState" request, then it stores the recently played slot ID's and the timestamps per each user. I set a limit so that it keeps a maximum of 20 recently played levels, when you replay a level that was already on the list, it changes the timestamp to have it re-appear at the top of the list. The game also only applies to users who are playing on LBP3. If you play LBP1 or LBP2, it will not change this list whatsoever.