home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

13 rows where author_association = "OWNER", issue = 681334912 and user = 9599 sorted by updated_at descending

✖
✖
✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 1

  • simonw · 13 ✖

issue 1

  • Support column descriptions in metadata.json · 13 ✖

author_association 1

  • OWNER · 13 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
898051645 https://github.com/simonw/datasette/issues/942#issuecomment-898051645 https://api.github.com/repos/simonw/datasette/issues/942 IC_kwDOBm6k_c41hy49 simonw 9599 2021-08-13T00:02:25Z 2021-08-13T00:02:25Z OWNER

And on mobile:

{
    "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  
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  
    737463116 https://github.com/simonw/datasette/issues/942#issuecomment-737463116 https://api.github.com/repos/simonw/datasette/issues/942 MDEyOklzc3VlQ29tbWVudDczNzQ2MzExNg== simonw 9599 2020-12-02T20:02:10Z 2020-12-02T20:03:01Z OWNER

    My idea is that if you installed my proposed plugin you wouldn't need metadata.json at all - your metadata would instead live in a table in the connected SQLite database files - either one table per database (so the metadata can live in the same place as the data) or maybe also in a dedicated separate database file, for if you want to add metadata to an otherwise read-only database.

    The plugin would then provide a UI for editing that metadata - maybe by configuring some writable canned queries or maybe something more custom than that. Or you could edit the metadata by manually editing the SQLite database file (or loading data into it using a tool like yaml-to-sqlite).

    {
        "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  
    737402392 https://github.com/simonw/datasette/issues/942#issuecomment-737402392 https://api.github.com/repos/simonw/datasette/issues/942 MDEyOklzc3VlQ29tbWVudDczNzQwMjM5Mg== simonw 9599 2020-12-02T18:08:55Z 2020-12-02T18:08:55Z OWNER

    SQLite does let you add comments in your CREATE TABLE statements: sql CREATE TABLE something ( id integer primary key, -- integer primary key created text -- created date as ISO datetime ); But the only mechanism for reading those back is to retrieve that CREATE TABLE block of SQL from the sqlite_master table and run a parser against it.

    I've so far resisted adding a SQL syntax parser to Datasette for complexity reasons - though I'm increasingly thinking I'll need to do it at some point.

    I think I'll leave this to plugins. I'm definitely going to build a plugin that lets you store metadata for tables and columns in a SQLite database table, which will then support interactively editing metadata through a UI.

    A plugin which extracts column comments from the SQLite CREATE TABLE comments would be feasible too, if I design the plugin hooks well.

    {
        "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  
    727626657 https://github.com/simonw/datasette/issues/942#issuecomment-727626657 https://api.github.com/repos/simonw/datasette/issues/942 MDEyOklzc3VlQ29tbWVudDcyNzYyNjY1Nw== simonw 9599 2020-11-15T19:54:44Z 2020-11-15T19:54:44Z OWNER

    This will also benefit from the metadata plugin hook: #860

    {
        "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  
    675720040 https://github.com/simonw/datasette/issues/942#issuecomment-675720040 https://api.github.com/repos/simonw/datasette/issues/942 MDEyOklzc3VlQ29tbWVudDY3NTcyMDA0MA== simonw 9599 2020-08-18T21:05:24Z 2020-08-18T21:05:24Z OWNER

    Is columns the right key for this in the table metadata block? I might want to use that for initial values for ?_col= in #615.

    Alternative names:

    • column_descriptions
    • column_info
    {
        "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  
    675718593 https://github.com/simonw/datasette/issues/942#issuecomment-675718593 https://api.github.com/repos/simonw/datasette/issues/942 MDEyOklzc3VlQ29tbWVudDY3NTcxODU5Mw== simonw 9599 2020-08-18T21:02:11Z 2020-08-18T21:02:24Z OWNER

    Easiest solution: if you provide column metadata it gets displayed above the table, something like on https://fivethirtyeight.datasettes.com/fivethirtyeight/antiquities-act%2Factions_under_antiquities_act

    HTML title= tooltips are also added to the table headers, which won't be visible on touch devices but that's OK because the information is visible on the page already.

    {
        "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  
    675715472 https://github.com/simonw/datasette/issues/942#issuecomment-675715472 https://api.github.com/repos/simonw/datasette/issues/942 MDEyOklzc3VlQ29tbWVudDY3NTcxNTQ3Mg== simonw 9599 2020-08-18T20:55:02Z 2020-08-18T20:55:02Z OWNER

    Could display these as tooltips on icons something like this (from the experimental datasette-inspect-columns plugin):

    This would need to take accessibility into account, and would need a different display for the mobile web layout. Need to consider how it will interact with the column menu suggested in #690.

    {
        "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  

    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 458.455ms · About: github-to-sqlite
    • Sort ascending
    • Sort descending
    • Facet by this
    • Hide this column
    • Show all columns
    • Show not-blank rows