306:edefddec933d
Anton Shestakov <av6@dwimlabs.net>, Sun, 24 Sep 2017 12:25:05 +0800
viewer: use subqueries to get data on index page Before, there were bare columns in the aggregate query, their values were undefined (but it somehow worked), as SQLite docs say. Good news is that now this bigger query uses (project_id, ordinal) index and is really fast.

previous change 254:dca6cd4682e3

candolint/adapters.py

Permissions: -rw-r--r--

Other formats: Feeds:
from os.path import basename
class HostingAdapter(object):
def __init__(self, project):
self.project = project
def get_commit_url(self, change):
return '#'
def get_branch_url(self, change):
return '#'
def get_line_url(self, change, line):
return '#'
class BitbucketAdapter(HostingAdapter):
def get_commit_url(self, change):
return '{url}/commits/{node}'.format(**{
'url': self.project.url,
'node': change.node
})
def get_branch_url(self, change):
return '{url}/branch/{branch}'.format(**{
'url': self.project.url,
'branch': change.branch
})
def get_line_url(self, change, line):
return '{url}/src/{node}/{filename}#{basename}-{line}'.format(**{
'url': self.project.url,
'node': change.node,
'filename': line['filename'],
'basename': basename(line['filename']),
'line': line['line_number']
})
class GithubAdapter(HostingAdapter):
def get_commit_url(self, change):
return '{url}/commit/{node}'.format(**{
'url': self.project.url,
'node': change.node
})
def get_branch_url(self, change):
return '{url}/tree/{branch}'.format(**{
'url': self.project.url,
'branch': change.branch
})
def get_line_url(self, change, line):
return '{url}/blob/{node}/{filename}#L{line}'.format(**{
'url': self.project.url,
'node': change.node,
'filename': line['filename'],
'line': line['line_number']
})
class HgwebAdapter(HostingAdapter):
def get_commit_url(self, change):
return '{url}/rev/{node}'.format(**{
'url': self.project.url,
'node': change.node
})
def get_branch_url(self, change):
return '{url}/log/{branch}'.format(**{
'url': self.project.url,
'branch': change.branch
})
def get_line_url(self, change, line):
return '{url}/file/{node}/{filename}#l{line}'.format(**{
'url': self.project.url,
'node': change.node,
'filename': line['filename'],
'line': line['line_number']
})