Giter Site home page Giter Site logo

ibm-cloud / github-traffic-stats Goto Github PK

View Code? Open in Web Editor NEW
32.0 6.0 14.0 1.34 MB

Manage and automatically collect Github traffic statistics for repositories

Home Page: https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-serverless-github-traffic-analytics

License: Apache License 2.0

Python 40.41% HTML 30.00% JavaScript 8.36% CSS 20.92% Dockerfile 0.31%
github-traffic db2 python ibm-cloud ibm-cloud-functions flask flask-sqlalchemy openid-connect ibm-cloud-solutions code-engine

github-traffic-stats's Introduction

Github Traffic Analytics: Combining serverless web app and eventing

This repository contains code based on this IBM Cloud solution tutorial. In the tutorial, we create an application to automatically collect Github traffic statistics for repositories and provide the foundation for traffic analytics. Github only provides access to the traffic data for the last 14 days. If you want to analyze statistics over a longer period of time, you need to download and store that data yourself. The app and the serverless action discussed in the tutorial implement a multi-tenant-ready solution to manage repositories, automatically collect traffic data on a daily or weekly schedule, and to view and analyze the collected data.

The original solution was based on Cloud Foundry for the web app and Cloud Functions for the automatic, serverless collection of traffic data. The code has been modified into a single Python app. It runs as dockerized container within IBM Cloud Code Engine. The app can be accessed via its web interface as regular web app. Moreover, utilizing eventing, the app receives signals (time events) to automatically collect GitHub traffic data. If not active, IBM Cloud Code Engine automatically scales down the app.

Architecture diagram

Flow:

  1. User accesses the Python (web) app running in IBM Cloud Code Engine. This is to set up the managed GitHub repositories or to access the collected traffic data.
  2. The app interacts with the IBM AppID service for authentication and user management and Db2 as database for user and GitHub traffic data.
  3. A Code Engine cron subscription based contacts the Python app to signal a time event.
  4. Based on the signaled event (3) or directed by an administrator (user), the Python app retrieves GitHub traffic data.

Highlights

The app utilizes IBM Cloud AppID for authentication. It is based on OpenID Connect 2.0. The authenticated users are matched against profiles in the backend database for authorization. This allows partial data view and multi-tenancy.

Daily and weekly data view in tables and some basic charting are fed asynchronously using AJAX callbacks to the app and implemented data APIs.

charting

Database schema

The database schema, defined in database.sql, can be graphically represented as (source in Graphviz DOT notation in dbschema.gv.txt):

License

See LICENSE for license information.

Contribute / Contact Information

If you have found errors or some instructions are not working anymore, then please open an GitHub issue or, better, create a pull request with your desired changes.

You can find more tutorials and sample code at: https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-tutorials

github-traffic-stats's People

Contributors

cclauss avatar data-henrik avatar dependabot[bot] avatar dprosper avatar l2fprod avatar powellquiring avatar vidyasagarmsc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

github-traffic-stats's Issues

Undefined name 'entries'... Is this line unreachable?

Left over from #2 Does the return statement on line just above mean that the code on this line is unreachable? PyLint is pretty good at detecting these kind of problems.

flake8 testing of https://github.com/IBM-Cloud/github-traffic-stats on Python 3.7.1

$ flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics

./backend/ghstats.py:610:63: F821 undefined name 'entries'
    resp = make_response(render_template('list.html', entries=entries))
                                                              ^
1     F821 undefined name 'entries'
1

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.