Skip to content
Permalink
Browse files

Fix Recently Added Series

  • Loading branch information...
da3dsoul committed Jun 15, 2019
1 parent 76d97a4 commit d63ff7d43c3879f028645ffbe740cd2120520bb1
@@ -523,23 +523,8 @@ public List<CL_AnimeSeries_User> GetSeriesRecentlyAdded(int maxRecords, int user
SVR_JMMUser user = RepoFactory.JMMUser.GetByID(userID);
if (user == null) return retSeries;

List<SVR_AnimeSeries> series = RepoFactory.AnimeSeries.GetMostRecentlyAdded(maxRecords);
int numSeries = 0;
foreach (SVR_AnimeSeries ser in series)
{
if (user.AllowedSeries(ser))
{
CL_AnimeSeries_User serContract = ser.GetUserContract(userID);
if (serContract != null)
{
retSeries.Add(serContract);
numSeries++;

// Lets only return the specified amount
if (retSeries.Count == maxRecords) return retSeries;
}
}
}
List<SVR_AnimeSeries> series = RepoFactory.AnimeSeries.GetMostRecentlyAdded(maxRecords, userID);
retSeries.AddRange(series.Select(a => a.GetUserContract(userID)).Where(a => a != null));
}
catch (Exception ex)
{
@@ -1692,7 +1692,7 @@ public ActionResult<IEnumerable<Serie>> GetSeriesRecent([FromQuery] API_Call_Par
{
para.limit = 10;
}
List<SVR_AnimeSeries> series = RepoFactory.AnimeSeries.GetMostRecentlyAdded(para.limit);
List<SVR_AnimeSeries> series = RepoFactory.AnimeSeries.GetMostRecentlyAdded(para.limit, User.JMMUserID);

foreach (SVR_AnimeSeries aser in series)
{
@@ -273,11 +273,12 @@ public List<SVR_AnimeSeries> GetWithMissingEpisodes()
}
}

public List<SVR_AnimeSeries> GetMostRecentlyAdded(int maxResults)
public List<SVR_AnimeSeries> GetMostRecentlyAdded(int maxResults, int userID)
{
lock (Cache)
{
return Cache.Values.OrderByDescending(a => a.DateTimeCreated).Take(maxResults).ToList();
return Cache.Values.Where(a => userID == 0 || RepoFactory.JMMUser.GetByID(userID).AllowedSeries(a))
.OrderByDescending(a => a.DateTimeCreated).Take(maxResults).ToList();
}
}
}

0 comments on commit d63ff7d

Please sign in to comment.
You can’t perform that action at this time.