Skip to content

Swarnendu0123/github-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-stats (GitHub Statistics)

Get all your github issues and pull-request in one place.

NPM Version NPM Downloads GitHub Repo size

NPM License GitHub Repo issues GitHub Repo pull requests

Contributors GitHub Repo stars GitHub Repo forks

Usefull Links:

Features:

  • getPulls(repoUrl) : Function Get all the pull requests of a repository
  • getIssues(repoUrl) : Function Get all the issues of a repository
  • getPulls(repoUrl, by) : Function Get all the pull requests of a repository created by a specific user
  • getIssues(repoUrl, by) : Function Get all the issues of a repository created by a specific user
  • by (Optional): The user who created the pull request/issue . If not provided, it will return all the pull requests.

Installation:

Npm:

    npm install @swarnendu0123/github-stats

Yarn:

    yarn add @swarnendu0123/github-stats

if you are using Typescript, you can install the types for node:

Npm:

    npm i --save-dev @types/node

Yarn:

    yarn add --dev @types/node

Usage:

Promise Syntax:

const stats = require("@swarnendu0123/github-stats");
stats
  .getIssues("https://github.com/oxiton-foundation/click-metrics")
  .then((data) => {
    console.log(data);
  });

Async/Await Syntax:

const stats = require("@swarnendu0123/github-stats");
const myPulls = await stats.getPulls(
  "https://github.com/oxiton-foundation/click-metrics"
);
console.log(myPulls);
const stats = require("@swarnendu0123/github-stats");
const myPulls = await stats.getPulls(
  "https://github.com/oxiton-foundation/click-metrics",
  "Swarnendu0123"
);
console.log(myPulls);

Output:

[
  {
    title: 'Example PR for checking. (Do not merge it or close it)',
    url: 'https://github.com/oxiton-foundation/click-metrics/pull/9',
    openedBy: 'Swarnendu0123',
    issueLabel: [ 'level 4', 'OOSI' ],
    status: 'open'
  },
  {
    title: 'MINOR CHANGES',
    url: 'https://github.com/oxiton-foundation/click-metrics/pull/8',
    openedBy: 'Swarnendu0123',
    issueLabel: [],
    status: 'merged'
  }
]

Using in a react app:

import React, { useEffect, useState } from "react";
import { getIssues } from "@swarnendu0123/github-stats";

function MyComponent() {
  const [issues, setIssues] = useState([]);
  useEffect(() => {
    getIssues("https://github.com/oxiton-foundation/click-metrics").then(
      (data) => {
        setIssues(data);
      }
    );
  }, []);

  return (
    <div>
      {issues.map((index, issue) => (
        <div key={index}>
          <h1>{issue.title}</h1>
          <p>{issue.url}</p>
          <p>{issue.openedBy}</p>
          <p>
            {issue.issueLabel.map((label) => (
              <span>{label}</span>
            ))}
          </p>
          <p>{issue.status}</p>
        </div>
      ))}
    </div>
  );
}

export default MyComponent;

Keywords:

github-stats github stats issues pulls github-issues github-pulls github-stats github-api github-issues-api github-pulls-api github-stats-api github-issues-pulls github-issues-pulls-stats github-issues-pulls-stats-api github-issues-pulls-stats-npm github-issues-pulls-stats-npm-package github-issues-pulls-stats-npm-package-api