Giter Club home page Giter Club logo

community-js-stackoverflow-orbit's Introduction

⛔️ DEPRECATED: Stack Overflow to Orbit Workspace

This repository is no longer recommended or maintained and it will soon be marked as archived in Github. Huge thanks to the original authors and contributors for providing this Github Actions template to our community. To add Stack Overflow interactions to your Orbit workspace, you can now request access to the Stack Overflow integration under Workspace Settings > Integrations.


Build Status npm version Contributor Covenant

This is a JavaScript package that can be used to integrate Stack Overflow questions with a specified tag into your organization's Orbit workspace.

This is a community project. The Orbit team does its best to maintain it and keep it up to date with any recent API changes.

We welcome community contributions to make sure that it stays current.

There are three ways to use this integration. Install package - build and run your own applications. Run the CLI - run on-demand directly from your terminal. Schedule an automation with GitHub - get started in minutes - no coding required

First Time Setup

To set up this integration you will need some details from StackOverflow. During the setup, we will need to create a new application on Stack Apps which will allow this integration to interact with the platform. The application will contain a Key which we should take note of for later.

  1. Head to Stack Apps and login in to your account.
  2. Register a new Stack Apps application. The oauth domain can be anything, as can the application website.
  3. In your application settings, take note of your Key value.

Application Credentials

The application requires the following environment variables:

Variable Description More Info
STACK_APPS_KEY API Key to query Stack Overflow Follow the First Time Setup guide above
ORBIT_API_KEY API key for Orbit Found in Account Settings in your Orbit workspace
ORBIT_WORKSPACE_ID ID for your Orbit workspace Last part of the Orbit workspace URL, i.e. https://app.orbit.love/my-workspace, the ID is my-workspace

Installation

Install the package with the following command

$ npm install @orbit-love/stackoverflow

The standard initialization of the library requires the following signature:

const OrbitStackOverflow = require('@orbit-love/stackoverflow')
const orbitStackOverflow = new OrbitStackOverflow('orbitWorkspaceId', 'orbitApiKey', 'stackAppsKey')

If you have the following environment variables set: ORBIT_WORKSPACE_ID, ORBIT_API_KEY, and STACK_APPS_KEY then you can initialize the client as follows:

const OrbitStackOverflow = require('@orbit-love/stackoverflow')
const orbitStackOverflow = new OrbitStackOverflow()

Questions

// Allows you to go back a number of hours and only get questions in that timeframe
const questions = await orbitStackOverflow.getQuestions({ tag: 'tag-1', hours: 24 })
const prepared = await orbitStackOverflow.prepareQuestions(questions)
const summary = await orbitStackOverflow.addActivities(prepared)
console.log(summary)

prepareQuestions()

There are several options when calling the prepareQuestions() method. The default is 'orbitActivity'.

// Returns question list as Orbit activity objects
await orbitStackOverflow.prepareQuestions(questions, 'orbitActivity')

// Returns questions that have at least one answer
await orbitStackOverflow.prepareQuestions(questions, 'hasAnswer')

// Returns questions with recent activity
await orbitStackOverflow.prepareQuestions(questions, 'recentActivity', { hours: 24 })

// Returns questions that are new within a number of hours - useful for post-fetching filtering
await orbitStackOverflow.prepareQuestions(questions, 'postedWithinHours', { hours: 24 })

// Returns an array of question IDs only
await orbitStackOverflow.prepareQuestions(questions, 'onlyIds')

Answers

const questionIds = [123, 456, 789]
const answers = await orbitStackOverflow.getAnswers({ ids: questionIds, hours: 24 })
const prepared = await orbitStackOverflow.prepareAnswers(questions)
const summary = await orbitStackOverflow.addActivities(prepared)
console.log(summary)

CLI Usage

To use this package you do not need to install it, but will need Node.js installed on your machine.

To use the CLI you must have the following environment variables set: ORBIT_WORKSPACE_ID, ORBIT_API_KEY, and STACK_APPS_KEY.

npx @orbit-love/stackoverflow [FLAGS]

Questions

npx @orbit-love/stackoverflow --questions --tag=tag-1 [--hours=12]
  • --hours is optional and defaults to 24.

Answers

npx @orbit-love/stackoverflow --answers --tag=tag-1 [--hours=12]
  • --hours is optional and defaults to 24.
  • This will only get answers on questions posted in the last 28 days.

Questions & Answers

npx @orbit-love/stackoverflow --questions --answers --tag=tag-1 [--hours=12]
  • --hours is optional and defaults to 24.
  • This will only get answers on questions posted in the last 28 days.

GitHub Actions Automation Setup

⚡ You can set up this integration in a matter of minutes using our GitHub Actions template. It will run regularly to add new activities to your Orbit workspace. All you need is a GitHub account.

See our guide for setting up this automation.

Contributing

We 💜 contributions from everyone! Check out the Contributing Guidelines for more information.

License

This project is under the MIT License.

Code of Conduct

This project uses the Contributor Code of Conduct. We ask everyone to please adhere by its guidelines.

community-js-stackoverflow-orbit's People

Contributors

dependabot[bot] avatar hummusonrails avatar mxdavis avatar phacks avatar phazonoverload avatar sindbach avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.