Coder Social home page Coder Social logo

election_livestats's Introduction

Election Livestats

Election Livestats is a module for Drupal 7 that extends the Election module to provide live statistics.

Note that all version numbers provided for dependencies or requirements reflect the development environment and can be substituted for other versions with compatible APIs.

Dependencies

Software Requirements

Installation

  • Run npm install in node/ folder
  • Set your configuration in node/config.json. You can do this by renaming or copying config.json.example.
  • Install the Highcharts library. The Libraries module has a good FAQ on installing external libraries.

Configuration

This module requires metrics to be implemented via hook_election_livestats_metrics_alter. An example metric "Total votes" is included by way of example. Documentation on the structure of metric classes is to come.

There is also a "view election live statistics" permission that you will need to configure before the live statistics page is visible.

You may need to open port 3000 on your firewall (e.g. on Ubuntu, ufw allow 3000/tcp).

Running

  • Start Redis server.
  • Run node node/app.js.
    Note: If the certificates are in a read-protected directory, the app will need to be run in sudo.
  • For every election for which you want to have live statistics, you will need go to election/%election_id/stats/actions and Cache eligibility and metadata.. Depending on your electorate size, this may take some time.
  • Once this is complete, you should see a "Total votes" header at election/%election_id/stats/. This will indicate how many votes have been cast as voting continues.

Process Monitoring

Ideally the Node.js app should run as a service on the server, so start it as a daemon or service in the way you prefer. I would recommend using PM2 to monitor the app, running pm2 startup to start it on boot.

Alternatively, the upstart script node/election_livestats_node.conf is included in this repository. To use it, change the directory in the script section to point to your election_livestats folder and then copy it to /etc/init/.

Security Considerations

Please note that currently there is no authentication on the websocket server. As a result, even if your election is only visible to certain users, anyone could connect to the websocket server and receive live statistics updates.

election_livestats's People

Contributors

gausie avatar

Watchers

 avatar  avatar  avatar

Forkers

digideskio

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.