@@ -1350,17 +1350,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1350
1350
Object.defineProperty(exports, "__esModule", ({ value: true }));
1351
1351
exports.fetchData = exports.fetchNext = exports.fetchFirst = exports.URL = void 0;
1352
1352
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';
1354
1354
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
+ : '';
1356
1359
const headers = {
1357
1360
Authorization: `bearer ${token}`,
1358
1361
};
1359
1362
const request = {
1360
1363
query: `
1361
1364
query($login: String!) {
1362
1365
user(login: $login) {
1363
- contributionsCollection {
1366
+ contributionsCollection${yearArgs} {
1364
1367
contributionCalendar {
1365
1368
isHalloween
1366
1369
totalContributions
@@ -1441,8 +1444,8 @@ const fetchNext = async (token, userName, cursor) => {
1441
1444
};
1442
1445
exports.fetchNext = fetchNext;
1443
1446
/** 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 );
1446
1449
const result = res1.data;
1447
1450
if (result && result.user.repositories.nodes.length === maxReposOneQuery) {
1448
1451
const repos1 = result.user.repositories;
@@ -1525,7 +1528,12 @@ const main = async () => {
1525
1528
core.setFailed('MAX_REPOS is NaN');
1526
1529
return;
1527
1530
}
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);
1529
1537
const userInfo = aggregate.aggregateUserInfo(response);
1530
1538
if (process.env.SETTING_JSON) {
1531
1539
const settingFile = r.readSettingJson(process.env.SETTING_JSON);
0 commit comments