fix(CodeFeed): Fixed timestamp initialization and commit fetching timeframe

This commit is contained in:
Philipp Kunz 2024-12-16 22:46:59 +01:00
parent a43114ab61
commit b59bd82685
3 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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.'
}

View File

@ -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<plugins.interfaces.ICommit[]> {
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;