Skip to content

ThreeSixtyGiving/grantvis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0b6b74c · Oct 29, 2024
Jan 25, 2024
Jan 25, 2024
Oct 29, 2024
Oct 29, 2024
Jan 25, 2024
Feb 22, 2022
Dec 22, 2021
Dec 22, 2021
Jan 20, 2022
Nov 11, 2021
Nov 11, 2021
Jan 25, 2024
Oct 10, 2024
Jan 25, 2024
Dec 22, 2021
Feb 22, 2022
May 18, 2022
Jan 25, 2024
Jan 25, 2024
Jan 25, 2024
Jan 25, 2024
Dec 19, 2022

Repository files navigation

GrantVis (Insights)

Coverage Status

Installation

Local

python3 -m venv .ve
source .ve/bin/activate

pip install -r requirements.txt
pip install -r dev-requirements.txt # if developing

Install postgres (Insights is tested in postgres 12)
sudo -u postgres createuser -P -e <username>  --interactive
createdb -U <username> -W insights-ng

export DATABASE_URL=postgresql://<username>:<password>@localhost/insights-ng
export MAPBOX_STYLE=<mapbox style uri>
export UPLOADS_FOLDER=/app/uploads
export DATASTORE_URL=postgresql://<datastore_user>:<datastore_password>@store.data.threesixtygiving.org:5432/360givingdatastore
export MAPBOX_ACCESS_TOKEN=<mapbox_access_token>
export FLASK_APP=insights.wsgi:app
export FLASK_ENV=development # if developing

Run Migrations

Dokku

dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres

dokku apps:create insights-ng

dokku postgres:create insightsng_db
dokku postgres:link insightsng_db insights-ng

dokku config:set insights-ng FLASK_APP=insights.wsgi:app
dokku config:set insights-ng DATASTORE_URL=postgresql://user:pass@store.data.threesixtygiving.org:5432/360givingdatastore

# Storage for static and cache files
dokku storage:ensure-directory insights_data_cache
dokku storage:mount insights-ng /var/lib/dokku/data/storage/insights_data_cache:/insights_data_cache
dokku storage:ensure-directory insights_static
dokku storage:mount insights-ng /var/lib/dokku/data/storage/insights_static:/insights_static

# Import data from 360Giving datastore
dokku run insights-ng flask data fetch
dokku run insights-ng flask data geonames

# Recommeneded timeout for nginx
dokku nginx:set insights proxy-read-timeout 300s
dokku proxy:build-config insights-ng

Migrations

flask db migrate
flask db upgrade

Fetch data

flask data fetch
flask data geonames

Update requirements

We target python3.6 for our requirements.

Use pip-compile provided by pip-tools package to process requirements .in files.

pip install pip-tools
pip-compile requirements.in 
pip-compile dev-requirements.in 

Run

Development server

export FLASK_APP=insights.wsgi:app
export FLASK_ENV=development
flask run

Tests

pytest tests

Test coverage

coverage run -m pytest ./tests
coverage report

Linter

black insights/

Design System

Insights' design system is located in 360-ds. Any change in CSS needs to be made in Insights' folder and then compile.

cd 360-ds
npm run compile-sass -- --project 'insights' --path '../insights/static/css/'