-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Меняет запрос к API на запрос к подготовленному файлу (#1253)
* Добавляет исключение для файла со статистикой * Удаляет сервис для работы с API GitHub * Внедреяет сервис для формирования статистики
- Loading branch information
Showing
5 changed files
with
46 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,6 @@ interviews | |
|
||
# кеш для @11ty/eleventy-cache-assets | ||
.cache | ||
.issues.json | ||
|
||
.env |
294 changes: 0 additions & 294 deletions
294
src/libs/github-contribution-service/github-contribution-service.js
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/libs/github-contribution-stats/github-contribution-stats.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const issues = require('../../../.issues.json') | ||
|
||
const stats = issues.reduce((result, issue) => { | ||
const user = issue['user']['login'].toLowerCase() | ||
const isPullRequest = 'pull_request' in issue | ||
const pullRequestIncrement = isPullRequest ? 1 : 0 | ||
const issueIncrement = !isPullRequest ? 1 : 0 | ||
const pullRequestDate = isPullRequest ? new Date(issue['closed_at']) : new Date() | ||
|
||
if (result && user in result) { | ||
result[user]['issues'] += issueIncrement | ||
result[user]['pr'] += pullRequestIncrement | ||
if (result[user]['first'] > pullRequestDate) { | ||
result[user]['first'] = pullRequestDate | ||
} | ||
return result | ||
} else { | ||
return { | ||
...result, | ||
[user]: { | ||
issues: issueIncrement, | ||
pr: pullRequestIncrement, | ||
first: pullRequestDate, | ||
}, | ||
} | ||
} | ||
}, {}) | ||
|
||
function getAuthorContributionStats() { | ||
return stats | ||
} | ||
|
||
module.exports = { | ||
getAuthorContributionStats, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.