Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Меняет запрос к API на запрос к подготовленному файлу #1253

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ interviews

# кеш для @11ty/eleventy-cache-assets
.cache
.issues.json

.env
294 changes: 0 additions & 294 deletions src/libs/github-contribution-service/github-contribution-service.js

This file was deleted.

35 changes: 35 additions & 0 deletions src/libs/github-contribution-stats/github-contribution-stats.js
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,
}
21 changes: 7 additions & 14 deletions src/views/person.11tydata.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,14 @@ module.exports = {
},

badgesFields: function (data) {
const { authorData } = data

if (!authorData) {
return null
const { contributionStat } = data
const releaseDate = new Date('2021-10-12T00:00:00Z')
const theFirstDate = new Date('1970-01-01T00:00:00Z')
let pullRequestDate = releaseDate
if (contributionStat && !contributionStat['first'] === theFirstDate) {
pullRequestDate = contributionStat
}

const nodes = authorData?.contributionActions?.people?.target?.history?.nodes

const prNodes = nodes && nodes.length > 0 ? nodes[nodes.length - 1]?.associatedPullRequests?.nodes : null

const pullRequestDate =
prNodes && prNodes.length > 0 ? prNodes[prNodes.length - 1]?.mergedAt : '2021-10-12T00:00:00Z'

// TODO: Решить вопрос с датой для участников: Игорь Коровченко, Ольга Алексашенко
const githubFirstContribution = new Date(pullRequestDate)
const githubFirstContribution = pullRequestDate
.toLocaleString('ru', {
year: 'numeric',
month: 'long',
Expand Down
Loading
Loading