Commit graph

318 commits

Author SHA1 Message Date
8615fde00a Merge pull request #161 from zorun/optimise_sql
Optimise sql queries
2017-01-16 21:15:43 +01:00
dc75a72dd0 Merge pull request #164 from zorun/fix_zero_transfers
Fix zero-amount transfers and other rounding issues
2017-01-16 21:13:56 +01:00
Jocelyn Delalande
376a0b37e3 Fix ServerTestCase.test_unprefixed test
The test was always failing, actual reason is the `app.run.configure()` fails
to reset the `APPLICATION_ROOT` setting which `ServerTestCase.test_prefixed`
overloads (side effect).

This patch *do not* fix app.run.configure as it seems uneasy, but takes a
different approach which has the advantage of making the test more explicit.

Would still be a good thing to investigate more on configure().

Fix #163
2017-01-09 10:11:50 +01:00
Baptiste Jonglez
d6cf89008f Workaround rounding issues when displaying balance of users
A user with a "0.00" balance would have either a "+0.00" in green or a
"-0.00" in red, depending on the exact value of the floating-point value.

Fix this by simply rounding to 2 digits before comparing to zero.
2017-01-03 21:37:19 +01:00
Baptiste Jonglez
b507a5afa1 Prevent transfers with a zero amount in the settle page
This workarounds a rounding issue caused by the (incorrect) usage of
floats for bill amounts.

This fixes #138
2017-01-03 21:37:19 +01:00
Baptiste Jonglez
543df7c1d4 Add a test to catch zero-amount transfers in the settle page 2017-01-03 21:37:19 +01:00
Baptiste Jonglez
699db1c4c8 Sort bills by (date.desc, ID.desc) instead of just date.desc
When viewing the list of bills, bills are (correctly) sorted by date.  But
the order of all bills for a given day is not intuitive: I would expect
bills to be sorted by reverse order of insertion.  That is, the last bill
to be added for a given day should appear first, not last.  Otherwise,
when adding several bills in a row for a given day, it's confusing to see
that the new bills do not appear on top of the list.

Fix this by sorting by decreasing ID after sorting by date.
2017-01-02 13:22:28 +01:00
Baptiste Jonglez
8e5ac8ae98 Optimise SQL queries when computing balance
This avoids creating thousands of small SQL queries when computing the
balance of users.  This significantly improves the performance of
displaying the main page of a project, since the balance of users is
displayed there:

    Before this commit: 4004 SQL queries, 19793 ms elapsed time, 19753 ms CPU time, 2094 ms SQL time
    After this commit:    12 SQL queries,  3688 ms elapsed time,  3753 ms CPU time,   50 ms SQL time
    Measured request:   display the sidebar with the balance of all users for the project (without displaying the list of bills)

This commit also greatly improves the performance of the "settle bills" page:

    Before this commit: 8006 SQL queries, 39167 ms elapsed time, 39600 ms CPU time, 4141 ms SQL time
    After this commit:    22 SQL queries,  7144 ms elapsed time,  7283 ms CPU time,   96 ms SQL time
    Measured request:   display the "Settle bills" page

Test setup to measure performance improvement:

- 5 users with various weights
- 1000 bills, each paid by a random user, each involving all 5 users
- laptop with Celeron N2830@2.16 GHz, SSD Samsung 850 EVO
- sqlite database on SSD, using sqlite 3.15.2
- python 2.7.13
- Flask-DebugToolbar 0.10.0 (to count SQL queries and loading time)

Performance measurements (using Flask-DebugToolbar on the second request,
to avoid measuring cold-cache performance):

- number of SQL queries
- elapsed time (from request to response)
- total CPU time consumed by the server handling the request
- total time spent on SQL queries (as reported by SQLAlchemy)
2017-01-02 13:09:26 +01:00
Baptiste Jonglez
74df614007 Optimise SQL queries when displaying bills for a project
By defaut, SQLAlchemy uses lazy loading, which means that displaying n
bills will generate around n queries (to get the list of owers of each
bill).  Pre-load the list of owers to drastically decrease the number of
SQL queries.

Before this commit: 1004 SQL queries, 7535 ms elapsed time, 7536 ms CPU time, 530 ms SQL time

After this commit: 5 SQL queries, 3342 ms elapsed time, 3393 ms CPU time, 15 ms SQL time

Measured request: display the list of all bills for the project (without displaying the sidebar with balances)

Test setup to measure performance improvement:

