修正人氣排行的數量問題
This commit is contained in:
@@ -376,10 +376,11 @@ export function PopularityRankings() {
|
||||
|
||||
const currentPage = teamCurrentPage
|
||||
const setCurrentPage = setTeamCurrentPage
|
||||
const totalPages = Math.ceil(teamsWithScores.length / ITEMS_PER_PAGE)
|
||||
const validTeams = teamsWithScores.filter(team => team && team.id)
|
||||
const totalPages = Math.ceil(validTeams.length / ITEMS_PER_PAGE)
|
||||
const startIndex = currentPage * ITEMS_PER_PAGE
|
||||
const endIndex = startIndex + ITEMS_PER_PAGE
|
||||
const currentTeams = teamsWithScores.slice(startIndex, endIndex)
|
||||
const currentTeams = validTeams.slice(startIndex, endIndex)
|
||||
|
||||
return (
|
||||
<Card className="mb-8">
|
||||
@@ -391,7 +392,7 @@ export function PopularityRankings() {
|
||||
<span>{title}</span>
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{currentCompetition?.name || "暫無進行中的競賽"} - {title}人氣排名 (共 {teamsWithScores.length} 個團隊)
|
||||
{currentCompetition?.name || "暫無進行中的競賽"} - {title}人氣排名 (共 {teamsWithScores.filter(team => team && team.id).length} 個團隊)
|
||||
</CardDescription>
|
||||
</div>
|
||||
<div className="flex items-center space-x-3">
|
||||
@@ -408,7 +409,7 @@ export function PopularityRankings() {
|
||||
{totalPages > 1 && (
|
||||
<div className="text-center">
|
||||
<div className="text-sm text-gray-600">
|
||||
顯示第 {startIndex + 1}-{Math.min(endIndex, teamsWithScores.length)} 名,共 {teamsWithScores.length}{" "}
|
||||
顯示第 {startIndex + 1}-{Math.min(endIndex, teamsWithScores.filter(team => team && team.id).length)} 名,共 {teamsWithScores.filter(team => team && team.id).length}{" "}
|
||||
個團隊
|
||||
</div>
|
||||
<div className="flex justify-center items-center space-x-2 mt-2">
|
||||
@@ -638,7 +639,7 @@ export function PopularityRankings() {
|
||||
<Users className="w-4 h-4 text-gray-500" />
|
||||
<span className="text-sm">
|
||||
{currentCompetition.type === 'team'
|
||||
? `${competitionTeams.length} 個參賽團隊`
|
||||
? `${competitionTeams.filter(team => team && team.id).length} 個參賽團隊`
|
||||
: `${filteredApps.length} 個參賽應用`}
|
||||
</span>
|
||||
</div>
|
||||
|
@@ -1727,16 +1727,15 @@ export class CompetitionService extends DatabaseServiceBase {
|
||||
ct.registered_at,
|
||||
u.name as leader_name,
|
||||
u.phone as leader_phone,
|
||||
COUNT(tm.id) as actual_member_count,
|
||||
a.id as app_id,
|
||||
a.name as app_name
|
||||
COUNT(DISTINCT tm.id) as actual_member_count,
|
||||
COUNT(DISTINCT a.id) as app_count
|
||||
FROM competition_teams ct
|
||||
JOIN teams t ON ct.team_id = t.id
|
||||
LEFT JOIN users u ON t.leader_id = u.id
|
||||
LEFT JOIN team_members tm ON t.id = tm.team_id
|
||||
LEFT JOIN apps a ON t.id = a.team_id AND a.is_active = 1
|
||||
WHERE ct.competition_id = ? AND t.is_active = 1
|
||||
GROUP BY t.id, ct.registered_at, u.name, u.phone, a.id, a.name
|
||||
GROUP BY t.id, t.name, t.leader_id, t.department, t.contact_email, t.total_likes, t.is_active, t.created_at, t.updated_at, ct.registered_at, u.name, u.phone
|
||||
ORDER BY ct.registered_at ASC
|
||||
`;
|
||||
return await DatabaseServiceBase.safeQuery(sql, [competitionId]);
|
||||
|
Reference in New Issue
Block a user