home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

17 rows where author_association = "OWNER", "updated_at" is on date 2021-05-23 and user = 9599 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

issue 5

  • ?_col= and ?_nocol= support for toggling columns on table view 8
  • ?_facet_size=X to increase number of facets results on the page 4
  • Add support for Jinja2 version 3.0 3
  • How to limit fields returned from the JSON API? 1
  • "More" link for facets that shows _facet_size=max results 1

user 1

  • simonw · 17 ✖

author_association 1

  • OWNER · 17 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
846627322 https://github.com/simonw/datasette/issues/615#issuecomment-846627322 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjYyNzMyMg== simonw 9599 2021-05-23T21:31:22Z 2021-05-23T21:31:22Z OWNER

Would it be useful to allow this mechanism to alias columns, for example supporting one of the following:

  • ?_col=airline as name_of_airline
  • ?_col=airline:name_of_airline

This could be handy for renaming columns to match a specific expected JSON output.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846627163 https://github.com/simonw/datasette/issues/615#issuecomment-846627163 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjYyNzE2Mw== simonw 9599 2021-05-23T21:30:01Z 2021-05-23T21:30:01Z OWNER

Interesting side-effect of this implementation is that you can both control column order and request the same column multiple times:

/fivethirtyeight/airline-safety%2Fairline-safety?_col=fatal_accidents_00_14&_col=fatalities_00_14&_col=airline&_col=airline

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846626871 https://github.com/simonw/datasette/issues/615#issuecomment-846626871 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjYyNjg3MQ== simonw 9599 2021-05-23T21:27:36Z 2021-05-23T21:27:36Z OWNER

A better interface for this would be a full list of columns each with a checkbox for making it visible on invisible - this could then be used to apply a bulk change (rather than refreshing the interface after every removed column) and it could also be easily designed to work on narrow mobile screens where the cog icon is not visible.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846626567 https://github.com/simonw/datasette/issues/615#issuecomment-846626567 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjYyNjU2Nw== simonw 9599 2021-05-23T21:25:19Z 2021-05-23T21:25:19Z OWNER

Here's a bug: removing the rowid column returns an error.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846599732 https://github.com/simonw/datasette/issues/615#issuecomment-846599732 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjU5OTczMg== simonw 9599 2021-05-23T17:46:45Z 2021-05-23T17:46:45Z OWNER

I've changed my mind about forbidding ?_col= and ?_nocol= from being applied at the same time - I'm going to come up with a simple resolution rule instead.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846595473 https://github.com/simonw/datasette/issues/615#issuecomment-846595473 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjU5NTQ3Mw== simonw 9599 2021-05-23T17:13:09Z 2021-05-23T17:13:09Z OWNER

Natalie suggests a quick way to implement "undo" would be to add a "Show all columns" item to that menu which only appears when at least one column is hidden.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846595091 https://github.com/simonw/datasette/issues/615#issuecomment-846595091 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjU5NTA5MQ== simonw 9599 2021-05-23T17:09:59Z 2021-05-23T17:09:59Z OWNER

Here's that prototype of a "Hide this column" cog menu button:

Need a way to undo that once you've hidden a column - maybe a list of currently hidden columns that lets you un-hide them.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846592392 https://github.com/simonw/datasette/issues/615#issuecomment-846592392 https://api.github.com/repos/simonw/datasette/issues/615 MDEyOklzc3VlQ29tbWVudDg0NjU5MjM5Mg== simonw 9599 2021-05-23T16:49:30Z 2021-05-23T16:49:44Z OWNER

I started looking at this again, inspired by #1326. I have a new diff that works against the latest main branch.

