Adrien Nader has proposed merging ~adrien/autopkgtest-cloud:browse-recent into autopkgtest-cloud:master.
Commit message: feat: /recent.html page similar in content to the user page Introduce a page with recent results to make it possible to keep up with changes as they are happening. Ideally, people who re-trigger tests would check it before re-triggering tests. Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~adrien/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/482377 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~adrien/autopkgtest-cloud:browse-recent into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi index 6a6e20d..19d7b0f 100755 --- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi +++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi @@ -211,7 +211,7 @@ def db_has_result_requester_idx(cursor: sqlite3.Cursor): return False -def get_results_for_user(user: str, limit: int, offset: int) -> list: +def get_results(limit: int, offset: int = 0, user: str = None) -> list: results = [] # We want to use sqlite3.Row here, so we need to create a cursor # as to not affect the overall db_con object, which could interfere @@ -222,9 +222,9 @@ def get_results_for_user(user: str, limit: int, offset: int) -> list: for row in cursor.execute( "SELECT test_id, run_id, version, triggers, " "duration, exitcode, requester, env, uuid FROM result " - "WHERE requester=:user " "ORDER BY run_id DESC " - "LIMIT :limit OFFSET :offset ", + "LIMIT :limit OFFSET :offset " + + ("WHERE requester=:user " if user else ""), { "user": user, "limit": limit, @@ -526,7 +526,7 @@ def user_overview(user): # Get results for this user if show_results: - previous_test_results = get_results_for_user(user, limit, offset) + previous_test_results = get_results(limit, offset, user) else: previous_test_results = [] @@ -553,6 +553,38 @@ def user_overview(user): ) +@app.route("/recent") +def recent(): + """ + This endpoint provides recent results where recent means that the test is + among the last limit results (default = 100 and 0 < limit <= 10000). + The page includes details such as version, triggers, requester, result, + log, ... + """ + + args = flask.request.args + try: + limit = int(args.get("limit", 100)) + assert isinstance(limit, int) + assert limit > 0 + assert limit <= 10000 + except (AssertionError, ValueError): + limit = 100 + + offset = 0 + + previous_test_results = get_results(limit, offset) + + return render( + "browse-recent.html", + running_tests=[], + queued_tests=[], + previous_test_results=previous_test_results, + limit=limit, + offset=offset, + ) + + @app.route("/user/<user>/ppa") def list_user_ppas(user): ppa_containers = load_ppa_cache() diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-recent.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-recent.html new file mode 100644 index 0000000..228a31a --- /dev/null +++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-recent.html @@ -0,0 +1,52 @@ +{% extends "browse-layout.html" %} +{% import "macros.html" as macros %} + +{% macro display_user_test_info(user_results) -%} + <table class="table"> + <tr> + <td> + <b>Package</b> + </td> + <td> + <b>Release</b> + </td> + <td> + <b>Arch</b> + </td> + {{ macros.set_up_results_table() }} + </tr> + {% for row in user_results %} + <tr {% if row[6] in ["running", "queued"] %}class="unfinished"{% endif %}> + {% set package = row[11] %} + {% set release = row[12] %} + {% set arch = row[13] %} + <td>{{ package }}</td> + <td>{{ release }}</td> + <td>{{ arch }}</td> + {{ macros.results_table_core(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], package, release, arch) }} + </tr> + {% endfor %} + </table> +{%- endmacro %} + +{% block content %} + <h1 class="page-header" id="user-home"> + Test results +</h1> + +{% if previous_test_results %} + <h2 id="results-complete">Test Results</h2> + <p>Results {{ offset }} to {{ offset + limit }}</p> + {{ display_user_test_info(previous_test_results) }} + + <nav class="page-links links"> + {% if offset != 0 %} + <a href="{{ base_url }}user/{{ user }}?offset={{ offset - limit }}&limit={{ limit }}">Previous page</a> + {% endif %} + <a href="{{ base_url }}user/{{ user }}?offset={{ offset + limit }}&limit={{ limit }}">Next page</a> + <br> + <a href="{{ base_url }}user/{{ user }}?limit=10000">Show more results</a> + </nav> +{% endif %} + +{% endblock content %} diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html index dc709e4..1ff5715 100644 --- a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html +++ b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html @@ -111,10 +111,10 @@ <td>{{ date }}</td> <td>{{ duration }}</td> <td> - {% if requester != "-" %} + {% if requester != None and requester != "-" %} <a href="https://launchpad.net/~{{ requester }}">{{ requester }}</a> {% else %} - {{ requester }} + - {% endif %} </td> <td class="nowrap {{ code }}" title={{ code }}>{{ code }} diff --git a/docs/developing.rst b/docs/developing.rst new file mode 100644 index 0000000..2f86344 --- /dev/null +++ b/docs/developing.rst @@ -0,0 +1,10 @@ +Developing autopkgtest-cloud +=========================== + +Set up environments +------------------- + +Documentation on how to set up development environments live in the directories +for the matching charms. At the time of writing, this includes: +* ./charms/focal/autopkgtest-cloud-worker/README.md +* ./charms/focal/autopkgtest-web/webcontrol/README.md diff --git a/docs/index.rst b/docs/index.rst index 2a62979..384f9eb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,4 +12,5 @@ Ubuntu. Ubuntu's instances can be viewed `here lxd webcontrol deploying + development docs
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp