Skip to content

Commit e1bb0d7

Browse files
authored
Merge pull request #95 from yoshi389111/release-0.8.0
Release 0.8.0
2 parents ff7baa4 + 28ff0b2 commit e1bb0d7

File tree

4 files changed

+141
-59
lines changed

4 files changed

+141
-59
lines changed

CHANGE_LOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## xxxx-xx-xx, 0.8.0 release
3+
## 2025-03-09, 0.8.0 release
44

55
* Added environment variable `GITHUB_ENDPOINT`.
66
* Added environment variable `YEAR`.

dist/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,17 +1350,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13501350
Object.defineProperty(exports, "__esModule", ({ value: true }));
13511351
exports.fetchData = exports.fetchNext = exports.fetchFirst = exports.URL = void 0;
13521352
const axios_1 = __importDefault(__nccwpck_require__(87269));
1353-
exports.URL = 'https://api.github.com/graphql';
1353+
exports.URL = process.env.GITHUB_ENDPOINT || 'https://api.github.com/graphql';
13541354
const maxReposOneQuery = 100;
1355-
const fetchFirst = async (token, userName) => {
1355+
const fetchFirst = async (token, userName, year = null) => {
1356+
const yearArgs = year
1357+
? `(from:"${year}-01-01T00:00:00.000Z", to:"${year}-12-31T23:59:59.000Z")`
1358+
: '';
13561359
const headers = {
13571360
Authorization: `bearer ${token}`,
13581361
};
13591362
const request = {
13601363
query: `
13611364
query($login: String!) {
13621365
user(login: $login) {
1363-
contributionsCollection {
1366+
contributionsCollection${yearArgs} {
13641367
contributionCalendar {
13651368
isHalloween
13661369
totalContributions
@@ -1441,8 +1444,8 @@ const fetchNext = async (token, userName, cursor) => {
14411444
};
14421445
exports.fetchNext = fetchNext;
14431446
/** Fetch data from GitHub GraphQL */
1444-
const fetchData = async (token, userName, maxRepos) => {
1445-
const res1 = await (0, exports.fetchFirst)(token, userName);
1447+
const fetchData = async (token, userName, maxRepos, year = null) => {
1448+
const res1 = await (0, exports.fetchFirst)(token, userName, year);
14461449
const result = res1.data;
14471450
if (result && result.user.repositories.nodes.length === maxReposOneQuery) {
14481451
const repos1 = result.user.repositories;
@@ -1525,7 +1528,12 @@ const main = async () => {
15251528
core.setFailed('MAX_REPOS is NaN');
15261529
return;
15271530
}
1528-
const response = await client.fetchData(token, userName, maxRepos);
1531+
const year = process.env.YEAR ? Number(process.env.YEAR) : null;
1532+
if (Number.isNaN(year)) {
1533+
core.setFailed('YEAR is NaN');
1534+
return;
1535+
}
1536+
const response = await client.fetchData(token, userName, maxRepos, year);
15291537
const userInfo = aggregate.aggregateUserInfo(response);
15301538
if (process.env.SETTING_JSON) {
15311539
const settingFile = r.readSettingJson(process.env.SETTING_JSON);

0 commit comments

Comments
 (0)