Skip to content
Instantly query taxi arrival times
Python JavaScript HTML CSS
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
daemons
logs
mouse
taxibros
templates
visualize
.coveragerc
.env.template
.gitignore
.travis.yml
README.md
coverage.svg
manage.py
setup.py

README.md

TaxiBros

Build Status Coverage Status Code style: black

Instantly query taxi arrival times.

alt text

Installing and running django server

All the following instructions executed from same folder as this README.md. Each instruction is a command, and a description of the command.

  1. Install the taxibros package.
    python3 -m pip install --upgrade .
    
  2. Follow .env.template to store all secret keys in a file named .env. Get your DJANGO_SECRET_KEY by:
    python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
    
  3. Follow taxibros/settings/local_settings.py.template to create your personal settings in taxibros/settings/local_settings.py.
  4. Migrate, as well as synchronize apps without migrations.
    python3 manage.py makemigrations
    python3 manage.py migrate --run-syncdb
    
  5. Run server.
    python3 manage.py runserver`
    

Accessing admin pages

  1. Create account.
    python3 manage.py createsuperuser
    
  2. Log in at /admin.

Downloading data

  1. Run the server (see Running django server section).
  2. Visit /daemons to check number of coordinates and timestamp, or /admin and select background_tasks to check if daemon is running
  3. Check logs/debug.log for debug output. For example:
    INFO 2018-05-17 12:26:54,905 tasks 8245 140658619733760 Running daemons.download.start_download
    DEBUG 2018-05-17 12:26:54,906 download 8245 140658619733760 start_download
    DEBUG 2018-05-17 12:26:55,219 download 8245 140658619733760 2018-05-17T12:26:46+08:00 4950 healthy
    INFO 2018-05-17 12:26:56,828 tasks 8245 140658619733760 Ran task and deleting daemons.download.start_download
    
    DEBUG 2018-05-17 12:26:58,045 process_tasks 8245 140658619733760 waiting for tasks
    ...
    
  • When the download_timestamps function is called, there are some changes to the database. These changes are removed if a SIGINT by C-C is sent before download_timestamps finishes.
  • If some background_task/task had error, and fixing the cause of error then restarting the server does not fix the issue, then delete task from database.

Running Tests

Tests are executed using the django manager.

  1. Run the test client
    python3 manage.py test
    

Creating PostGIS database

  1. Download dependencies.
    sudo apt install postgresql-server-dev-9.5 postgresql-9.5-postgis-2.3
    
  2. You may have to manually create the data directory and start the server. Filenames might be different.
    su - postgres
    initdb -D /var/lib/postgresql
    pg_ctl -D /var/lib/postgresql -l logfile start
    
  3. Create user and database.
    su - postgres
    psql
    CREATE USER geodjango PASSWORD 'geodjango';
    ALTER ROLE geodjango SUPERUSER;
    CREATE DATABASE geodjango OWNER geodjango;
    exit
    

Transitioning from SQLite to PostgreSQL

  1. Dump and load data
  2. Ignore old django migrations. A few other notes.
  • netstat -nlp | grep 5432 to see where the socket is, if it exists.
  • Remove/ignore all conversions of QuerySets to Python lists before AppConfig is ready. If those conversions are executed, ./manage.py migrate will query the empty database.

Installing Open Street Map

  1. For more context in map (including street and thoroughfare details), install PROJ.4 datum shifting files.

Continuous integration

Automatic CI on each new commit with .travis.yml in the repo. However, sometimes build errors occur (specifically test_unique_timestamp fails), even though it passes on your local machine. Assuming your local_settings.py matches travis' settings in production.py, restart build on Travis CI and pray.

Coverage testing

  1. Generate .coverage file.
    coverage run manage.py test
    
  2. Optional: show report.
    coverage report -m
    
  3. Generate coverage badge. You might have to alias python3 .../path/to/coverage_badge/__main__.py to coverage-badge.
    coverage-badge -o coverage.svg
    

Code formatting

  1. Run with sensible defaults.
    black .
    

Cache framework

  1. Install memcached and dev tools.
    sudo apt install -y memcached libmemcached-dev
    
  2. Follow guide on django cache docs.

Mouse tracking

We use musjs.

  1. Create new mouse database by python manage.py migrate --database=mouse_db.
  2. Play tracked mouse movements at /mouse.
You can’t perform that action at this time.