mirror of
https://github.com/postgres/pgweb.git
synced 2025-07-29 11:59:36 +00:00
Store the git hash of developer docs loaded
This will require some further updates on the loading side of things before it's fully valid, but for now track and show a link to the git hash used to build developer docs *if* one is specified. We only track it for devel (because releases have release numbers) and we only show it in the cases where we would already show the loading time.
This commit is contained in:
18
pgweb/core/migrations/0006_version_docsgit.py
Normal file
18
pgweb/core/migrations/0006_version_docsgit.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.11 on 2022-06-20 18:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0005_remove_version_relnotes'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='version',
|
||||
name='docsgit',
|
||||
field=models.CharField(blank=True, help_text='The git hash of the loaded docs, for devel version', max_length=40),
|
||||
),
|
||||
]
|
@ -25,6 +25,7 @@ class Version(models.Model):
|
||||
supported = models.BooleanField(null=False, blank=False, default=True)
|
||||
testing = models.IntegerField(null=False, blank=False, default=0, help_text="Testing level of this release. latestminor indicates beta/rc number", choices=TESTING_CHOICES)
|
||||
docsloaded = models.DateTimeField(null=True, blank=True, help_text="The timestamp of the latest docs load. Used to control indexing and info on developer docs.")
|
||||
docsgit = models.CharField(max_length=40, null=False, blank=True, help_text="The git hash of the loaded docs, for devel version")
|
||||
firstreldate = models.DateField(null=False, blank=False, help_text="The date of the .0 release in this tree")
|
||||
eoldate = models.DateField(null=False, blank=False, help_text="The final release date for this tree")
|
||||
|
||||
|
@ -30,11 +30,14 @@ def _versioned_404(msg, version):
|
||||
@content_sources('style', "'unsafe-inline'")
|
||||
def docpage(request, version, filename):
|
||||
loaddate = None
|
||||
loadgit = None
|
||||
if version == 'current':
|
||||
ver = Version.objects.filter(current=True)[0].tree
|
||||
elif version == 'devel':
|
||||
ver = Decimal(0)
|
||||
loaddate = Version.objects.get(tree=Decimal(0)).docsloaded
|
||||
verobj = Version.objects.get(tree=Decimal(0))
|
||||
loaddate = verobj.docsloaded
|
||||
loadgit = verobj.docsgit
|
||||
else:
|
||||
ver = Decimal(version)
|
||||
if ver == Decimal(0):
|
||||
@ -155,6 +158,7 @@ def docpage(request, version, filename):
|
||||
'title': page.title,
|
||||
'doc_index_filename': indexname,
|
||||
'loaddate': loaddate,
|
||||
'loadgit': loadgit,
|
||||
'og': {
|
||||
'url': '/docs/{}/{}'.format(page.display_version(), page.file),
|
||||
'time': page.version.docsloaded,
|
||||
|
@ -80,7 +80,7 @@
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div>
|
||||
<a href="/docs/" title="Documentation">Documentation</a> → <a href="/docs/{{page.display_version}}/{{doc_index_filename}}">PostgreSQL {{page.display_version}}</a>{%if loaddate%} ({{loaddate|date:"Y-m-d H:i:s"}}){%endif%}
|
||||
<a href="/docs/" title="Documentation">Documentation</a> → <a href="/docs/{{page.display_version}}/{{doc_index_filename}}">PostgreSQL {{page.display_version}}</a>{%if loaddate%} ({{loaddate|date:"Y-m-d H:i:s"}}{%if loadgit%} - git commit <a href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h={{loadgit}}">{{loadgit}}</a>{%endif%}){%endif%}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -104,6 +104,8 @@ parser.add_option("-q", "--quiet", action="store_true", dest="quiet",
|
||||
help="Run quietly (no output at all)")
|
||||
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
||||
help="Run verbosely")
|
||||
parser.add_option("-g", "--git", type=str,
|
||||
help="Specify git hash used to load")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) != 2:
|
||||
@ -233,7 +235,15 @@ if not quiet:
|
||||
|
||||
if numchanges > 0:
|
||||
# Update the docs loaded timestamp
|
||||
curs.execute("UPDATE core_version SET docsloaded=CURRENT_TIMESTAMP WHERE tree=%(v)s", {'v': ver})
|
||||
if ver == "0" and options.git:
|
||||
githash = options.git
|
||||
else:
|
||||
githash = ''
|
||||
|
||||
curs.execute("UPDATE core_version SET docsloaded=CURRENT_TIMESTAMP, docsgit=%(git)s WHERE tree=%(v)s", {
|
||||
'v': ver,
|
||||
'git': githash,
|
||||
})
|
||||
|
||||
# Issue varnish purge for all docs of this version
|
||||
if ver == "0":
|
||||
|
Reference in New Issue
Block a user