Skip to content

Commit

Permalink
Merge branch 'develop' into s24-privacy
Browse files Browse the repository at this point in the history
  • Loading branch information
jsenning committed Jun 11, 2024
2 parents d706e46 + 668b422 commit 275360c
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 21 deletions.
13 changes: 13 additions & 0 deletions Gordon360/Controllers/RecIM/ParticipantsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ public ActionResult<IEnumerable<ParticipantStatusExtendedViewModel>> GetParticip
return Ok(res);
}

/// <summary>
/// Used primarily on the rec-im base page, fetches all future/upcoming matches for a participant
/// </summary>
/// <param name="username">participant username</param>
/// <returns>list of upcoming matches of given participant</returns>
[HttpGet]
[Route("{username}/matches")]
public ActionResult<IEnumerable<MatchExtendedViewModel>> GetParticipantMatches(string username)
{
var res = participantService.GetParticipantMatches(username);
return Ok(res);
}

[HttpGet]
[Route("{username}")]
public ActionResult<ParticipantExtendedViewModel> GetParticipantByUsername(string username)
Expand Down
7 changes: 7 additions & 0 deletions Gordon360/Documentation/Gordon360.xml

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

2 changes: 1 addition & 1 deletion Gordon360/Services/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class EventService(CCTContext context, IMemoryCache cache, IAccountServic
*/
private static readonly string AllEventsURL = "https://25live.collegenet.com/25live/data/gordon/run/events.xml?/&event_type_id=14+57&state=2&end_after=" + GetFirstEventDate() + "&scope=extended";

private IEnumerable<EventViewModel> Events => cache.Get<IEnumerable<EventViewModel>>(CacheKeys.Events);
private IEnumerable<EventViewModel> Events => cache.Get<IEnumerable<EventViewModel>>(CacheKeys.Events) ?? [];

/// <summary>
/// Access the memory stream created by the cached task and parse it into events
Expand Down
85 changes: 65 additions & 20 deletions Gordon360/Services/RecIM/ParticipantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,74 @@ public IEnumerable<ParticipantStatusExtendedViewModel> GetParticipantStatusHisto

public IEnumerable<TeamExtendedViewModel> GetParticipantTeams(string username)
{
var teams = context.ParticipantTeam
.Where(pt => pt.ParticipantUsername == username && pt.RoleTypeID != 0 && pt.RoleTypeID != 2 )
.Join(context.Team.Where(t => t.StatusID != 0),
pt => pt.TeamID,
t => t.ID,
(pt, t) => new TeamExtendedViewModel
{
ID = t.ID,
Activity = context.Activity.FirstOrDefault(a => a.ID == t.ActivityID),
Name = t.Name,
Status = context.TeamStatus
.FirstOrDefault(ts => ts.ID == t.StatusID)
.Description,
Logo = t.Logo,
TeamRecord = context.SeriesTeam
.Include(st => st.Team)
.Where(st => st.TeamID == t.ID)
.Select(st => (TeamRecordViewModel)st)
});
var teams = context.ParticipantTeam
.Where(pt => pt.ParticipantUsername == username && pt.RoleTypeID != 0 && pt.RoleTypeID != 2)
.Join(context.Team.Where(t => t.StatusID != 0),
pt => pt.TeamID,
t => t.ID,
(pt, t) => new TeamExtendedViewModel
{
ID = t.ID,
Activity = context.Activity.FirstOrDefault(a => a.ID == t.ActivityID),
Name = t.Name,
Status = context.TeamStatus
.FirstOrDefault(ts => ts.ID == t.StatusID)
.Description,
Logo = t.Logo,
TeamRecord = context.SeriesTeam
.Include(st => st.Team)
.Where(st => st.TeamID == t.ID)
.Select(st => (TeamRecordViewModel)st)
});
return teams;
}

public IEnumerable<MatchExtendedViewModel> GetParticipantMatches(string username)
{
var matches = context.ParticipantTeam
.Where(pt => pt.ParticipantUsername == username && pt.RoleTypeID != 0 && pt.RoleTypeID != 2)
.Join(context.MatchTeam.Where(mt => mt.StatusID != 0 && mt.Match.StatusID != 0)
.Include(mt => mt.Match.Series.Activity)
.Include(mt => mt.Match.MatchTeam)
.ThenInclude(mt => mt.Match)
.Include(mt => mt.Match.MatchTeam)
.ThenInclude(mt => mt.Status),

pt => pt.TeamID,
mt => mt.TeamID,
(pt, mt) => new MatchExtendedViewModel
{
ID = mt.Match.ID,
Scores = mt.Match.MatchTeam
.Select(mt_ => (TeamMatchHistoryViewModel)mt_)
.AsEnumerable(),
StartTime = mt.Match.StartTime,
Surface = mt.Match.Surface.Name,
Status = mt.Match.Status.Description,
Activity = new ActivityExtendedViewModel
{
ID = mt.Match.Series.Activity.ID,
Name = mt.Match.Series.Activity.Name
},
Team = mt.Match.MatchTeam.Where(mt_ => mt_.StatusID != 0)
.Select(mt_ => new TeamExtendedViewModel
{
ID = mt_.TeamID,
Name = mt_.Team.Name,
TeamRecord = context.SeriesTeam
.Where(st => st.SeriesID == mt.Match.SeriesID && st.TeamID == mt_.TeamID)
.Select(st => new TeamRecordViewModel
{
WinCount = st.WinCount,
LossCount = st.LossCount
})
})
}
);
return matches;
}

public IEnumerable<ParticipantExtendedViewModel> GetParticipants()
{
// This is Participant left join CustomParticipant left join Student
Expand Down
1 change: 1 addition & 0 deletions Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public interface IParticipantService
IEnumerable<ParticipantStatusExtendedViewModel> GetParticipantStatusHistory(string username);
ParticipantExtendedViewModel? GetParticipantByUsername(string username, string? roleType = null);
AccountViewModel GetUnaffiliatedAccountByUsername(string username);
IEnumerable<MatchExtendedViewModel> GetParticipantMatches(string username);
IEnumerable<TeamExtendedViewModel> GetParticipantTeams(string username);
Task<ParticipantExtendedViewModel> PostParticipantAsync(string username, int? statusID = 4);
Task<ParticipantExtendedViewModel> PostCustomParticipantAsync(string username, CustomParticipantViewModel newCustomParticipant);
Expand Down

0 comments on commit 275360c

Please sign in to comment.