// 检查所有参赛人的学历数据
|
const axios = require('axios');
|
|
async function checkAllEducationData() {
|
try {
|
console.log('=== 检查所有参赛人的学历数据 ===');
|
|
// 查询所有参赛人
|
const listQuery = `
|
query {
|
activityPlayerApplications(page: 1, size: 50) {
|
content {
|
id
|
playerName
|
projectName
|
}
|
totalElements
|
}
|
}
|
`;
|
|
const listResponse = await axios.post('http://localhost:8080/api/graphql', {
|
query: listQuery
|
}, {
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
});
|
|
if (listResponse.data.errors) {
|
console.log('查询错误:', listResponse.data.errors);
|
return;
|
}
|
|
const applications = listResponse.data.data?.activityPlayerApplications?.content || [];
|
const total = listResponse.data.data?.activityPlayerApplications?.totalElements || 0;
|
|
console.log(`总共找到 ${total} 个参赛人,开始检查学历数据...`);
|
|
let educationStats = {
|
total: 0,
|
hasEducation: 0,
|
noEducation: 0,
|
educationTypes: {}
|
};
|
|
// 检查每个参赛人的学历
|
for (let i = 0; i < applications.length; i++) {
|
const app = applications[i];
|
|
// 查询详情
|
const detailQuery = `
|
query GetActivityPlayerDetail($id: ID!) {
|
activityPlayerDetail(id: $id) {
|
id
|
playerInfo {
|
name
|
education
|
}
|
}
|
}
|
`;
|
|
try {
|
const detailResponse = await axios.post('http://localhost:8080/api/graphql', {
|
query: detailQuery,
|
variables: { id: app.id }
|
}, {
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
});
|
|
if (detailResponse.data.errors) {
|
console.log(`参赛人 ${app.id} 查询错误:`, detailResponse.data.errors);
|
continue;
|
}
|
|
const detail = detailResponse.data.data?.activityPlayerDetail;
|
if (!detail) {
|
console.log(`参赛人 ${app.id} 未找到详情`);
|
continue;
|
}
|
|
educationStats.total++;
|
const education = detail.playerInfo.education || '';
|
|
if (education && education.trim()) {
|
educationStats.hasEducation++;
|
if (educationStats.educationTypes[education]) {
|
educationStats.educationTypes[education]++;
|
} else {
|
educationStats.educationTypes[education] = 1;
|
}
|
|
console.log(`✅ 参赛人 ${detail.playerInfo.name} (ID: ${app.id}) 有学历: "${education}"`);
|
} else {
|
educationStats.noEducation++;
|
console.log(`❌ 参赛人 ${detail.playerInfo.name} (ID: ${app.id}) 学历为空`);
|
}
|
|
} catch (error) {
|
console.log(`参赛人 ${app.id} 查询失败:`, error.message);
|
}
|
}
|
|
console.log('\n=== 学历数据统计 ===');
|
console.log(`总参赛人数: ${educationStats.total}`);
|
console.log(`有学历数据: ${educationStats.hasEducation}`);
|
console.log(`无学历数据: ${educationStats.noEducation}`);
|
|
if (educationStats.hasEducation > 0) {
|
console.log('\n学历分布:');
|
Object.entries(educationStats.educationTypes).forEach(([education, count]) => {
|
console.log(` ${education}: ${count} 人`);
|
});
|
} else {
|
console.log('\n❌ 所有参赛人都没有学历数据!');
|
console.log('可能的原因:');
|
console.log('1. 用户在注册时确实没有选择学历');
|
console.log('2. 注册表单的学历字段有问题');
|
console.log('3. 数据提交时学历字段丢失');
|
console.log('4. 数据库存储时有问题');
|
}
|
|
} catch (error) {
|
console.error('检查失败:', error.message);
|
}
|
}
|
|
checkAllEducationData();
|