def coprs_by_user(username=None, page=1): user = users_logic.UsersLogic.get(username).first() if not user: return page_not_found("User {0} does not exist.".format(username)) pinned = [pin.copr for pin in PinnedCoprsLogic.get_by_user_id(user.id) ] if page == 1 else [] query = CoprsLogic.get_multiple_owned_by_username(username) query = CoprsLogic.filter_without_ids(query, [copr.id for copr in pinned]) query = CoprsLogic.filter_without_group_projects(query) query = CoprsLogic.set_query_order(query, desc=True) paginator = helpers.Paginator(query, query.count(), page) coprs = paginator.sliced_query # flask.g.user is none when no user is logged - showing builds from everyone users_builds = builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 4) data = builds_logic.BuildsLogic.get_small_graph_data('30min') return flask.render_template("coprs/show/user.html", user=user, coprs=coprs, pinned=pinned, paginator=paginator, tasks_info=ComplexLogic.get_queue_sizes(), users_builds=users_builds, graph=data)
def api_coprs_by_owner(username=None): """ Return the list of coprs owned by the given user. username is taken either from GET params or from the URL itself (in this order). :arg username: the username of the person one would like to the coprs of. """ username = flask.request.args.get("username", None) or username if username is None: raise LegacyApiError("Invalid request: missing `username` ") release_tmpl = "{chroot.os_release}-{chroot.os_version}-{chroot.arch}" if username.startswith("@"): group_name = username[1:] query = CoprsLogic.get_multiple() query = CoprsLogic.filter_by_group_name(query, group_name) else: query = CoprsLogic.get_multiple_owned_by_username(username) query = CoprsLogic.join_builds(query) query = CoprsLogic.set_query_order(query) repos = query.all() output = {"output": "ok", "repos": []} for repo in repos: yum_repos = {} for build in repo.builds: # FIXME in new api! for chroot in repo.active_chroots: release = release_tmpl.format(chroot=chroot) yum_repos[release] = fix_protocol_for_backend( os.path.join(build.copr.repo_url, release + '/')) break output["repos"].append({ "name": repo.name, "additional_repos": repo.repos, "yum_repos": yum_repos, "description": repo.description, "instructions": repo.instructions, "persistent": repo.persistent, "unlisted_on_hp": repo.unlisted_on_hp, "auto_prune": repo.auto_prune, }) return flask.jsonify(output)
def coprs_show(page=1): query = CoprsLogic.get_multiple() query = CoprsLogic.set_query_order(query, desc=True) paginator = helpers.Paginator(query, query.count(), page) coprs = paginator.sliced_query # flask.g.user is none when no user is logged - showing builds from everyone # TODO: builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 5) takes too much time, optimize sql # users_builds = builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 5) users_builds = builds_logic.BuildsLogic.get_recent_tasks(None, 5) return flask.render_template("coprs/show/all.html", coprs=coprs, paginator=paginator, tasks_info=ComplexLogic.get_queues_size(), users_builds=users_builds)
def coprs_show(page=1): query = CoprsLogic.get_multiple(include_unlisted_on_hp=False) query = CoprsLogic.set_query_order(query, desc=True) paginator = helpers.Paginator(query, query.count(), page) coprs = paginator.sliced_query # flask.g.user is none when no user is logged - showing builds from everyone # TODO: builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 5) takes too much time, optimize sql # users_builds = builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 5) users_builds = builds_logic.BuildsLogic.get_recent_tasks(None, 5) return flask.render_template("coprs/show/all.html", coprs=coprs, paginator=paginator, tasks_info=ComplexLogic.get_queues_size(), users_builds=users_builds)
def api_coprs_by_owner(username=None): """ Return the list of coprs owned by the given user. username is taken either from GET params or from the URL itself (in this order). :arg username: the username of the person one would like to the coprs of. """ username = flask.request.args.get("username", None) or username if username is None: raise LegacyApiError("Invalid request: missing `username` ") release_tmpl = "{chroot.os_release}-{chroot.os_version}-{chroot.arch}" if username.startswith("@"): group_name = username[1:] query = CoprsLogic.get_multiple() query = CoprsLogic.filter_by_group_name(query, group_name) else: query = CoprsLogic.get_multiple_owned_by_username(username) query = CoprsLogic.join_builds(query) query = CoprsLogic.set_query_order(query) repos = query.all() output = {"output": "ok", "repos": []} for repo in repos: yum_repos = {} for build in repo.builds: if build.results: for chroot in repo.active_chroots: release = release_tmpl.format(chroot=chroot) yum_repos[release] = fix_protocol_for_backend( os.path.join(build.results, release + '/')) break output["repos"].append({"name": repo.name, "additional_repos": repo.repos, "yum_repos": yum_repos, "description": repo.description, "instructions": repo.instructions}) return flask.jsonify(output)
def coprs_by_user(username=None, page=1): user = users_logic.UsersLogic.get(username).first() if not user: return page_not_found("User {0} does not exist.".format(username)) query = CoprsLogic.get_multiple_owned_by_username(username) query = CoprsLogic.filter_without_group_projects(query) query = CoprsLogic.set_query_order(query, desc=True) paginator = helpers.Paginator(query, query.count(), page) coprs = paginator.sliced_query # flask.g.user is none when no user is logged - showing builds from everyone users_builds = builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 5) return flask.render_template("coprs/show/user.html", user=user, coprs=coprs, paginator=paginator, tasks_info=ComplexLogic.get_queues_size(), users_builds=users_builds)
def coprs_by_owner(username=None, page=1): user = users_logic.UsersLogic.get(username).first() if not user: return page_not_found( "User {0} does not exist.".format(username)) query = CoprsLogic.get_multiple_owned_by_username(username) query = CoprsLogic.filter_without_group_projects(query) query = CoprsLogic.set_query_order(query, desc=True) paginator = helpers.Paginator(query, query.count(), page) coprs = paginator.sliced_query # flask.g.user is none when no user is logged - showing builds from everyone users_builds = builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 5) return flask.render_template("coprs/show/user.html", user=user, coprs=coprs, paginator=paginator, tasks_info=ComplexLogic.get_queues_size(), users_builds=users_builds)