Skip to content

Commit 7ba6632

Browse files
committed
fix releases bug
1 parent 19a6571 commit 7ba6632

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/bot.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const {getVersions} = require('./github-client');
66

77
const API_TOKEN = config.telegram.token || '';
88

9+
const PREVIEW_RELEASES_COUNT = -10;
10+
const FIRST_UPDATE_RELEASES_COUNT = 20;
11+
912
const about = `
1013
Bot to notify you about new releases in the repositories that you add to the subscription. New releases are checked every ${config.app.updateInterval / 60} minutes.
1114
@@ -211,7 +214,7 @@ class Bot {
211214

212215
if (!hasRepoInDB) {
213216
try {
214-
const releases = await getVersions(repo.owner, repo.name, 20);
217+
const releases = await getVersions(repo.owner, repo.name, FIRST_UPDATE_RELEASES_COUNT);
215218

216219
await this.db.addRepo(repo.owner, repo.name);
217220
await this.db.updateRepo(repo.owner, repo.name, releases);
@@ -326,7 +329,7 @@ class Bot {
326329
keyboards.table(
327330
`getReleases:one`,
328331
`getReleases:one:${index}:release`,
329-
repo.releases.slice(-10).map(({name, isPrerelease}) => `${name}${isPrerelease ? ' (pre-release)' : ''}`)
332+
repo.releases.slice(PREVIEW_RELEASES_COUNT).map(({name, isPrerelease}) => `${name}${isPrerelease ? ' (pre-release)' : ''}`)
330333
)
331334
)
332335
}
@@ -349,7 +352,7 @@ class Bot {
349352

350353
return this.sendReleases(
351354
null,
352-
[Object.assign(repo, {releases: [repo.releases[releaseIndex]]})],
355+
[Object.assign(repo, {releases: [repo.releases.slice(PREVIEW_RELEASES_COUNT)[releaseIndex]]})],
353356
ctx.replyWithMarkdown
354357
);
355358
}

0 commit comments

Comments
 (0)