MCPcopy Create free account
hub / github.com/chokcoco/iCSS / saveIssuesToDatabase

Method saveIssuesToDatabase

MCP/scripts/fetch-issues.js:541–612  ·  view source on GitHub ↗
(issues)

Source from the content-addressed store, hash-verified

539 }
540
541 async saveIssuesToDatabase(issues) {
542 console.log('💾 Saving and analyzing issues...');
543
544 const insertSQL = `
545 INSERT OR REPLACE INTO issues
546 (number, title, body, html_url, labels, created_at, updated_at, search_content)
547 VALUES (?, ?, ?, ?, ?, ?, ?, ?)
548 `;
549
550 let savedCount = 0;
551
552 for (const issue of issues) {
553 if (issue.pull_request) continue;
554
555 try {
556 const labels = Array.isArray(issue.labels)
557 ? JSON.stringify(issue.labels.map(label => typeof label === 'string' ? label : label.name))
558 : issue.labels;
559
560 const searchContent = this.createSearchContent(issue);
561
562 // 保存基本信息
563 await new Promise((resolve, reject) => {
564 this.db.run(
565 insertSQL,
566 [
567 issue.number,
568 issue.title,
569 issue.body || '',
570 issue.html_url,
571 labels,
572 issue.created_at,
573 issue.updated_at,
574 searchContent
575 ],
576 async function(err) {
577 if (err) {
578 console.error(`Error saving issue #${issue.number}:`, err);
579 reject(err);
580 } else {
581 try {
582 // 分析并保存标签信息
583 await this.analyzeArticleLabels(issue);
584 savedCount++;
585 resolve();
586 } catch (analysisErr) {
587 console.error(`Error analyzing issue #${issue.number}:`, analysisErr);
588 reject(analysisErr);
589 }
590 }
591 }.bind(this)
592 );
593 });
594
595 if (savedCount % 10 === 0) {
596 console.log(` 📝 Processed ${savedCount} articles...`);
597 }
598 } catch (error) {

Callers 1

fetchAllIssuesMethod · 0.95

Calls 6

createSearchContentMethod · 0.95
analyzeArticleLabelsMethod · 0.95
analyzeLabelRelationsMethod · 0.95
buildLabelHierarchyMethod · 0.95
runMethod · 0.45

Tested by

no test coverage detected