Пример #1
0
def repository(name: str):
    """Recommendations and other trends for a repository."""
    repo = Repository.query.filter(Repository.name == name).first_or_404()

    ranks = {'all': None, 'language': None}
    ranks['all'] = Ranking.query \
        .filter(Ranking.period == RankingPeriod.Recent) \
        .filter(Ranking.repo_id == repo.repo_id) \
        .filter(Ranking.language == "All") \
        .order_by(Ranking.start_date.desc()).first()

    if repo.language:
        ranks['language'] = Ranking.query \
            .filter(Ranking.period == RankingPeriod.Recent) \
            .filter(Ranking.repo_id == repo.repo_id) \
            .filter(Ranking.language == repo.language) \
            .order_by(Ranking.start_date.desc()).first()

    releases = Release.query \
        .filter(Release.repo_id == repo.repo_id) \
        .order_by(Release.created_at) \
        .all()

    from growser.models import Recommendation

    recommendations = Recommendation.find_by_repository(3, repo.repo_id, 100)

    return render("repository.html",
                  repo=repo,
                  releases=releases,
                  recommendations=recommendations,
                  ranks=ranks)
Пример #2
0
def find_recommendations(query: FindRecommendations) -> List[Recommendation]:
    query = Recommendation.find_by_repository(
        query.model, query.repo_id, query.limit)
    return query