Revert "feat(schedule): split team projects into groups like individual projects"

This reverts commit 00a676fcc9.
This commit is contained in:
2026-01-23 15:17:41 +08:00
parent 00a676fcc9
commit 9975dfd48c
@@ -124,26 +124,19 @@ public class ParticipantGroupingService {
continue; continue;
} }
// Get distinct team names // For team projects, skip gender filter as validation is done at registration time
List<String> teamNames = members.stream() // Team athlete records do not have accurate gender info (they represent the team, not individual members)
// members = filterByCategory(members, project);
long teamCount = members.stream()
.map(MartialAthlete::getTeamName) .map(MartialAthlete::getTeamName)
.filter(t -> t != null && !t.isEmpty()) .filter(org -> org != null && !org.isEmpty())
.distinct() .distinct()
.collect(Collectors.toList()); .count();
int teamCount = teamNames.size();
String projectName = project.getProjectName(); String projectName = project.getProjectName();
String categoryName = getProjectCategoryName(project); String categoryName = getProjectCategoryName(project);
// Calculate max teams per group (use maxParticipants as max teams)
int maxTeamsPerGroup = project.getMaxParticipants() != null && project.getMaxParticipants() > 0
? project.getMaxParticipants() : 10;
int durationPerTeam = (project.getEstimatedDuration() != null && project.getEstimatedDuration() > 0)
? project.getEstimatedDuration() : 5;
if (teamCount <= maxTeamsPerGroup) {
// No need to split - single group
ScheduleGroupData group = ScheduleGroupData.builder() ScheduleGroupData group = ScheduleGroupData.builder()
.groupName(projectName + (categoryName.isEmpty() ? "" : " " + categoryName)) .groupName(projectName + (categoryName.isEmpty() ? "" : " " + categoryName))
.projectId(first.getProjectId()) .projectId(first.getProjectId())
@@ -152,47 +145,19 @@ public class ParticipantGroupingService {
.category(categoryName) .category(categoryName)
.displayOrder(displayOrder++) .displayOrder(displayOrder++)
.totalParticipants(members.size()) .totalParticipants(members.size())
.totalTeams(teamCount) .totalTeams((int) teamCount)
.athletes(members) .athletes(members)
.estimatedDuration(teamCount * durationPerTeam + Math.max(0, teamCount - 1) * 2)
.build(); .build();
groups.add(group);
int duration;
if (project.getEstimatedDuration() != null && project.getEstimatedDuration() > 0) {
duration = (int) teamCount * project.getEstimatedDuration();
} else { } else {
// Split into multiple groups duration = (int) teamCount * 5 + Math.max(0, (int) teamCount - 1) * 2;
int numGroups = (int) Math.ceil((double) teamCount / maxTeamsPerGroup); }
group.setEstimatedDuration(duration);
log.info("Team project {} {} has {} teams, splitting into {} groups (max {} per group)",
projectName, categoryName, teamCount, numGroups, maxTeamsPerGroup);
for (int i = 0; i < numGroups; i++) {
int startIdx = i * maxTeamsPerGroup;
int endIdx = Math.min(startIdx + maxTeamsPerGroup, teamCount);
List<String> subTeamNames = teamNames.subList(startIdx, endIdx);
// Filter athletes belonging to teams in this sub-group
List<MartialAthlete> subMembers = members.stream()
.filter(a -> subTeamNames.contains(a.getTeamName()))
.collect(Collectors.toList());
int subTeamCount = subTeamNames.size();
String groupSuffix = "" + (i + 1) + "";
ScheduleGroupData group = ScheduleGroupData.builder()
.groupName(projectName + " " + categoryName + groupSuffix)
.projectId(first.getProjectId())
.projectType((project.getType() == 2 || project.getType() == 3) ? 2 : 1)
.maxParticipants(project.getMaxParticipants())
.category(categoryName)
.displayOrder(displayOrder++)
.totalParticipants(subMembers.size())
.totalTeams(subTeamCount)
.athletes(subMembers)
.estimatedDuration(subTeamCount * durationPerTeam + Math.max(0, subTeamCount - 1) * 2)
.build();
groups.add(group); groups.add(group);
} }
}
}
return displayOrder; return displayOrder;
} }
@@ -259,17 +224,16 @@ public class ParticipantGroupingService {
int totalPeople = members.size(); int totalPeople = members.size();
int numSubGroups = (int) Math.ceil((double) totalPeople / maxPeoplePerGroup); int numSubGroups = (int) Math.ceil((double) totalPeople / maxPeoplePerGroup);
log.info("Individual project {} {} has {} people, splitting into {} groups (max {} per group)", log.info("Individual project '{}' has {} people, splitting into {} groups (max {} per group)",
projectName, categoryName, totalPeople, numSubGroups, maxPeoplePerGroup); projectName + " " + categoryName, totalPeople, numSubGroups, maxPeoplePerGroup);
for (int i = 0; i < numSubGroups; i++) { for (int i = 0; i < numSubGroups; i++) {
int startIdx = i * maxPeoplePerGroup; int startIdx = i * maxPeoplePerGroup;
int endIdx = Math.min(startIdx + maxPeoplePerGroup, totalPeople); int endIdx = Math.min(startIdx + maxPeoplePerGroup, totalPeople);
List<MartialAthlete> subGroupMembers = new ArrayList<>(members.subList(startIdx, endIdx)); List<MartialAthlete> subGroupMembers = new ArrayList<>(members.subList(startIdx, endIdx));
String groupSuffix = "" + (i + 1) + "";
ScheduleGroupData group = ScheduleGroupData.builder() ScheduleGroupData group = ScheduleGroupData.builder()
.groupName(projectName + " " + categoryName + groupSuffix) .groupName(projectName + " " + categoryName + "" + (i + 1) + "")
.projectId(project.getId()) .projectId(project.getId())
.projectType(1) .projectType(1)
.maxParticipants(maxPeoplePerGroup) .maxParticipants(maxPeoplePerGroup)