Issue417

Title Add autocomplete for the nosy list
Priority feature Status resolved
Superseder Nosy List ezio.melotti
Assigned To ezio.melotti Topics

Created on 2011-08-12.05:04:46 by ezio.melotti, last changed 2011-08-15.09:05:15 by ezio.melotti.

Files
File name Uploaded Type Edit Remove
issue417.diff ezio.melotti, 2011-08-12.05:04:45 text/plain
nosy-autocomplete.png ezio.melotti, 2011-08-12.05:05:58 image/png
Messages
msg2216 (view) Author: ezio.melotti Date: 2011-08-12.05:04:45
The attached patch adds an autocomplete to the nosy list.

TL;DR: see screenshot.

This is how it works:
  * server-side, the entries are taken from 2 places:
    1) the experts index of the devguide.  This is done downloading and
       parsing the rst source.  The new user.experts.html page returns
       this data as JSON.
    2) the list of committers from the Roundup database.  This is done
       retrieving the username and realname from the database.  The new
       user.devs.html page returns this data as JSON to logged in users.
    The Python code to retrieve this data and convert to JSON is in a
    new extension called jnosy.py.

  * client-side, when the page loads, the browser:
    1) checks if the two JSON files are cached in the HTML5 storage;
    2) if HTML storage is not supported or if they are not cached,
       it requests from the JSON from the server (through the two
       user.*.html pages), and possibly caches the result;
    3) the two JSON files are adapted and combined, in order to
       form a list of entries for the autocomplete.

When the user writes in the nosy list, the autocomplete will list all the elements that match divided by category.
The categories are the ones of the experts index (one per table), plus a "developer" category.
The "developer" entries are listed first, and look like "Name Surname (username)".  Once selected, only the username is added to the nosy.
The "experts" entries list the name of the module/interest area/etc. followed by the list of names (e.g. 'unittest: michael.foord,ezio.melotti'), and once selected it adds all the names to the nosy.

A few more random comments about the patch:
  * HTML5 storage allows the script to save data on the client's
    machine and it's available on all the major browsers (FF3.5+,
    IE8+, Chrome4+, Opera10.5+, Safari4+).
  * If the HTML5 storage is not available the script will request
    the data from the server, once for each issue page visited
    (all the data are downloaded only once when the page loads).
  * Both the pages return less than 5 kB of JSON, and both seem
    quite fast.
  * If JS is not available the autocomplete is not available, with
    no other side effects.
  * Having autocomplete for all the registered users, even if 
    technically doable, has two major problems:
    1) it takes about 10s for the server to put together a JSON
       object with all the names and usernames of 10k+ users and
       send it to the client (that's about 200+ kB of JSON);
    2) it's probably really slow to process on the client-side
       and it will flood the autocomplete with lot of matching
       names (I haven't tried it though).
  * The user.devs.html page is not visible to not-logged in users.
  * Some server-side caching should be added, so that at least the
    expert page is not downloaded and parsed every time.
    I'm not sure if this should be done via the Cache-Control
    and/or Expires HTTP headers (that would prevent the browsers
    to send requests at all), or just keep the generated JSON
    in memory or in a local file, and update it, say, once a day.
  * The HTML5 storage cache should also be invalidated after a
    while, and the JSON requested again to the server.
  * Instead of having two separates files, a single file that
    returns a single JSON object with both developers and experts
    can be used.

Unless there are problems with this design, I'll commit it and see what the users think about it.
msg2217 (view) Author: ezio.melotti Date: 2011-08-13.08:06:10
I committed an updated version in r88881.  The things I changed are:
  * the autocomplete is not loaded anymore if the user can't edit the nosy;
  * names are added only once, duplicated are now discarded;
  * if the JSON in the local storage is older than one day, it will be downloaded again;
msg2219 (view) Author: ezio.melotti Date: 2011-08-15.09:05:15
No one complained yet, so I documented it in the devguide and I'm closing this.
History
Date User Action Args
2011-08-15 09:05:15ezio.melottisetstatus: testing -> resolved
messages: + msg2219
2011-08-13 08:06:11ezio.melottisetstatus: in-progress -> testing
messages: + msg2217
2011-08-12 05:05:58ezio.melottisetfiles: + nosy-autocomplete.png
2011-08-12 05:04:46ezio.melotticreate