```diff diff --git a/datasette/views/table.py b/datasette/views/table.py index 4879228..f4b2ee2 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -64,6 +64,36 @@ class Row:

class RowTableShared(DataView): + async def columns_to_select(self, db, table, request): + table_columns = await db.table_columns(table) + if "_col" in request.args and "_nocol" in request.args: + raise DatasetteError("Cannot use _col and _nocol at the same time") + if "_col" in request.args: + new_columns = [] + for column in request.args.getlist("_col"): + if column not in table_columns: + raise DatasetteError("_col={} is an invalid column".format(column)) + new_columns.append(column) + return new_columns + elif "_nocol" in request.args: + # Return all columns EXCEPT these + bad_columns = [ + column + for column in request.args.getlist("_nocol") + if column not in table_columns + ] + if bad_columns: + raise DatasetteError( + "_nocol={} - invalid columns".format(", ".join(bad_columns)) + ) + return [ + column + for column in table_columns + if column not in request.args.getlist("_nocol") + ] + else: + return table_columns + async def sortable_columns_for_table(self, database, table, use_rowid): db = self.ds.databases[database] table_metadata = self.ds.table_metadata(database, table) @@ -321,18 +351,16 @@ class TableView(RowTableShared): )

     pks = await db.primary_keys(table)
  • table_column_details = await db.table_column_details(table)
  • table_columns = [column.name for column in table_column_details]

  • select_columns = ", ".join(escape_sqlite(t) for t in table_columns)
  • table_columns = await self.columns_to_select(db, table, request)
  • select_clause = ", ".join(escape_sqlite(t) for t in table_columns)
     use_rowid = not pks and not is_view
     if use_rowid:
    
    • select = f"rowid, {select_columns}"
    • select = f"rowid, {select_clause}" order_by = "rowid" order_by_pks = "rowid" else:
    • select = select_columns
    • select = select_clause order_by_pks = ", ".join([escape_sqlite(pk) for pk in pks]) order_by = order_by_pks

@@ -715,6 +743,8 @@ class TableView(RowTableShared): column = fk["column"] if column not in columns_to_expand: continue + if column not in columns: + continue expanded_columns.append(column) # Gather the values column_index = columns.index(column) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_col= and ?_nocol= support for toggling columns on table view 517451234  
846493370 https://github.com/simonw/datasette/issues/1326#issuecomment-846493370 https://api.github.com/repos/simonw/datasette/issues/1326 MDEyOklzc3VlQ29tbWVudDg0NjQ5MzM3MA== simonw 9599 2021-05-23T02:55:00Z 2021-05-23T02:55:00Z OWNER

Currently you can do this with a custom SQL query, but as you've noticed this means you don't get automatic pagination: https://latest.datasette.io/fixtures.json?sql=select+pk%2C+created%2C+state+from+facetable+order+by+pk+limit+10&_shape=array

I have an open issue to allow selecting specific columns on the table page: #615

A workaround you can use today is to define a SQL view that selects just the tables you want. View pages behave exactly like tables in that they provide pagination by default.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
How to limit fields returned from the JSON API? 891969037  
846483426 https://github.com/simonw/datasette/issues/1331#issuecomment-846483426 https://api.github.com/repos/simonw/datasette/issues/1331 MDEyOklzc3VlQ29tbWVudDg0NjQ4MzQyNg== simonw 9599 2021-05-23T00:57:30Z 2021-05-23T00:57:30Z OWNER

Here's an alpha release with updated dependencies: https://pypi.org/project/datasette/0.57a0/

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Add support for Jinja2 version 3.0 893537744  
846482057 https://github.com/simonw/datasette/issues/1331#issuecomment-846482057 https://api.github.com/repos/simonw/datasette/issues/1331 MDEyOklzc3VlQ29tbWVudDg0NjQ4MjA1Nw== simonw 9599 2021-05-23T00:39:55Z 2021-05-23T00:39:55Z OWNER

I'm stuck also because datasette wants itsdangerous~=1.1 instead of allowing itsdangerous-2.0.0

Bumped that dependency in b64d87204612a84663616e075f542499a5d82a03

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Add support for Jinja2 version 3.0 893537744  
846481937 https://github.com/simonw/datasette/issues/1331#issuecomment-846481937 https://api.github.com/repos/simonw/datasette/issues/1331 MDEyOklzc3VlQ29tbWVudDg0NjQ4MTkzNw== simonw 9599 2021-05-23T00:38:28Z 2021-05-23T00:38:28Z OWNER

I'm going to push an alpha release with the new dependencies shortly.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Add support for Jinja2 version 3.0 893537744  
846481896 https://github.com/simonw/datasette/issues/1337#issuecomment-846481896 https://api.github.com/repos/simonw/datasette/issues/1337 MDEyOklzc3VlQ29tbWVudDg0NjQ4MTg5Ng== simonw 9599 2021-05-23T00:37:52Z 2021-05-23T00:37:52Z OWNER

The tricky thing about this is that ideally I'd like this to link to a paginated set of results - but arbitrary SQL queries do not yet support pagination, see #856.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
"More" link for facets that shows _facet_size=max results 898904402  
846481801 https://github.com/simonw/datasette/issues/1332#issuecomment-846481801 https://api.github.com/repos/simonw/datasette/issues/1332 MDEyOklzc3VlQ29tbWVudDg0NjQ4MTgwMQ== simonw 9599 2021-05-23T00:36:20Z 2021-05-23T00:36:20Z OWNER

Documentation:

  • https://docs.datasette.io/en/latest/facets.html#facets-in-query-strings at the bottom of the section
  • https://docs.datasette.io/en/latest/json_api.html#special-table-arguments at the bottom of the list of arguments
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_facet_size=X to increase number of facets results on the page 893890496  
846479730 https://github.com/simonw/datasette/issues/1332#issuecomment-846479730 https://api.github.com/repos/simonw/datasette/issues/1332 MDEyOklzc3VlQ29tbWVudDg0NjQ3OTczMA== simonw 9599 2021-05-23T00:11:31Z 2021-05-23T00:11:31Z OWNER

Here's the code in question: https://github.com/simonw/datasette/blob/5e9672c9bb33e41686472db4aa427168f9e67dbe/datasette/facets.py#L187-L210

It has access to the current request object as self.request.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_facet_size=X to increase number of facets results on the page 893890496  
846479212 https://github.com/simonw/datasette/issues/1332#issuecomment-846479212 https://api.github.com/repos/simonw/datasette/issues/1332 MDEyOklzc3VlQ29tbWVudDg0NjQ3OTIxMg== simonw 9599 2021-05-23T00:07:46Z 2021-05-23T00:07:46Z OWNER

?_facet_size=50 seems like a very reasonable thing to support - I'll cap it at whatever the max_returned_rows setting is (which defaults to 1000).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_facet_size=X to increase number of facets results on the page 893890496  
846479062 https://github.com/simonw/datasette/issues/1332#issuecomment-846479062 https://api.github.com/repos/simonw/datasette/issues/1332 MDEyOklzc3VlQ29tbWVudDg0NjQ3OTA2Mg== simonw 9599 2021-05-23T00:06:34Z 2021-05-23T00:06:34Z OWNER

A URL parameter to modify that facet size is a really good idea.

I thought I had an issue open for "..." linking to more results but I can't find it now.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
?_facet_size=X to increase number of facets results on the page 893890496  

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 579.585ms · About: github-to-sqlite