83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
|
|
import { mockData } from './src/data/mockData.js';
|
||
|
|
|
||
|
|
// 检查日历事件中的重复
|
||
|
|
const events = mockData.calendarEvents;
|
||
|
|
|
||
|
|
// 按日期分组
|
||
|
|
const dateMap = {};
|
||
|
|
|
||
|
|
events.forEach((event, index) => {
|
||
|
|
// 提取日期部分
|
||
|
|
const dateMatch = event.startTime?.match(/^(\d{4}-\d{2}-\d{2})/);
|
||
|
|
const date = dateMatch ? dateMatch[1] : 'unknown';
|
||
|
|
|
||
|
|
if (!dateMap[date]) {
|
||
|
|
dateMap[date] = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
// 只关注AI课程和营销能力课
|
||
|
|
if (event.type === 'ai-course' || event.type === 'marketing-course') {
|
||
|
|
dateMap[date].push({
|
||
|
|
index: index,
|
||
|
|
type: event.type,
|
||
|
|
title: event.title,
|
||
|
|
teacher: event.teacher,
|
||
|
|
time: event.startTime + ' - ' + event.endTime
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('检查AI课程(ai-course)和营销能力课(marketing-course)的重复:\n');
|
||
|
|
|
||
|
|
let duplicatesFound = false;
|
||
|
|
|
||
|
|
// 查找同一天有多个同类型课程的情况
|
||
|
|
Object.keys(dateMap).sort().forEach(date => {
|
||
|
|
const courses = dateMap[date];
|
||
|
|
|
||
|
|
// 按类型分组
|
||
|
|
const typeGroups = {};
|
||
|
|
courses.forEach(course => {
|
||
|
|
if (!typeGroups[course.type]) {
|
||
|
|
typeGroups[course.type] = [];
|
||
|
|
}
|
||
|
|
typeGroups[course.type].push(course);
|
||
|
|
});
|
||
|
|
|
||
|
|
// 检查是否有重复
|
||
|
|
Object.keys(typeGroups).forEach(type => {
|
||
|
|
if (typeGroups[type].length > 1) {
|
||
|
|
duplicatesFound = true;
|
||
|
|
console.log(`日期: ${date}`);
|
||
|
|
console.log(` 类型: ${type} (出现${typeGroups[type].length}次)`);
|
||
|
|
typeGroups[type].forEach(course => {
|
||
|
|
console.log(` [索引${course.index}] ${course.title} - ${course.teacher}`);
|
||
|
|
});
|
||
|
|
console.log('');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
if (!duplicatesFound) {
|
||
|
|
console.log('没有发现同一天有重复的AI课程或营销能力课\n');
|
||
|
|
}
|
||
|
|
|
||
|
|
// 统计总数
|
||
|
|
const aiCourses = events.filter(e => e.type === 'ai-course');
|
||
|
|
const marketingCourses = events.filter(e => e.type === 'marketing-course');
|
||
|
|
|
||
|
|
console.log('统计信息:');
|
||
|
|
console.log(`AI课程(ai-course)总数: ${aiCourses.length}`);
|
||
|
|
console.log(`营销能力课(marketing-course)总数: ${marketingCourses.length}`);
|
||
|
|
console.log(`日历事件总数: ${events.length}`);
|
||
|
|
|
||
|
|
// 显示前几个AI课程和营销能力课
|
||
|
|
console.log('\n前5个AI课程:');
|
||
|
|
aiCourses.slice(0, 5).forEach((course, i) => {
|
||
|
|
console.log(` ${i+1}. ${course.title} - ${course.startTime?.split(' ')[0]}`);
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('\n前5个营销能力课:');
|
||
|
|
marketingCourses.slice(0, 5).forEach((course, i) => {
|
||
|
|
console.log(` ${i+1}. ${course.title} - ${course.startTime?.split(' ')[0]}`);
|
||
|
|
});
|