(Bug1353802) Add query result caching to handle_event

Improve the performance of handle_event by caching the results of
database queries. In testing adding 2000 users from a CSV file with
a typical number of fields (username, password, email, firstname,
lastname, studentid, address, town, city, country, homenumber,
mobilenumber), this change reduced the average import time over
three runs (with a fresh install each time) as follows:

                       Before      After     Saving
Total Wall Time        246s        114s       132s - 54%
handle_event           132s         21s       111s - 84%

(The change to handle_event seems to affect other functions'
execution times, perhaps due to other database caches still
being in memory that would otherwise be replaced).

Change-Id: Ibf28650df710dd807f95fca30a2dfc29ed92f5cd
Signed-off-by: Nigel Cunningham <nigelc@catalyst-au.net>
(Bug1353802) Remember and reuse last db_format_timestamp output if poss.

This patch adds support for remembering the last parameter used
by ArtefactType::commit to db_format_timestamp and the output of
the function, and reusing the output if the input is the same on
the next call.

In a test import of 2000 users, this patch reduced the number of
invocations of db_format_timestamp from 80,000 (3.6s) to 14,800
(.3s).

Change-Id: I6f5575f9d3649ff53514f9927744a01966d103dd
Signed-off-by: Nigel Cunningham <nigelc@catalyst-au.net>
Searching by user in Shared Pages (bug 897586)

Include searching by a user to the Shared Pages tab.

This is a pretty complicated area as the View::view_search() is used in many areas.
Have not added a new search type of 'users only' like the 'tags only'.
Have only updated the general search type of 'Title, description, tags' to include users.

Change-Id: I6020aa5f432133649e50ea180bbd8536c8e30e72
Signed-off-by: Ghada El-Zoghbi <ghada@catalyst-au.net>
Merge "Searching by user in Shared Pages (bug 897586)"
Merge "(Bug1353802) Remember and reuse last db_format_timestamp output if poss."
Add site option to prevent display of usernames (Bug #1353516)

Change-Id: I0c2db9c1fefcea2dfd7e442729ee0d46e822a781
Signed-off-by: Tony Butler <tonyjbutler@gmail.com>