- 5 users with various weights
- 1000 bills, each paid by a random user, each involving all 5 users
- laptop with Celeron N2830@2.16 GHz, SSD Samsung 850 EVO
- sqlite database on SSD, using sqlite 3.15.2
- python 2.7.13
- Flask-DebugToolbar 0.10.0 (to count SQL queries and loading time)

Performance measurements (using Flask-DebugToolbar with the second
request, to avoid measuring cold-cache performance):

- number of SQL queries
- elapsed time (from request to response)
- total CPU time consumed by the server handling the request
- total time spent on SQL queries (as reported by SQLAlchemy)
2017-01-02 13:09:26 +01:00
7ba9048b06 Merge pull request #150 from fredericsureau/negative-amounts
Allow negative bill amounts
2016-09-12 17:54:58 +02:00
fredericsureau
c9b2d17f60 Update negative amounts test 2016-09-12 16:30:01 +02:00
fredericsureau
a1f1655f06 Allow negative bill amounts 2016-09-12 14:21:57 +02:00
Adam Chainz
a80202e066 Convert readthedocs links for their .org -> .io migration for hosted projects
As per [their blog post of the 27th April](https://blog.readthedocs.com/securing-subdomains/) ‘Securing subdomains’:

> Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard.

Test Plan: Manually visited all the links I’ve modified.
2016-06-28 07:46:50 +01:00
Jocelyn Delande
a5579220e0 Fix migrations upgrade path for MySQL
For some reason, the migration path from unmanaged db (from alembic
point-of-view) to managed db, through the initial migration works well with
sqlite… But not with mysql where the db system tries to re-create the existing
tables.

This commit is a way to detect if we are migrating from pre-alembic era and
skip the first migration (which would do nothing anyway), marking it as already
executed.

It's quite hackish but that's the best I found so far to get it working with
both MySQL and SQLite.
2016-06-18 12:13:46 +02:00
Jocelyn Delande
c49a355eb0 Update translation 2016-06-16 15:52:24 +02:00
Jocelyn Delande
d3bb04c1bf Add migration to initialize Person weights
That's for Persons that existed before the weights were added to model.
2016-06-16 15:52:24 +02:00
Jocelyn Delande
7a630b78ea Hide the member weights in members list if all weights are "1". 2016-06-16 15:52:24 +02:00
Jocelyn Delande
ec8fe2326b Added member edit form 2016-06-16 15:52:24 +02:00
Jocelyn Delande
64c2cd56df display an edit button on members list 2016-06-15 10:20:37 +02:00
Jocelyn Delande
1147f2ece8 Ask for confirmation only for deleting users 2016-06-15 10:20:37 +02:00
Jocelyn Delande
85abc0b1fc Added a template filter not to show zero decimals on user weights 2016-06-15 10:20:37 +02:00
Jocelyn Delande
b57df5cd36 UI for showing user weights in user list 2016-06-15 10:20:37 +02:00
Jocelyn Delande
06f10d0508 Added member weights support to API 2016-06-15 10:20:37 +02:00
Jocelyn Delande
2b071a1a3b Add members weight in models and budget backend refs #94 2016-06-15 10:20:37 +02:00
Jocelyn Delande
465deabd02 Add a manage.py CLI (flask_script)
As it's the Flask-Migrate way to expose its commands (./manage.py db command).

In our case, it's specially useful for creating new migrations.
2016-05-31 12:10:53 +02:00
Jocelyn Delande
74995f9959 Handle migrations through alembic/flask-Migrations
Auto-initialization now applies migrations instead of using db. create_all()

fix #83
2016-05-31 12:10:53 +02:00
Jocelyn Delande
b685fa74d6 Do not load user-overriden settings in unit tests.
Loading not versioned settings.py during tests make them less predictable.
That's inspired from django behaviour with DJANGO_SETTING_MODULE environment variable.
2016-04-03 22:31:32 +02:00
a8841f9d3f Merge pull request #122 from JocelynDelalande/configurable-prefix
Made an URL prefix configurable in settings
2015-11-09 09:26:11 +01:00
Mathieu Leplatre
eff0f7c2df Prevent comma to be included in URL 2015-09-25 12:32:56 +02:00
Mathieu Leplatre
c6c40f02c5 Prevent comma to be included in URL 2015-09-25 12:31:52 +02:00
Quentin Roy
d31de6c4a3 Merge pull request #130 from JocelynDelalande/trailing-whitespaces
Remove trailing whitespaces
2015-08-20 12:08:52 +02:00
Jocelyn Delande
d9313ba40e Remove trailing whitespaces 2015-08-20 12:02:04 +02:00
Jocelyn Delande
15091e28c0 Made an URL prefix configurable in settings, includes tests. 2015-08-19 22:56:45 +02:00
Jocelyn Delande
d6c514e7d1 Adds a way to (re)configure the running app, reloading settings.
Currently, there is no way to reset settings after modifying them, which is
anoying for tests.
2015-08-19 22:53:16 +02:00
Alexandre Avenel
b9458db08e Bugfix rounding settle algorithm
In some cases, settle algorithm failed to deliver optimal solution due to a rounding bug.
2015-07-05 22:16:38 +02:00
84aafc850e Merge pull request #121 from JocelynDelalande/deprecated-default-mail-sender
nicely deprecates DEFAULT_MAIL_SENDER
2015-05-20 18:03:50 +02:00
Jocelyn Delande
2b598477b7 specified sizes for string columns for MySQL 2015-05-01 18:28:40 +02:00
Jocelyn Delande
df215cbb79 nicely deprecates DEFAULT_MAIL_SENDER as it changed upstream for flask-mail>=0.8 2015-04-30 16:58:16 +02:00
42dd9d54a8 Merge pull request #119 from aavenel/fix-118
Fix 118
2015-04-15 21:32:50 +02:00
Alexandre Avenel
4f4439eec9 Fix #118 : Create a new project with the name "dashboard" should raise an exception 2015-04-12 20:41:57 +02:00
Alexandre Avenel
79f24b7cb8 Format numbers in templates 2014-07-22 20:19:35 +02:00
Alexandre Avenel
9236c13213 Fix rounding error in balances 2014-07-21 22:23:30 +02:00
229fe41a0c Merge pull request #106 from aavenel/bugfix105
Bugfix #105 : TypeError: object of type 'NoneType' has no len()
2013-10-17 04:41:00 -07:00
85a92e0485 Merge pull request #114 from aavenel/bugfix104
bugfix #104 : ZeroDivisionError
2013-10-17 04:40:47 -07:00
A.Avenel
ca186dfa2e Fix translation for password tooltip
- Javascript don't like non-escaped character
- fix typo
2013-10-13 21:51:34 +02:00
A.Avenel
7b338a2a14 Fix translation for password tooltip
- Javascript don't like non-escaped character
- fix typo
2013-10-13 21:45:49 +02:00
A.Avenel
6f9fe3c159 bugfix #104 : ZeroDivisionError
- test if self.owers is null before returning value
2013-10-12 17:28:15 +02:00
A.Avenel
74e6f9f11d Add unit-test for bug #105.
Small code refactoring for better readability
2013-10-12 16:56:25 +02:00
Quentin
f2d0d19880 ihatemoney does not start anymore with flask-wtf 0.9: limit flask-wtf to version 0.8 in requirements.txt 2013-08-23 14:15:19 +02:00
A.Avenel
8b64762f71 Bugfix : error when you access /authenticate url without a project identifier 2013-06-23 17:37:58 +02:00
a71d249e6c Merge pull request #96 from aavenel/master
New feature : Settle the bill
2013-05-09 18:32:55 -07:00
A.Avenel
ff9ead2203 Optimization 2013-05-09 23:23:23 +02:00
A.Avenel
058cc8a9e5 correct french translation 2013-05-09 22:33:15 +02:00
A.Avenel
4d329a76ae Bugfix#92 : error when deleting an user 2013-04-08 11:29:31 +02:00
A.Avenel
1999ebd925 one more fix to french translation ... 2013-04-08 00:14:16 +02:00
A.Avenel
9fcdd0dee3 Forget to translate some sentences ... 2013-04-07 23:48:23 +02:00
A.Avenel
c1f4348b52 update french translation 2013-04-07 23:38:39 +02:00
A.Avenel
a0e94f3c11 bugfix : "Settle" link was not active on navbar. 2013-04-07 23:01:32 +02:00
A.Avenel
0d7c82b122 More code cleanup for "settle bills" 2013-04-07 22:14:32 +02:00
A.Avenel
1fa0cff180 use "member.id" instead of "member" 2013-04-07 20:25:25 +02:00
A.Avenel
b410e48851 Merge branch 'flask0.9' of github.com:aavenel/ihatemoney 2013-02-19 15:36:37 +01:00
A.Avenel
a4b8283fba Update tests to work with flask 0.9 2013-02-19 15:27:51 +01:00
A.Avenel
bfea4e436f update for flask 0.9 2013-02-18 19:18:49 +01:00
A.Avenel
8b114c5718 update for "create archive" interface 2012-11-26 21:52:25 +01:00
A.Avenel
ee7459025d Increase max-height for modal
so we can display more members without using scrollbars
2012-11-25 14:01:47 +01:00
A.Avenel
bbd4a1a838 Cosmetic changes for "add a bill" panel 2012-11-25 13:53:30 +01:00
A.Avenel
79bd22c25c Add unit tests for settle_bill 2012-11-03 20:53:51 +01:00
A.Avenel
2b51131aa4 Merge git://github.com/Lastpixl/ihatemoney into HEAD
Conflicts:
	budget/templates/layout.html
	budget/templates/list_bills.html
2012-11-03 17:34:05 +01:00
A.Avenel
0fcc2c72ec Some love for the dashboard view 2012-09-03 23:11:32 +02:00
A.Avenel
44dc06bb6f Bugfix : "Submit and add a new one" not working 2012-09-03 21:06:07 +02:00
A.Avenel
d0129abc0e Bugfix : calendar widget not working when you edit a bill. 2012-09-03 18:11:31 +02:00
A.Avenel
a2b950d9c8 Remove some old code no longer needed (Correct 404 errors about jquery-ui) 2012-09-03 17:40:34 +02:00
688a281464 remove epio support 2012-09-02 14:09:41 +02:00
6a544855d7 Fix project deletion. fix #87 2012-09-02 13:53:01 +02:00
e75809dddf Enhance the test suite 2012-09-02 13:26:56 +02:00
b3ce91c79f add sentry support 2012-06-10 01:49:01 +02:00
599895cac3 Switched to the new naming scheme for extensions 2012-05-19 15:09:57 +02:00
Frédéric Sureau
be32a2550e Update to Boostrap v2.
Remove unused libs (QTip, JQueryUI) and add bootstrap-datepicker which is much lighter.
2012-04-05 15:40:09 +02:00
870101c237 add settings for epio 2012-04-01 20:36:28 +02:00
90acad67f9 make tests run on python 2.7 also 2012-04-01 19:39:26 +02:00
Frédéric Sureau
192ca41b0a Adds test for the has_bills() method of Person model 2012-03-29 01:13:00 +02:00
Frédéric Sureau
c343bf96ea Merge branch 'master' of git://github.com/spiral-project/ihatemoney 2012-03-28 17:02:02 +02:00
Xavier Mehrenberger
cb13fbb782 Split bills function and basic template. 2012-03-12 01:35:28 +01:00
Feth AREZKI
46d2dfeb29 remove unused code
If that code is ever needed, I'll try to rewrite it as a class
decorator, which is more hype
2012-03-06 22:42:58 +01:00
Feth AREZKI
353aec4f1e remove unused imports, and pep8 2012-03-06 22:14:29 +01:00
Feth AREZKI
e04a4154e8 remove unused imports and from blah import * 2012-03-06 22:14:10 +01:00
Feth AREZKI
e22ee5dfd2 remove from blah import * 2012-03-06 22:13:47 +01:00
Feth AREZKI
9583fe3cbe code reread: noop, and pep8 <3 2012-03-06 20:37:32 +01:00
Feth AREZKI
6a50e7318b pep8 <3 and '*' imports removal 2012-03-06 18:42:44 +01:00
Feth AREZKI
fddf60a662 pep8 <3 and '*' imports removal 2012-03-06 18:41:55 +01:00
Feth AREZKI
c51c02481b tolerance to smtp error when creating project 2012-02-20 17:03:44 +01:00
Feth AREZKI
04f8470223 cosmit. rem trailing spaces 2012-02-20 16:58:18 +01:00
Frédéric Sureau
71cb07a92b Merge remote-tracking branch 'upstream/master' 2012-02-15 16:09:23 +01:00
Adrien CLERC
bd1b0aaff3 Add QTip2 and use it to display a message about access code on the first page. 2012-02-11 19:18:34 +01:00
Adrien CLERC
2f928e08be Use embedded fonts instead of Google. 2012-02-09 23:02:55 +01:00
Adrien CLERC
e1ca284d84 Add font generated from FontSquirrel. The CSS have
been slightly modified.
2012-02-09 23:01:28 +01:00
Frédéric Sureau
caf9b6fcc2 Correct bug in members model. The has_bills method did not worked as expected. Fix #73. 2012-01-28 12:40:10 +01:00
Frédéric Sureau
a59465c9a5 Changed delete feature to only support POST method. Fix #21. 2012-01-28 01:35:04 +01:00
848e4a34ce Fix an error in dashboard.html 2011-12-04 00:23:55 +01:00
A.Avenel
1a5abcfbf2 Fix for a bug introduced in last commit : crash of dashboard view when there is no bill. 2011-12-03 22:25:19 +01:00