guardian/frontend — pull request #7261 by stephanfowler (2014-11-24 17:30:49+00:00)
Title: User history refactor

@johnduffell @phamann @rich-nguyen @crifmulholland : a rethink of the history, that maintains existing usages of it.

It throws away all unused item data, in favour of storing more lossy summary data, ie. 30 days worth of visits - rather than exactly 100 visits previously. Saves the following into localStorage (the formats are optimised for size rather than than legibility.)

__gu.history__ - an ordered list of the 50 most recent article ids, with a count of their total visits.
```
[
["football/2014/nov/18/the-fiver-scotland-england-fitba", 2],
["football/2014/nov/14/the-fiver-youre-no-good-for-me-i-dont-need-nobody", 1]
...
```

__gu.history.summary__ - a map of tags/sections/series/authors associated with content visited since the `start` day. Each has a display name and a histogram of views since the start. This start day itself is updated to so as to never be further back than 30 days, causing the histogram to drop data points from before that.
```
{
"start":16398,
"tags":{
"football":["Football",[[2,6], [1,10], [0,2]]],
"football/series/thefiver":["The Fiver",[[0,4]]],
"profile/pauldoyle":["Paul Doyle",[[0,1]]],
....

// the format is [, ]
````

__gu.history.popular__ - an ordered list of the 10 most popular items from the summary. These are ranked by visits weighted by recency. This will be rendered as a personalised nav in a later PR.
```
[
["football","Football"],
["football/series/thefiver","The Fiver"],
["profile/pauldoyle","Paul Doyle"]
...
```