Add a sitemap.txt for popular public repos

and reference it from the robots.txt
This commit is contained in:
Jake Moshenko 2016-06-17 13:52:27 -04:00
parent c712be05e2
commit a1cf12e460
11 changed files with 146 additions and 52 deletions

View file

@ -405,3 +405,15 @@ def confirm_email_authorization_for_repo(code):
return found
def list_popular_public_repos(action_count_threshold, time_span):
cutoff = datetime.now() - time_span
return (Repository
.select(Namespace.username, Repository.name)
.join(Namespace, on=(Repository.namespace_user == Namespace.id))
.switch(Repository)
.join(RepositoryActionCount)
.where(RepositoryActionCount.date >= cutoff,
Repository.visibility == get_public_repo_visibility())
.group_by(RepositoryActionCount.repository)
.having(fn.Sum(RepositoryActionCount.count) >= action_count_threshold)
.tuples())