Projektarten: Zuordnungs-Mail auch ohne vorherigen Versuch nachholen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1f1ffb5275
commit
d3c6858ecc
2 files changed
+20
-2
No files matched your search
@@ -101,6 +101,9 @@ export async function runRepoAssignJob({
|
||||
if (isOrgOwner(repo)) continue
|
||||
const login = repo.owner?.login || ''
|
||||
if (!login) continue
|
||||
// Alte Repos (>= 24 h) bekommen keinen Ersteller: sie werden nie gemailt und nie erinnert.
|
||||
const age = now.getTime() - new Date(repo.created_at || 0).getTime()
|
||||
if (!(age < 24 * 3600_000)) continue
|
||||
handled.add(projectId)
|
||||
await updateDocument(collection(), projectId, { createdByGitea: login })
|
||||
const r = await sendFirstMailIfDue(projectId, repo, login, { now, createdNow: true, sendMail })
|
||||
@@ -110,9 +113,9 @@ export async function runRepoAssignJob({
|
||||
const docs = await listDocuments(collection(), [Query.limit(5000)])
|
||||
for (const p of docs) {
|
||||
if (!p.createdByGitea || p.kind || handled.has(p.$id)) continue
|
||||
// Wiederholung: erste Mail fehlgeschlagen (1-2 Versuche), Repo noch juenger als 24 h.
|
||||
// Wiederholung/Nachholen: erste Mail noch nicht raus (0-2 Versuche), Repo noch juenger als 24 h.
|
||||
const attempts = Number(p.assignMailAttempts || 0)
|
||||
if (!p.assignMailSentAt && attempts > 0 && attempts < 3) {
|
||||
if (!p.assignMailSentAt && attempts < 3) {
|
||||
let repo
|
||||
try {
|
||||
repo = await fetchRepo(p.repoFullName)
|
||||
|
||||
@@ -105,6 +105,21 @@ test('Job: 20 alte Repos → 0 Mails', async () => {
|
||||
assert.equal(c.imported, 20)
|
||||
assert.equal(c.mails, 0)
|
||||
assert.equal(sink.sent.length, 0)
|
||||
assert.ok(!docsOf('knso/alt0')[0].createdByGitea, 'alte Repos bekommen kein createdByGitea')
|
||||
})
|
||||
|
||||
test('Job: Mail ohne vorherigen Versuch wird nachgeholt (createdByGitea, 0 Versuche)', async () => {
|
||||
freshSink()
|
||||
gitea.addRepo({ full_name: 'knso/nachholen', created_at: ago(2) })
|
||||
await runRepoAssignJob({ now: NOW })
|
||||
const [doc] = docsOf('knso/nachholen')
|
||||
// Lauf abgebrochen, bevor die erste Mail versucht wurde
|
||||
aw.all('websiteProjects').find((d) => d.$id === doc.$id).assignMailSentAt = ''
|
||||
Object.assign(aw.all('websiteProjects').find((d) => d.$id === doc.$id), { assignMailAttempts: 0 })
|
||||
freshSink()
|
||||
const c = await runRepoAssignJob({ now: NOW })
|
||||
assert.equal(c.retries, 1)
|
||||
assert.equal(sink.sent.length, 1)
|
||||
})
|
||||
|
||||
test('Job: neues Nutzer-Repo → Mail, Org-Repo → keine Mail', async () => {
|
||||
|
||||
Reference in new issue
Block a user