SpriteLink/NIPAP — pull request #431 by plajjan (2013-11-11 15:26:48+00:00)
Title: Implement precalculation of number of children

This implements the calculation and storing of the number of children to
a prefix. Previously we did this calculation kind of on-the-fly when
returning search results but as it is a value that doesn't change much
it is well suited to being calculated beforehand and stored in the
database.

Together with this, a lot of database triggers have been refactored.
Most of the changes pertain to how and when triggers are called and not
their actual function. Instead of triggering children/tag/indent
calculation on all updates we are now using the column based triggers
available in PostgreSQL 9.x to only trigger on changes that would
influence the result. For example, changing the description of a prefix
would not change the indent and so there is no need to trigger indent
calculation on changes to the description column. There is a certain
risk of new bugs as the changes are quite extensive but the unittests
run without fault and I've gone through everything more than once ;)

Naturally, the web UI now uses the values it receives from the backend
on how many children a prefix has. There was quite a lot of logic to
handle guessing the amount of children which has now been removed.

Also clarify certain parts of country code integrity test and fix other
unittests.

Fixes #421.