Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

zooniverse/zoo-stats-api-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zoo stats

Build Status

API

The stats service has a GraphQL API, https://graphql.org/ which differs to RESTful APIs.

There is only one endpoint path for this API /graphql and it only supports the POST HTTP method for the application/json content type.

POST /graphql (application/json)

Introspect the available operations

curl -d '{"query": "{__schema {queryType {name fields {name}}mutationType {name fields {name}}}}"}' -H "Content-Type: application/json" -X POST https://graphql-stats.zooniverse.org/graphql

Event type counts per interval Retrieve the number of classifications for a specified event type for a known interval. Non-required attributes are projectID and userId to filter the results.

Note: If you supply the the userId attribute you must provide a bearer token in the Authorization header, e.g. Authorization: Bearer <TOKEN>

You must supply and eventType, interval and window. Valid intervals are postgres intervals, e.g. 2 Days, 24 Hours, 60 Seconds Valid windows are postgres intervals, e.g. 7 Days, 2 Weeks, 1 Month, 1 Year.

{
  statsCount(
    eventType: "classification",
    interval: "1 Day",
    window: "1 week",
    projectId: "${project.id}",
    userId: "${user.id}"
  ){
    period,
    count
  }
}

Note: classification events are currently the only supported event types.

Getting Started

  1. Clone the repository git clone https://github.com/zooniverse/zoo_stats_api_graphql.

  2. Install Docker from the appropriate link above.

  3. cd into the cloned folder.

  4. Run docker-compose build to build the containers Panoptes API container. You will need to re-run this command on any changes to Dockerfile.dev (note the dev dockerfile, production is Dockerfile)

  5. Create and run the application containers with docker-compose up

  6. If the above step reports a missing database error, kill the docker-compose process or open a new terminal window in the current directory and then run docker-compose run --rm zoo_stats bundle exec rake db:setup to setup the database. This command will launch a new Docker container, run the rake DB setup task, and then clean up the container.

  7. Open up the application in your browser at http://localhost:3000

Once all the above steps complete you will have a working copy of the checked out code base. Keep your code up to date and rebuild the image on any code or configuration changes.

Note: You will need to re-install the gem dependencies for the application if you modify the Gemfile * Run: docker-compose run --rm zoo_stats bundle install

Testing

  1. Setup the test environment and database

    • Run: docker-compose run --rm -e RAILS_ENV=test zoo_stats bundle exec rake db:setup
  2. Run the tests

    • Run: docker-compose run -T --rm -e RAILS_ENV=test zoo_stats bundle exec rspec
  3. Get a console to interactively run / debug tests

    • Run: docker-compose run --rm -e RAILS_ENV=test zoo_stats bash
    • Then in the container run: bundle exec rspec

Setup Docker and Docker Compose

Thanks

This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com.

pullreminders

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published