示例#1
0
def index():
    # packages by distro
    # XXX think about moving this to the model
    distro_packages = db_session.query(
        Distro.distro_name, func.count(SubmissionPackage.pkg_name)
    ).select_from(
        SubmissionPackage
    ).join(
        Submission
    ).join(
        Distro
    ).group_by(Distro.distro_name).all()

    # number of submissions per distribution
    submissions_distrover = db_session.query(
        Submission.distro_name + ' ' + Submission.distro_version,
        func.count(Submission.sub_id)
        ).group_by(Submission.distro_name, Submission.distro_version).all()

    # transform the list of tuples returned by SQLA into a nested JS array
    distro_packages = json.dumps(distro_packages)
    submissions_distrover = json.dumps(submissions_distrover)

    return dict(distro_packages=distro_packages,
                submissions_distrover=submissions_distrover)
示例#2
0
def update_archives(arc_month=LAST_MONTH):
    """Archives packages of a month, by default: last month"""
    query = db_session.query(SubPac.pkg_name, SubPac.pkg_version,
                             SubPac.pkg_release, SubPac.pkg_arch,
                             SubPac.vendor_name, SubPac.pkg_status,
                             Sub.distro_name, Sub.distro_version,
                             func.min(SubPac.sub_date),
                             func.count('*').label('count')
                             ).join(Sub)

    arcs = query.filter(extract('month', SubPac.sub_date) == arc_month.month,
                        extract('year', SubPac.sub_date) == arc_month.year
                        ).group_by(extract('month', SubPac.sub_date),
                                   extract('year', SubPac.sub_date),
                                   SubPac.pkg_name, SubPac.pkg_version,
                                   SubPac.pkg_release, SubPac.pkg_arch,
                                   SubPac.vendor_name,
                                   SubPac.pkg_status, Sub.distro_name,
                                   Sub.distro_version).all()
    pkg_archives = []
    for pkg in arcs:
        pkg_archive = PackageArchive(*pkg)
        pkg_archive.month = pkg_archive.month.replace(day=1)
        pkg_archives.append(pkg_archive)

    db_session.add_all(pkg_archives)
    db_session.commit()
示例#3
0
def package(name, version, release, arch, epoch=''):
    """Return a Package object"""

    pkgs = SubmissionPackage.query.filter_by(pkg_name=name,
                                             pkg_version=version,
                                             pkg_release=release,
                                             pkg_epoch=epoch,
                                             pkg_arch=arch).all()
    if not pkgs:
        abort(404)

    pkg_statuses = db_session.query(
        SubmissionPackage.pkg_status,
        func.count(SubmissionPackage.pkg_status)).filter_by(
            pkg_name=name,
            pkg_version=version,
            pkg_release=release,
            pkg_epoch=epoch,
            pkg_arch=arch).group_by(SubmissionPackage.pkg_status).all()
    statuses = dict()
    for k, v in pkg_statuses:
        statuses[k] = v
    print statuses

    return dict(generic_package=pkgs[0].serialize,
                packages=[i.serialize for i in pkgs],
                **statuses)
示例#4
0
def index():
    # packages by distro
    # XXX think about moving this to the model
    distro_packages = db_session.query(
        Distro.distro_name, func.count(
            SubmissionPackage.pkg_name)).select_from(SubmissionPackage).join(
                Submission).join(Distro).group_by(Distro.distro_name).all()

    # number of submissions per distribution
    submissions_distrover = db_session.query(
        Submission.distro_name + ' ' + Submission.distro_version,
        func.count(Submission.sub_id)).group_by(
            Submission.distro_name, Submission.distro_version).all()

    # transform the list of tuples returned by SQLA into a nested JS array
    distro_packages = json.dumps(distro_packages)
    submissions_distrover = json.dumps(submissions_distrover)

    return dict(distro_packages=distro_packages,
                submissions_distrover=submissions_distrover)
