()
| 550 | } |
| 551 | |
| 552 | generateStats() { |
| 553 | console.log('\n📊 CSS-Inspiration Statistics:'); |
| 554 | |
| 555 | this.db.all(` |
| 556 | SELECT |
| 557 | category, |
| 558 | COUNT(*) as count, |
| 559 | difficulty_level |
| 560 | FROM css_inspiration |
| 561 | GROUP BY category, difficulty_level |
| 562 | ORDER BY category, difficulty_level |
| 563 | `, (err, rows) => { |
| 564 | if (err) { |
| 565 | console.error('Error generating stats:', err); |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | const stats = {}; |
| 570 | rows.forEach(row => { |
| 571 | if (!stats[row.category]) { |
| 572 | stats[row.category] = {}; |
| 573 | } |
| 574 | stats[row.category][row.difficulty_level] = row.count; |
| 575 | }); |
| 576 | |
| 577 | Object.entries(stats).forEach(([category, difficulties]) => { |
| 578 | const total = Object.values(difficulties).reduce((sum, count) => sum + count, 0); |
| 579 | console.log(` ${this.categoryMapping[category] || category}: ${total} 个案例`); |
| 580 | Object.entries(difficulties).forEach(([level, count]) => { |
| 581 | console.log(` - ${level}: ${count} 个`); |
| 582 | }); |
| 583 | }); |
| 584 | |
| 585 | // 总体统计 |
| 586 | this.db.get('SELECT COUNT(*) as total FROM css_inspiration', (err, row) => { |
| 587 | if (!err && row) { |
| 588 | console.log(`\n 📈 总计: ${row.total} 个 CSS 演示案例`); |
| 589 | } |
| 590 | |
| 591 | console.log('\n🎉 CSS-Inspiration 数据导入完成!'); |
| 592 | process.exit(0); |
| 593 | }); |
| 594 | }); |
| 595 | } |
| 596 | |
| 597 | close() { |
| 598 | this.db.close(); |
no test coverage detected