summaryrefslogtreecommitdiff
path: root/pgweb/docs/struct.py
diff options
context:
space:
mode:
authorMagnus Hagander2012-02-07 11:12:05 +0000
committerMagnus Hagander2012-02-07 11:12:05 +0000
commit17ffc371b9213ad51f8b0a3df40e33551bcb7af5 (patch)
treef3f5da3a3d4dc67cbb5e9687cad4da874ace87ce /pgweb/docs/struct.py
parent1cf436ac4f35843a68e2730fa4eee6c23b8a0e76 (diff)
Assign better priorities to docs pages for searching, and include older docs
Instead of just including supported versions, include older versions of the docs as well, and properly assign priorities by: * For current docs, always assign priority 1.0 * For any other docs, start at 0.8 for the latest and decrease priority by 0.1 for each version, until we reach 0.1. This should restore the ability to search for old versions of the documentation (they still get proper priorities when searching for suburls, which currently returns no hits at all) while maintaining a strong priority for the newer versions.
Diffstat (limited to 'pgweb/docs/struct.py')
-rw-r--r--pgweb/docs/struct.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/pgweb/docs/struct.py b/pgweb/docs/struct.py
index dcc66618..3728b6ae 100644
--- a/pgweb/docs/struct.py
+++ b/pgweb/docs/struct.py
@@ -9,12 +9,28 @@ def get_struct():
# Can't use a model here, because we don't (for some reason) have a
# hard link to the versions table here
curs = connection.cursor()
- curs.execute("SELECT d.version, d.file, v.docsloaded FROM docs d INNER JOIN core_version v ON v.tree=d.version WHERE v.supported")
+ curs.execute("SELECT d.version, d.file, v.docsloaded FROM docs d INNER JOIN core_version v ON v.tree=d.version WHERE d.version > 0 ORDER BY d.version DESC")
+
+ # Start priority is higher than average but lower than what we assign
+ # to the current version of the docs.
+ docprio = 0.8
+ lastversion = None
+
for version, filename, loaded in curs.fetchall():
+ # Decrease the priority with 0.1 for every version of the docs
+ # we move back in time, until we reach 0.1. At 0.1 it's unlikely
+ # to show up in a general search, but still possible to reach
+ # through version specific searching for example.
+ if lastversion != version:
+ if docprio > 0.2:
+ docprio -= 0.1
+ lastversion = version
+
yield ('docs/%s/static/%s' % (version, filename),
- None, loaded)
- #FIXME ^ do something smart with priorities on older
- #versions
+ docprio, loaded)
+
+ # Also yield the current version urls, with the highest
+ # possible priority
if version == currentversion.tree:
yield ('docs/current/static/%s' % filename,
1.0, loaded)