Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nick22985/Dev-Stats
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ecc0af2a80c98541f2dbe6d7c4a2997b12e87786
Choose a base ref
..
head repository: nick22985/Dev-Stats
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 28b0664823ed65b2fa62de3fb407dbbb4cfaf34c
Choose a head ref
Showing with 287 additions and 307 deletions.
  1. +1 −1 .github/workflows/main.yml
  2. +5 −5 index.js
  3. +1 −2 lib/fomratting.js
  4. +3 −7 lib/github.js
  5. +270 −285 package-lock.json
  6. +7 −7 package.json
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: "16.10.0"
node-version: "20.12.2"
cache: "npm"
- run: npm ci
- run: npm run start --if-present
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as dotenv from "dotenv";
import chalk from "chalk";

import { DateTime, Settings } from "luxon"; // Not needed maybe?
import { getWakaStats } from "./lib/waka.js";
import { getGithubStats, updateReadme } from "./lib/github.js";

import chalk from "chalk";
import { formatDoc } from "./lib/fomratting.js";
import { getWakaStats } from "./lib/waka.js";
import { stringify } from "querystring";

dotenv.config();
@@ -41,16 +43,14 @@ async function start() {
try {
if (wakatime_api_key == undefined) throw "No WakaTime Api Key Provided";
if (gh_token == undefined) throw "No Github Token Provided";
console.log("start");
console.log(chalk.white.bold("WakaStats"));
devStats.wakatime = await getWakaStats(wakatime_api_key);
console.log("Github Stats");
devStats.github = await getGithubStats(devStats.wakatime.timezone, gh_token);
console.log("Api Calls Completed");
Settings.defaultZoneName = devStats.wakatime.timezone;
devStats.currentDate = DateTime.local();
if (settings.excludeProjects) {
settings.excludeProjects = settings.excludeProjects.split(", ");
settings.excludeProjects = settings.excludeProjects.map((project) => project.toLowerCase());
}
let formatted = await formatDoc(devStats, settings);
console.log(formatted);
3 changes: 1 addition & 2 deletions lib/fomratting.js
Original file line number Diff line number Diff line change
@@ -110,10 +110,9 @@ async function formatDoc(devStats, settings) {
if (settings.showProjects) {
document += `\n📚 **Projects**:\n\`\`\`text\n`;
if (settings.excludeProjects) {
console.log(devStats.wakatime.projects)
devStats.wakatime.projects = devStats.wakatime.projects.map((project) => {
if(project) {
settings.excludeProjects.includes(project.name) ? project.name = process.env.EXLUDE_PROJECT_NAME ? process.env.EXLUDE_PROJECT_NAME : '' : project.name;
settings.excludeProjects.includes(project.name.toLowerCase()) ? project.name = process.env.EXLUDE_PROJECT_NAME ? process.env.EXLUDE_PROJECT_NAME : '' : project.name;
return project;
}
});
10 changes: 3 additions & 7 deletions lib/github.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Base64 } from 'js-base64';
import { DateTime } from 'luxon';
import fetch from 'node-fetch';
import _ from 'lodash';
import { Octokit } from '@octokit/rest';
import { Base64 } from 'js-base64';
import _ from 'lodash';
import fetch from 'node-fetch';

export { getGithubStats, updateReadme };

@@ -107,7 +107,6 @@ async function getContributedRepos(gh_token, userInfo, timezone) {
let currentRepo = repoContributed.data.user.repositoriesContributedTo.nodes[repo];
try {
await graphQLQuery(gh_token, getCommittedDataQuery, { owner: currentRepo.owner.login, name: currentRepo.name, id: userInfo.id }).then((data) => {
console.log(data);
let committedDates = data.data.repository.defaultBranchRef?.target?.history?.edges;
for (const date in committedDates) {
let currentDate = committedDates[date].node.committedDate;
@@ -155,11 +154,9 @@ async function getContributedRepos(gh_token, userInfo, timezone) {
}
});
} catch (e) {
console.log(e);
}
}
} catch (e) {
console.log(e);
}
let temp1 = maxValueObject(timeData.time, timeData.totalContributions);
timeData.biggestTime = temp1.max;
@@ -205,7 +202,6 @@ async function graphQLQuery(gh_token, query, variables) {
// if (res.status == 200) return await res.json();
// else throw `Query failed ${res.status_code}, ${query}`;
} catch (e) {
console.log(e);
}
}

Loading