home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

7 rows where author_association = "OWNER" and "updated_at" is on date 2021-08-12 sorted by updated_at descending

✖
✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: issue_url, reactions, created_at (date), updated_at (date)

issue 2

  • Support column descriptions in metadata.json 6
  • UI for setting `?_size=max` on table page 1

user 1

  • simonw 7

author_association 1

  • OWNER · 7 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
898050457 https://github.com/simonw/datasette/issues/942#issuecomment-898050457 https://api.github.com/repos/simonw/datasette/issues/942 IC_kwDOBm6k_c41hymZ simonw 9599 2021-08-12T23:59:53Z 2021-08-12T23:59:53Z OWNER

Documentation: https://docs.datasette.io/en/latest/metadata.html#column-descriptions

Live demo: https://latest.datasette.io/fixtures/roadside_attractions

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support column descriptions in metadata.json 681334912  
898037650 https://github.com/simonw/datasette/issues/942#issuecomment-898037650 https://api.github.com/repos/simonw/datasette/issues/942 IC_kwDOBm6k_c41hveS simonw 9599 2021-08-12T23:23:54Z 2021-08-12T23:23:54Z OWNER

I like this enough that I'm going to ship it as an alpha and try it out on a couple of live projects.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support column descriptions in metadata.json 681334912  
898037456 https://github.com/simonw/datasette/issues/942#issuecomment-898037456 https://api.github.com/repos/simonw/datasette/issues/942 IC_kwDOBm6k_c41hvbQ simonw 9599 2021-08-12T23:23:34Z 2021-08-12T23:23:34Z OWNER

Prototype with a <dl>:

