Exemplo n.º 1
0
def get_signoff_groups(repos=None, user=None):
    if repos is None:
        repos = Repo.objects.filter(testing=True)
    repo_ids = [r.pk for r in repos]

    test_pkgs = Package.objects.select_related(
            'arch', 'repo', 'packager').filter(repo__in=repo_ids)
    packages = test_pkgs.order_by('pkgname')
    packages = attach_maintainers(packages)

    # Filter by user if asked to do so
    if user is not None:
        packages = [p for p in packages if user == p.packager
                or user in p.maintainers]

    # Collect all pkgbase values in testing repos
    pkgtorepo = get_target_repo_map(repos)

    # Collect all possible signoffs and specifications for these packages
    signoffs = get_current_signoffs(repos)
    specs = get_current_specifications(repos)

    same_pkgbase_key = lambda x: (x.repo.name, x.arch.name, x.pkgbase)
    grouped = groupby_preserve_order(packages, same_pkgbase_key)
    signoff_groups = []
    for group in grouped:
        signoff_group = PackageSignoffGroup(group)
        signoff_group.target_repo = pkgtorepo.get(signoff_group.pkgbase,
                "Unknown")
        signoff_group.find_signoffs(signoffs)
        signoff_group.find_specification(specs)
        signoff_groups.append(signoff_group)

    return signoff_groups
Exemplo n.º 2
0
def get_recent_updates(number=15, testing=True, staging=False):
    repos = Repo.objects.all()
    if not testing:
        repos = repos.exclude(testing=True)
    if not staging:
        repos = repos.exclude(staging=True)

    # This is a bit of magic. We are going to show 15 on the front page, but we
    # want to try and eliminate cross-architecture wasted space. Pull enough
    # packages that we can later do some screening and trim out the fat.
    pkgs = []
    # grab a few extra so we can hopefully catch everything we need
    fetch = number * 6
    for arch in Arch.objects.all():
        pkgs += list(Package.objects.normal().filter(
            arch=arch, repo__in=repos).order_by('-last_update')[:fetch])
    pkgs.sort(key=attrgetter('last_update'), reverse=True)

    same_pkgbase_key = lambda x: (x.repo.name, x.pkgbase)
    grouped = groupby_preserve_order(pkgs, same_pkgbase_key)

    updates = []
    for group in grouped:
        update = RecentUpdate(group)
        updates.append(update)

    return updates[:number]
Exemplo n.º 3
0
def get_signoff_groups(repos=None, user=None):
    if repos is None:
        repos = Repo.objects.filter(testing=True)
    repo_ids = [r.pk for r in repos]

    test_pkgs = Package.objects.select_related(
        'arch', 'repo', 'packager').filter(repo__in=repo_ids)
    packages = test_pkgs.order_by('pkgname')
    packages = attach_maintainers(packages)

    # Filter by user if asked to do so
    if user is not None:
        packages = [
            p for p in packages if user == p.packager or user in p.maintainers
        ]

    # Collect all pkgbase values in testing repos
    pkgtorepo = get_target_repo_map(repos)

    # Collect all possible signoffs and specifications for these packages
    signoffs = get_current_signoffs(repos)
    specs = get_current_specifications(repos)

    same_pkgbase_key = lambda x: (x.repo.name, x.arch.name, x.pkgbase)
    grouped = groupby_preserve_order(packages, same_pkgbase_key)
    signoff_groups = []
    for group in grouped:
        signoff_group = PackageSignoffGroup(group)
        signoff_group.target_repo = pkgtorepo.get(signoff_group.pkgbase,
                                                  "Unknown")
        signoff_group.find_signoffs(signoffs)
        signoff_group.find_specification(specs)
        signoff_groups.append(signoff_group)

    return signoff_groups
Exemplo n.º 4
0
def get_recent_updates(number=15, testing=True, staging=False):
    repos = Repo.objects.all()
    if not testing:
        repos = repos.exclude(testing=True)
    if not staging:
        repos = repos.exclude(staging=True)

    # This is a bit of magic. We are going to show 15 on the front page, but we
    # want to try and eliminate cross-architecture wasted space. Pull enough
    # packages that we can later do some screening and trim out the fat.
    pkgs = []
    # grab a few extra so we can hopefully catch everything we need
    fetch = number * 6
    for arch in Arch.objects.all():
        pkgs += list(Package.objects.normal().filter(
            arch=arch, repo__in=repos).order_by('-last_update')[:fetch])
    pkgs.sort(key=attrgetter('last_update'), reverse=True)

    same_pkgbase_key = lambda x: (x.repo.name, x.pkgbase)
    grouped = groupby_preserve_order(pkgs, same_pkgbase_key)

    updates = []
    for group in grouped:
        update = RecentUpdate(group)
        updates.append(update)

    return updates[:number]