示例#5
0
def index():
    distros = Distro.query.all()
    vendors = Vendor.query.all()

    # packages by distro
    # XXX think about moving this to the model
    distro_packages = db_session.query(
        Distro.distro_name, func.count(SubmissionPackage.pkg_name)
        ).select_from(SubmissionPackage).join(System).join(Distro
        ).group_by(Distro.distro_name).all()

    # transform the list of tuples returned by SQLA into a nested JS array
    distro_packages = json.dumps(distro_packages)
    return dict(distros=[i.serialize for i in distros], vendors=[i.serialize
                for i in vendors], distro_packages=distro_packages)
示例#6
0
def distro_doc():
    """Document the Distro related API functions

    Also returns a nested list of [distrovers, number of submissions] pairs.

    """
    # number of submissions per distribution
    submissions_distrover = db_session.query(
        Submission.distro_name + ' ' + Submission.distro_version,
        func.count(Submission.sub_id)
        ).group_by(Submission.distro_name, Submission.distro_version).all()

    # transform the list of tuples returned by SQLA into a nested JS array
    submissions_distrover = json.dumps(submissions_distrover)

    return dict(submissions_distrover=submissions_distrover)
示例#7
0
def distro_doc():
    """Document the Distro related API functions

    Also returns a nested list of [distrovers, number of submissions] pairs.

    """
    # number of submissions per distribution
    submissions_distrover = db_session.query(
        Submission.distro_name + ' ' + Submission.distro_version,
        func.count(Submission.sub_id)).group_by(
            Submission.distro_name, Submission.distro_version).all()

    # transform the list of tuples returned by SQLA into a nested JS array
    submissions_distrover = json.dumps(submissions_distrover)

    return dict(submissions_distrover=submissions_distrover)
示例#8
0
def index():
    distros = Distro.query.all()
    vendors = Vendor.query.all()

    # packages by distro
    # XXX think about moving this to the model
    distro_packages = (
        db_session.query(Distro.distro_name, func.count(SubmissionPackage.pkg_name))
        .select_from(SubmissionPackage)
        .join(System)
        .join(Distro)
        .group_by(Distro.distro_name)
        .all()
    )

    # transform the list of tuples returned by SQLA into a nested JS array
    distro_packages = json.dumps(distro_packages)
    return render_template("index.html", distros=distros, vendors=vendors, distro_packages=distro_packages)
示例#9
0
def package(name, version, release, arch, epoch=""):
    """Return a Package object"""

    pkgs = SubmissionPackage.query.filter_by(
        pkg_name=name, pkg_version=version, pkg_release=release, pkg_epoch=epoch, pkg_arch=arch
    ).all()
    if not pkgs:
        abort(404)

    pkg_statuses = (
        db_session.query(SubmissionPackage.pkg_status, func.count(SubmissionPackage.pkg_status))
        .filter_by(pkg_name=name, pkg_version=version, pkg_release=release, pkg_epoch=epoch, pkg_arch=arch)
        .group_by(SubmissionPackage.pkg_status)
        .all()
    )
    statuses = dict()
    for k, v in pkg_statuses:
        statuses[k] = v
    print statuses

    return render_template("packages.html", generic_package=pkgs[0], packages=pkgs, **statuses)
示例#10
0
def package(name, version, release, arch, epoch=''):
    """Return a Package object"""

    pkgs = SubmissionPackage.query.filter_by(
        pkg_name=name, pkg_version=version, pkg_release=release,
        pkg_epoch=epoch, pkg_arch=arch).all()
    if not pkgs:
        abort(404)

    pkg_statuses = db_session.query(
        SubmissionPackage.pkg_status, func.count(SubmissionPackage.pkg_status)
        ).filter_by(
        pkg_name=name, pkg_version=version, pkg_release=release,
        pkg_epoch=epoch, pkg_arch=arch
        ).group_by(
            SubmissionPackage.pkg_status).all()
    statuses = dict()
    for k, v in pkg_statuses:
        statuses[k] = v
    print statuses

    return dict(generic_package=pkgs[0].serialize, packages=[i.serialize
        for i in pkgs], **statuses)