Compare commits

..

No commits in common. "af0601b1c4b4a2711198cfba1f37ffd2f4e2d12c" and "1dbfc7696954d5feb4ed428fcc02c04c03fd51ae" have entirely different histories.

2 changed files with 4 additions and 53 deletions

@ -1 +1 @@
Subproject commit 6ab7939676e2ef9bb9ab07089e99b815023e92af
Subproject commit 0c38e33cc1920bd577c2d84a417a18690f1eda53

View File

@ -2021,53 +2021,6 @@ ${excerpt}
}
});
// GET /chronicle/activity — GitHub push イベントから期間内のコミット一覧を返す
r.get('/chronicle/activity', authMiddleware, async (req, res) => {
const token = process.env.CHRONICLE_GITHUB_TOKEN || '';
if (!token) return res.status(503).json({ error: 'CHRONICLE_GITHUB_TOKEN not configured' });
const daysNum = Math.min(Math.max(parseInt(req.query.days) || 7, 1), 30);
const since = new Date(Date.now() - daysNum * 86400000);
try {
const ghHeaders = {
'Authorization': `Bearer ${token}`,
'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
'User-Agent': 'posimai-chronicle/1.0'
};
const eventsResp = await fetch(
'https://api.github.com/orgs/posimai/events?per_page=100',
{ headers: ghHeaders }
);
if (!eventsResp.ok) throw new Error(`GitHub API ${eventsResp.status}`);
const events = await eventsResp.json();
const commits = [];
const repos = new Set();
for (const ev of events) {
if (ev.type !== 'PushEvent') continue;
if (new Date(ev.created_at) < since) continue;
const repoName = ev.repo.name.replace('posimai/', '');
repos.add(repoName);
for (const c of ev.payload?.commits || []) {
const msg = c.message.split('\n')[0];
if (/^Merge\b/i.test(msg)) continue;
commits.push({ repo: repoName, message: msg, date: ev.created_at });
}
}
res.json({ commits, repos: [...repos], since: since.toISOString() });
} catch (e) {
console.error('[chronicle/activity]', e.message);
res.status(500).json({ error: e.message });
}
});
r.post('/journal/upload', authMiddleware, (req, res) => {
try {
const { base64 } = req.body || {};
@ -2724,11 +2677,9 @@ ${excerpt}
}
}
// summary が取れなかった場合は failed にするdone+nullのまま再試行不能になるのを防ぐ
const finalStatus = summary ? 'done' : 'failed';
await pool.query(
`UPDATE together_shares SET summary=$1, tags=$2, archive_status=$3 WHERE id=$4`,
[summary || null, tags, finalStatus, shareId]
`UPDATE together_shares SET summary=$1, tags=$2, archive_status='done' WHERE id=$3`,
[summary, tags, shareId]
);
} catch (e) {
console.error('[together archive]', shareId, e.message);
@ -2779,7 +2730,7 @@ ${excerpt}
}
}
if (!rearchiveDone) {
await pool.query(`UPDATE together_shares SET archive_status='failed' WHERE id=$1`, [shareId]);
await pool.query(`UPDATE together_shares SET archive_status='done' WHERE id=$1`, [shareId]);
}
} else {
// failed / skipped — フル再アーカイブ