This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
Find a file
2020-11-18 23:01:18 +00:00
.idea Hopefully fix speed issue on external data 2019-09-09 15:37:56 +01:00
doc Payroll sumission API improved and test added 2017-09-18 17:13:18 +01:00
etc/code-point-open Added codepoint open data to etc. dir with LICENCE file 2017-09-21 13:15:20 +01:00
images fixes 2017-04-20 16:40:24 +01:00
lib flash fixes on import 2019-09-11 15:02:08 +01:00
log Added log folder and gitignore config 2016-09-15 16:55:27 +01:00
public Word wrap feedback in admin console 2017-10-23 15:02:18 +01:00
script added new relations 2019-07-03 17:36:36 +01:00
share Revert "Commit database files" 2020-10-18 14:38:47 +01:00
t Possible fix for test failure 2019-07-14 15:52:39 +01:00
templates flash fixes on import 2019-09-11 15:02:08 +01:00
.gitignore Hopefully fix speed issue on external data 2019-09-09 15:37:56 +01:00
.travis.yml Update perl version in Travis CI 2019-09-16 10:46:38 +01:00
CHANGELOG.md Update changelog 2019-09-16 10:43:44 +01:00
cpanfile Hopefully fix speed issue on external data 2019-09-09 15:37:56 +01:00
make_leaderboards Fixed rank sending and added leaderboard creation script 2017-07-20 11:56:24 +01:00
pear-local_loop.conf Merge remote-tracking branch 'origin/TBSliver/Minion-Tasks' into finn/minionimport 2019-07-05 18:50:37 +01:00
pear-local_loop.development.conf Fix various bits for import 2019-07-14 15:15:14 +01:00
pear-local_loop.testing.conf Update config and tests so deployment and testing use separate databases. 2017-03-08 18:52:04 +00:00
README.md Add db upgrade step 2020-11-18 23:01:18 +00:00

LocalSpend - Server

This repository contains the server for the LocalSpend system.

Current Status

Master: Build Status

Development: Build Status

Test Environment

Running Tests

To run the main test framework, first install all the dependencies, then run the tests:

  • cpanm --installdeps .
  • prove -lr

To run the main framework against a PostgreSQL backend, assuming you have postgres installed, you will need some extra dependencies first:

  • cpanm --installdeps . --with-feature postgres
  • PEAR_TEST_PG=1 prove -lr

Setting Up Minion

To set up Minion support, you will need to create a database and user for it to connect to. In production his should be a PostgreSQL database, however SQLite can be used in testing.

To use the SQLite version:

  1. Install the SQLite dependencies:
    • cpanm --installdeps --with-feature sqlite .
  2. Ensure that the following is in your configuration file:
    • minion => {
        SQLite => 'sqlite:minion.db',
      },
      

This will then use an SQLite DB for the Minion backend, using minion.db as the database file.

To start the minion itself, run this command:

  • ./script/pear-local_loop minion worker

Importing Ward Data

To import ward data:

  1. Download CSV(s) from here
  2. Run the following command:
    • ./script/pear-local_loop minion job \
        --enqueue 'csv_postcode_import'  \
        --args '[ "⟨ path to CSV ⟩ ]'
      

Setting Up Entity Postcodes

  1. Import Code-Point Open:
    • included in etc/
    • ./script/pear-local_loop codepoint_open --outcodes LA1
  2. Assign postcodes:
    • ./script/pear-local_loop minion job \
        --enqueue entity_postcode_lookup
      

Example PostgreSQL setup

# Example commands - probably not the best ones
# TODO come back and improve these with proper ownership and DDL rights
sudo -u postgres createuser minion
sudo -u postgres createdb localloop_minion
sudo -u postgres psql
psql=# alter user minion with encrypted password 'abc123';
psql=# grant all privileges on database localloop_minion to minion;

Development Environment

There are a couple of setup steps to getting a development environment ready.

First Time Setup

  1. Decide if you're using SQLite or PostgreSQL locally.
    • Development supports both, however production uses PostgreSQL.
    • For this example we will use SQLite.
    • As the default config. is set up for this, no configuration changes are needed initially.
  2. Install dependencies:
    • cpanm --installdeps . \
      --with-feature=sqlite \
      --with-feature=codepoint-open
      
  3. Install the database:
    • ./script/deploy_db install -c 'dbi:SQLite:dbname=foodloop.db'
  4. Set up the development users:
    • ./script/pear-local_loop dev_data --force
    • DO NOT RUN ON PROD.
  5. Start the minion:
    • ./script/pear-local_loop minion worker
  6. Import ward data (see instructions above)
  7. Set up postcodes (see instructions above)
  8. Create an environment.dev.ts file in src/environments with your API keys
  9. Start the application:
    • morbo script/pear-local_loop -l http://*:3000
    • You can modify the host and port as needed.

Database Scripts

To upgrade the database after making changes to commit:

  1. Increment the $VERSION number in lib/Pear/LocalLoop/Schema.pm
  2. ./script/deploy_db write_ddl -c 'dbi:SQLite:dbname=foodloop.db'
  3. ./script/deploy_db upgrade -c 'dbi:SQLite:dbname=foodloop.db'

To redo leaderboards:

  1. ./script/pear-local_loop recalc_leaderboards

Troubleshooting

Can't write to /usr/local/share/perl/5.30.0 and /usr/local/bin: Installing modules to /home//perl5 when running cpanm commands

Intall local::lib by running the following commands:

  cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)

NB: You must run this in each Terminal window; I don't know why.

Can't load application from file "/script/pear-local_loop": Can't locate Data/UUID.pm in @INC (you may need to install the DATA::UUID module) when running server

Ensure you have run the cpan --installdeps command.