Skip to content

A web application for editing Toolhub records in a fun and easy way

License

Notifications You must be signed in to change notification settings

wikimedia/toolhunt

Repository files navigation

toolhunt

Description

Toolhunt is a web application for editing Toolhub records in a fun and easy way. It allows users to view and add missing fields for tools in Toolhub.

This repository contains the project backend. The frontend can be found in the toolhunt-ui repository.

This is an Outreachy Internship project.

Issue Tracker

This project uses Phabricator to track issues.

Documentation

API documentation is automatically generated by Swagger and can be accessed (while the app is running) at localhost:8082/api/documentation

Setup/Installation Requirements

Note that, as of the latest build, access to the API documentation and backend functionality happens through the frontend component of this app: toolhunt-ui repository

In other words, to do much of anything with this half of the project, you must have both front- and backend components running in Docker containers.

  • Clone this repo to your machine with the command git clone https://github.com/wikimedia/toolhunt.git

  • Clone the frontend ui repo with git clone https://github.com/wikimedia/toolhunt.git

In order to authenticate successfully, you must register your local version of the app with the Toolhub Demo Server.

  • To register, go to Developer Settings and complete the form.

  • Set http://localhost:8082/api/authorize as the Authorization Callback URL.

  • Create an .env file in the root directory of your toolhunt repo and add TOOLHUB_CLIENT_ID and TOOLHUB_CLIENT_SECRET (set their values to be whatever you received from the demo server registration)

When building the Docker containers, the backend must go first.

From the toolhunt directory:

  • docker-compose up --build --detach

From the toolhunt-ui directory:

  • docker-compose up --build --detach

Then:

  • Open a browser window to localhost:8082

Working with the database

Initializing the Database

  • From the command line, docker-compose exec flask-web flask db upgrade

Accessing the Database

  • From the command line, docker exec -it mariadb mariadb --user user -p mydatabase (password: mypassword)

Adding field data to the Database

Whether you're working with the mock data or "real" data, the contents of the field table will remain the same.

  • From the command line, docker-compose exec flask-web python manage.py insert_fields

This needs to be done first, before adding tool data.

Adding test data to the Database

The mock data set contains three tools and a set of completed tasks. When run, the function load_mock_data will put the tools through the insertion process and auto-generate tasks, as it would with "real" data.

It will also enter completed tasks into the completed_task table in the database.

  • From the command line, docker-compose exec flask-web python manage.py load_mock_data

The results will appear on the command line. This command may be run multiple times; observe the command line messages to see what changes when a tool and/or task is already present in the DB.

The set of completed tasks will allow us to test that the high scores, user contributions, and latest contributions are returning correctly.

Adding a full data set from Toolhub to the Database

  • From the command line, docker-compose exec flask-web python manage.py update_db

While in development mode, the fetch request associated with this pipeline draws data from the Toolhub Test Server. This command can be run prior to or following load_mock_data.

Running local CI and tests

Toolhunt uses tox to handle local CI (linting, syntax, style, code formatting and import sorting). To use it, follow the installation instructions and, from the toolhunt directory, enter tox on the command line.

Technologies to be Used

  • Python
  • Flask
  • Redis
  • Docker
  • MariaDB

About

A web application for editing Toolhub records in a fun and easy way

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •