-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Team composition #494
Merged
tabascq
merged 4 commits into
PuzzleServer:master
from
digit01Wave:jessica/TeamComposition
Jun 22, 2019
Merged
Team composition #494
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
@page "/{eventId}/{eventRole}/Teams/TeamCompositionSummary" | ||
@model ServerCore.Pages.Teams.TeamCompositionSummaryModel | ||
@{ | ||
ViewData["Title"] = "Team Index"; | ||
ViewData["AdminRoute"] = "/Teams/TeamCompositionSummary"; | ||
ViewData["AuthorRoute"] = "/Teams/Index"; | ||
ViewData["PlayRoute"] = "/Teams/Index"; | ||
} | ||
|
||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>TeamCompositionSummary</title> | ||
<style> | ||
td, th { | ||
text-align:center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<a asp-page="/Teams/Index">Back to team list</a> | ||
<br /> | ||
<h2>Team Composition Summary</h2> | ||
<div> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th> | ||
Team Name | ||
</th> | ||
<th> | ||
Total | ||
</th> | ||
<th> | ||
Employee Count | ||
</th> | ||
<th> | ||
Intern Count | ||
</th> | ||
<th> | ||
Non-Microsoft Count | ||
</th> | ||
<th> | ||
Possible Employee Aliases | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var teamComp in Model.TeamCompositions) | ||
{ | ||
<tr> | ||
<td> | ||
<a asp-page="./Details" asp-route-teamId="@teamComp.TeamID">@teamComp.TeamName</a> | ||
</td> | ||
<td> | ||
@teamComp.Total | ||
</td> | ||
<td> | ||
@teamComp.MicrosoftNonInternCount | ||
</td> | ||
<td> | ||
@teamComp.InternCount | ||
</td> | ||
<td> | ||
@teamComp.NonMicrosoftCount | ||
</td> | ||
<td> | ||
@teamComp.PossibleEmployeeAliases.Count | ||
@if (teamComp.PossibleEmployeeAliases.Count > 0) | ||
{ | ||
<br/> | ||
@string.Format("({0})", string.Join("; ", teamComp.PossibleEmployeeAliases)) | ||
} | ||
</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
</div> | ||
</body> | ||
</html> |
104 changes: 104 additions & 0 deletions
104
ServerCore/Pages/Teams/TeamCompositionSummary.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.EntityFrameworkCore; | ||
using ServerCore.DataModel; | ||
using ServerCore.Helpers; | ||
using ServerCore.ModelBases; | ||
|
||
namespace ServerCore.Pages.Teams | ||
{ | ||
/// <summary> | ||
/// Model for the author/admin's view of the feedback items for a specific puzzle | ||
/// /used for viewing and aggregating feedback for a specific puzzle | ||
/// </summary> | ||
[Authorize(Policy = "IsEventAdmin")] | ||
public class TeamCompositionSummaryModel : EventSpecificPageModel | ||
{ | ||
// AlphaNumeric or dashes only | ||
public Regex aliasRegex = new Regex("^[a-zA-Z0-9-]*$"); | ||
|
||
public TeamCompositionSummaryModel(PuzzleServerContext serverContext, UserManager<IdentityUser> userManager) : base(serverContext, userManager) | ||
{ | ||
} | ||
|
||
public class TeamComposition | ||
{ | ||
public TeamComposition(int teamId) | ||
{ | ||
this.TeamID = teamId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No |
||
this.PossibleEmployeeAliases = new List<string>(); | ||
} | ||
|
||
public int TeamID { get; } | ||
public string TeamName { get; set; } | ||
public int MicrosoftNonInternCount { get; set; } | ||
public int InternCount { get; set; } | ||
public int NonMicrosoftCount { get; set; } | ||
public int Total { get; set; } | ||
public List<string> PossibleEmployeeAliases { get; set; } | ||
} | ||
|
||
public IEnumerable<TeamComposition> TeamCompositions { get; set; } | ||
|
||
public IActionResult OnGet() | ||
{ | ||
TeamCompositions = _context.Teams.Where(team => team.EventID == Event.ID) | ||
.Join( | ||
_context.TeamMembers, | ||
team => team.ID, | ||
teamMember => teamMember.Team.ID, | ||
(team, teamMember) => new IntermediateTeamMember() { TeamID = team.ID, TeamName = team.Name, TeamMember = teamMember.Member }) | ||
.GroupBy(intermediate => intermediate.TeamID) | ||
.Select(this.MapToTeamComposition); | ||
|
||
return Page(); | ||
} | ||
|
||
private TeamComposition MapToTeamComposition(IGrouping<int, IntermediateTeamMember> group) | ||
{ | ||
TeamComposition toReturn = new TeamComposition(group.Key); | ||
|
||
foreach (IntermediateTeamMember groupMember in group) | ||
{ | ||
toReturn.TeamName = groupMember.TeamName; | ||
toReturn.Total += 1; | ||
|
||
string email = groupMember.TeamMember.Email; | ||
string alias = groupMember.TeamMember.EmployeeAlias; | ||
if (email.EndsWith("@microsoft.com")) | ||
{ | ||
if (email.StartsWith("t-")) | ||
{ | ||
toReturn.InternCount += 1; | ||
} | ||
else | ||
{ | ||
toReturn.MicrosoftNonInternCount += 1; | ||
} | ||
} | ||
else if (!string.IsNullOrEmpty(alias) && aliasRegex.IsMatch(alias)) | ||
{ | ||
toReturn.PossibleEmployeeAliases.Add(alias); | ||
} | ||
else | ||
{ | ||
toReturn.NonMicrosoftCount += 1; | ||
} | ||
} | ||
|
||
return toReturn; | ||
} | ||
|
||
private class IntermediateTeamMember | ||
{ | ||
public int TeamID { get; set; } | ||
public string TeamName { get; set; } | ||
public PuzzleUser TeamMember { get; set; } | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hides the swag report from authors. I think they might need access to it.