<html>
  <head>
    <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
  </head>
  <body>
    <div align="center">
      <h2>Build Command Statistics - Prototype</h2>
      <p>
        This is an admittedly primitive interface to the build command
        statistics gathered every time a build command (currently just
        build_packages) is run in golo.chromium.org or corp.google.com.
        Submit suggestions for enhancements, at
        <a href="http://goo.gl/mod/plg0">this google.com dory page</a>.
      </p>
      <p>
        Create
        <a href="https://developers.google.com/appengine/docs/python/datastore/gqlreference">GCL queries</a>
        to search the statistics database.  GCL has no SELECT or FROM clauses.  This site
        supports a SQL-like SELECT clause for column filtering, but no FROM clause is
        needed/supported.  If no SELECT clause is given then default columns are selected
        (see below).  A default LIMIT 30 is used unless otherwise specified.
      </p>
    </div>

    <hr>
    <h3>Prepare a new query</h3>
    <form action="/stats" method="get">
      <h5>Write your own query</h5>
      <div><textarea name="query" rows="2" cols="100">{{ user_query }}</textarea></div>
      <div><input type="submit" value="Submit Query"></div>
    </form>

    <form action="/stats" method="get">
      <h5>Select an example query</h5>
      <div>
        <select name="query">
          {% for example_query in example_queries %}
            <option>{{ example_query }}</option>
          {% endfor %}
        </select>
      </div>
      <div><input type="submit" value="Submit Query"></div>
    </form>

    <hr>
    <div><h3>Query results</h3></div>
    <div>For query: <b>{{ user_query }}</b></div>
    <p/>
    {% if error_msg %}
    <b><font color="red">{{ error_msg }}</font></b>
    {% else %}
    <table border="1">{{ results_table }}</table>
    {% endif %}
    <p/>

    <hr>
    <div><h3>Database columns available</h3></div>
    Columns selected by default in <b>bold</b>.
    <ul>{{ column_list }}</ul>

    <hr>
    <div align="center">
      Signed in as <b>{{ user_email }}</b>
    </div>
  </body>
</html>
