From b59bd826851f94d7d8995fa36c337266815ec003 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 16 Dec 2024 22:46:59 +0100 Subject: [PATCH] fix(CodeFeed): Fixed timestamp initialization and commit fetching timeframe --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/index.ts | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index e2edd60..725ef2a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-12-16 - 1.6.5 - fix(CodeFeed) +Fixed timestamp initialization and commit fetching timeframe + +- Updated the lastRunTimestamp initialization default period from 24 hours to 7 days in CodeFeed constructor. +- Modified commit fetching logic to consider commits from the last 7 days instead of 24 hours in fetchRecentCommitsForRepo. + ## 2024-12-14 - 1.6.4 - fix(core) Refactor fetch logic to use a unified fetchFunction for API calls diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 2d8c105..cbec873 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@foss.global/codefeed', - version: '1.6.4', + version: '1.6.5', description: 'The @foss.global/codefeed module is designed for generating feeds from Gitea repositories, enhancing development workflows by processing commit data and repository activities.' } diff --git a/ts/index.ts b/ts/index.ts index 0a330f5..d9896a8 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -12,7 +12,7 @@ export class CodeFeed { this.baseUrl = baseUrl; this.token = token; this.lastRunTimestamp = - lastRunTimestamp || new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(); + lastRunTimestamp || new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(); console.log('CodeFeed initialized with last run timestamp:', this.lastRunTimestamp); } @@ -198,7 +198,7 @@ export class CodeFeed { owner: string, repo: string ): Promise { - const twentyFourHoursAgo = new Date(Date.now() - 24 * 60 * 60 * 1000); + const commitTimeframe = new Date(Date.now() - (7 * 24 * 60 * 60 * 1000)); let page = 1; const recentCommits: plugins.interfaces.ICommit[] = []; @@ -223,7 +223,7 @@ export class CodeFeed { for (const commit of data) { const commitDate = new Date(commit.commit.author.date); - if (commitDate > twentyFourHoursAgo) { + if (commitDate > commitTimeframe) { recentCommits.push(commit); } else { return recentCommits;