```diff diff --git a/datasette/static/app.css b/datasette/static/app.css index c6be1e9..bf068fd 100644 --- a/datasette/static/app.css +++ b/datasette/static/app.css @@ -836,6 +841,16 @@ svg.dropdown-menu-icon { background-repeat: no-repeat; }

+dl.column-descriptions dt { + font-weight: bold; +} +dl.column-descriptions dd { + padding-left: 1.5em; + white-space: pre-wrap; + line-height: 1.1em; + color: #666; +} + .anim-scale-in { animation-name: scale-in; animation-duration: 0.15s; diff --git a/datasette/templates/table.html b/datasette/templates/table.html index 211352b..466e8a4 100644 --- a/datasette/templates/table.html +++ b/datasette/templates/table.html @@ -51,6 +51,14 @@

{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}

+{% if metadata.columns %} +<dl class="column-descriptions"> + {% for column_name, column_description in metadata.columns.items() %} + <dt>{{ column_name }}</dt><dd>{{ column_description }}</dd> + {% endfor %} +</dl> +{% endif %} + {% if filtered_table_rows_count or human_description_en %}

{% if filtered_table_rows_count or filtered_table_rows_count == 0 %}{{ "{:,}".format(filtered_table_rows_count) }} row{% if filtered_table_rows_count == 1 %}{% else %}s{% endif %}{% endif %} {% if human_description_en %}{{ human_description_en }}{% endif %} ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support column descriptions in metadata.json 681334912  
898022235 https://github.com/simonw/datasette/issues/942#issuecomment-898022235 https://api.github.com/repos/simonw/datasette/issues/942 IC_kwDOBm6k_c41hrtb simonw 9599 2021-08-12T22:52:23Z 2021-08-12T22:52:23Z OWNER

I like this. Need to solve for mobile though where the cog menu isn't visible - I think I'll do that with a definition list at the top of the page.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support column descriptions in metadata.json 681334912  
898021895 https://github.com/simonw/datasette/issues/942#issuecomment-898021895 https://api.github.com/repos/simonw/datasette/issues/942 IC_kwDOBm6k_c41hroH simonw 9599 2021-08-12T22:51:36Z 2021-08-12T22:51:36Z OWNER

Prototype:

``diff diff --git a/datasette/static/app.css b/datasette/static/app.css index c6be1e9..5ca64cb 100644 --- a/datasette/static/app.css +++ b/datasette/static/app.css @@ -784,9 +784,14 @@ svg.dropdown-menu-icon { font-size: 0.7em; color: #666; margin: 0; - padding: 0; padding: 4px 8px 4px 8px; } +.dropdown-menu .dropdown-column-description { + margin: 0; + color: #666; + padding: 4px 8px 4px 8px; + max-width: 20em; +} .dropdown-menu li { border-bottom: 1px solid #ccc; } diff --git a/datasette/static/table.js b/datasette/static/table.js index 991346d..a903112 100644 --- a/datasette/static/table.js +++ b/datasette/static/table.js @@ -9,6 +9,7 @@ var DROPDOWN_HTML =


  • Show not-blank rows
  • +

    `;

    var DROPDOWN_ICON_SVG = <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> @@ -166,6 +167,14 @@ var DROPDOWN_ICON_SVG =<svg xmlns="http://www.w3.org/2000/svg" width="14" heig } else { columnTypeP.style.display = "none"; } + + var columnDescriptionP = menu.querySelector(".dropdown-column-description"); + if (th.dataset.columnDescription) { + columnDescriptionP.innerText = th.dataset.columnDescription; + columnDescriptionP.style.display = 'block'; + } else { + columnDescriptionP.style.display = 'none'; + } menu.style.position = "absolute"; menu.style.top = menuTop + 6 + "px"; menu.style.left = menuLeft + "px"; diff --git a/datasette/templates/table.html b/datasette/templates/_table.html index d765937..649f517 100644 --- a/datasette/templates/_table.html +++ b/datasette/templates/_table.html @@ -4,7 +4,7 @@ <thead> <tr> {% for column in display_columns %} - <th class="col-{{ column.name|to_css_class }}" scope="col" data-column="{{ column.name }}" data-column-type="{{ column.type }}" data-column-not-null="{{ column.notnull }}" data-is-pk="{% if column.is_pk %}1{% else %}0{% endif %}"> + <th {% if column.description %}data-column-description="{{ column.description }}" {% endif %}class="col-{{ column.name|to_css_class }}" scope="col" data-column="{{ column.name }}" data-column-type="{{ column.type }}" data-column-not-null="{{ column.notnull }}" data-is-pk="{% if column.is_pk %}1{% else %}0{% endif %}"> {% if not column.sortable %} {{ column.name }} {% else %} diff --git a/datasette/views/table.py b/datasette/views/table.py index 456d806..486a613 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -125,6 +125,7 @@ class RowTableShared(DataView): """Returns columns, rows for specified table - including fancy foreign key treatment""" db = self.ds.databases[database] table_metadata = self.ds.table_metadata(database, table) + column_descriptions = table_metadata.get("columns") or {} column_details = {col.name: col for col in await db.table_column_details(table)} sortable_columns = await self.sortable_columns_for_table(database, table, True) pks = await db.primary_keys(table) @@ -147,6 +148,7 @@ class RowTableShared(DataView): "is_pk": r[0] in pks_for_display, "type": type, "notnull": notnull, + "description": column_descriptions.get(r[0]), } )

    ```

    {
        "total_count": 0,
        "+1": 0,
        "-1": 0,
        "laugh": 0,
        "hooray": 0,
        "confused": 0,
        "heart": 0,
        "rocket": 0,
        "eyes": 0
    }
    Support column descriptions in metadata.json 681334912  
    897996296 https://github.com/simonw/datasette/issues/942#issuecomment-897996296 https://api.github.com/repos/simonw/datasette/issues/942 IC_kwDOBm6k_c41hlYI simonw 9599 2021-08-12T22:01:36Z 2021-08-12T22:01:36Z OWNER

    I'm going with "columns": {"name-of-column": "description-of-column"}.

    If I decide to make "col" and "nocol" available in metadata I'll use those as the keys in the metadata, for consistency with the existing query string parameters.

    I'm OK with having both "columns": ... and "col": ... keys in the metadata, even though they could be a tiny bit confusing without the documentation.

    {
        "total_count": 1,
        "+1": 1,
        "-1": 0,
        "laugh": 0,
        "hooray": 0,
        "confused": 0,
        "heart": 0,
        "rocket": 0,
        "eyes": 0
    }
    Support column descriptions in metadata.json 681334912  
    897960049 https://github.com/simonw/datasette/issues/1429#issuecomment-897960049 https://api.github.com/repos/simonw/datasette/issues/1429 IC_kwDOBm6k_c41hchx simonw 9599 2021-08-12T20:53:04Z 2021-08-12T20:53:04Z OWNER

    Maybe something like this:

    Next page - 100 per page (show 1,000 per page)

    {
        "total_count": 0,
        "+1": 0,
        "-1": 0,
        "laugh": 0,
        "hooray": 0,
        "confused": 0,
        "heart": 0,
        "rocket": 0,
        "eyes": 0
    }
    UI for setting `?_size=max` on table page 969548935  

    Advanced export

    JSON shape: default, array, newline-delimited, object

    CSV options:

    CREATE TABLE [issue_comments] (
       [html_url] TEXT,
       [issue_url] TEXT,
       [id] INTEGER PRIMARY KEY,
       [node_id] TEXT,
       [user] INTEGER REFERENCES [users]([id]),
       [created_at] TEXT,
       [updated_at] TEXT,
       [author_association] TEXT,
       [body] TEXT,
       [reactions] TEXT,
       [issue] INTEGER REFERENCES [issues]([id])
    , [performed_via_github_app] TEXT);
    CREATE INDEX [idx_issue_comments_issue]
                    ON [issue_comments] ([issue]);
    CREATE INDEX [idx_issue_comments_user]
                    ON [issue_comments] ([user]);
    Powered by Datasette · Queries took 1086.376ms · About: github-to-sqlite
    • Sort ascending
    • Sort descending
    • Facet by this
    • Hide this column
    • Show all columns
    • Show not-blank rows