home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

20 rows where "created_at" is on date 2021-01-06 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 6

  • Use force_https_urls on when deploying with Cloud Run 9
  • Make original path available to render hooks 5
  • register_output_renderer() should support streaming data 3
  • Redesign default .json format 1
  • Policy on documenting "public" datasette.utils functions 1
  • Lazily evaluated arguments for call_with_supported_arguments 1

user 1

  • simonw 20

author_association 1

  • OWNER 20
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
755500475 https://github.com/simonw/datasette/issues/1180#issuecomment-755500475 https://api.github.com/repos/simonw/datasette/issues/1180 MDEyOklzc3VlQ29tbWVudDc1NTUwMDQ3NQ== simonw 9599 2021-01-06T18:43:41Z 2021-01-06T18:43:41Z OWNER

Relevant code: https://github.com/simonw/datasette/blob/97fb10c17dd007a275ab743742e93e932335ad67/datasette/utils/init.py#L919-L940

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Lazily evaluated arguments for call_with_supported_arguments 780767542  
755495387 https://github.com/simonw/datasette/issues/1179#issuecomment-755495387 https://api.github.com/repos/simonw/datasette/issues/1179 MDEyOklzc3VlQ29tbWVudDc1NTQ5NTM4Nw== simonw 9599 2021-01-06T18:39:23Z 2021-01-06T18:39:23Z OWNER

In that case maybe there are three new arguments: path, full_path and url.

I'll also add request.full_path for consistency with these: https://github.com/simonw/datasette/blob/97fb10c17dd007a275ab743742e93e932335ad67/datasette/utils/asgi.py#L77-L90

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make original path available to render hooks 780278550  
755492945 https://github.com/simonw/datasette/issues/1179#issuecomment-755492945 https://api.github.com/repos/simonw/datasette/issues/1179 MDEyOklzc3VlQ29tbWVudDc1NTQ5Mjk0NQ== simonw 9599 2021-01-06T18:37:39Z 2021-01-06T18:37:39Z OWNER

I think I'll call this full_path for consistency with Django.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make original path available to render hooks 780278550  
755489974 https://github.com/simonw/datasette/issues/1179#issuecomment-755489974 https://api.github.com/repos/simonw/datasette/issues/1179 MDEyOklzc3VlQ29tbWVudDc1NTQ4OTk3NA== simonw 9599 2021-01-06T18:35:24Z 2021-01-06T18:35:24Z OWNER

Django calls this HttpRequest.get_full_path() - for the path plus the querystring.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make original path available to render hooks 780278550  
755486103 https://github.com/simonw/datasette/issues/1179#issuecomment-755486103 https://api.github.com/repos/simonw/datasette/issues/1179 MDEyOklzc3VlQ29tbWVudDc1NTQ4NjEwMw== simonw 9599 2021-01-06T18:32:41Z 2021-01-06T18:34:11Z OWNER

This parameter will return the URL path, with querystring arguments, to the HTML version of the page - e.g. /github/issue_comments or /github/issue_comments?_sort_desc=created_at

Open questions:

  • What should it be called? path could be misleading since it also includes the querystring.
  • Should I provide a url or full_url version which includes https://blah.com/...?
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make original path available to render hooks 780278550  
755484384 https://github.com/simonw/datasette/issues/782#issuecomment-755484384 https://api.github.com/repos/simonw/datasette/issues/782 MDEyOklzc3VlQ29tbWVudDc1NTQ4NDM4NA== simonw 9599 2021-01-06T18:31:14Z 2021-01-06T18:31:57Z OWNER

In building https://latest-with-plugins.datasette.io/github/issue_comments.Notebook?_labels=on I discovered the following patterns for importing data into both Pandas and Observable/d3: python import pandas df = pandas.read_json( "https://latest-with-plugins.datasette.io/github/issue_comments.json?_shape=array" ) And: javascript d3 = require("d3@5") rows = d3.json( "https://latest-with-plugins.datasette.io/github/issue_comments.json?_shape=array" ) Once again I find myself torn on the best possible default. A list of JSON objects is instantly compatible with both pandas.read_json() and d3.json() - but it leaves nowhere to put the extra information like pagination and suchlike!

Even given this I still think the correct default is an object with "rows", "total" and "next_url" keys. I should commit to that and implement it - this thought exercise has been running for far too long.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Redesign default .json format 627794879  
755476820 https://github.com/simonw/datasette/issues/1178#issuecomment-755476820 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTQ3NjgyMA== simonw 9599 2021-01-06T18:24:47Z 2021-01-06T18:24:47Z OWNER

Issue fixed - https://latest-with-plugins.datasette.io/github/issue_comments.Notebook?_labels=on displays the correct schemes now.

I can't think of a reason anyone on Cloud Run would ever NOT want the force_https_urls option, but just in case I've made it so if you pass --extra-options --setting force_https_urls off to publish cloudrun your setting will be respected.

https://github.com/simonw/datasette/blob/97fb10c17dd007a275ab743742e93e932335ad67/datasette/publish/cloudrun.py#L105-L110

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755468795 https://github.com/simonw/datasette/issues/1178#issuecomment-755468795 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTQ2ODc5NQ== simonw 9599 2021-01-06T18:14:35Z 2021-01-06T18:14:35Z OWNER

Deploying that change now to test it.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755163886 https://github.com/simonw/datasette/issues/1178#issuecomment-755163886 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTE2Mzg4Ng== simonw 9599 2021-01-06T08:37:51Z 2021-01-06T08:37:51Z OWNER

Easiest fix would be for publish cloudrun to set force_https_urls:

datasette publish now used to do this: https://github.com/simonw/datasette/blob/07e208cc6d9e901b87552c1be2854c220b3f9b6d/datasette/publish/now.py#L59-L63

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755161574 https://github.com/simonw/datasette/issues/1179#issuecomment-755161574 https://api.github.com/repos/simonw/datasette/issues/1179 MDEyOklzc3VlQ29tbWVudDc1NTE2MTU3NA== simonw 9599 2021-01-06T08:32:31Z 2021-01-06T08:32:31Z OWNER

An optional path argument to https://docs.datasette.io/en/stable/plugin_hooks.html#register-output-renderer-datasette which shows the path WITHOUT the .Notebook extension would be useful here.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make original path available to render hooks 780278550  
755160187 https://github.com/simonw/datasette/issues/1178#issuecomment-755160187 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTE2MDE4Nw== simonw 9599 2021-01-06T08:29:35Z 2021-01-06T08:29:35Z OWNER

https://latest-with-plugins.datasette.io/-/asgi-scope

{'asgi': {'spec_version': '2.1', 'version': '3.0'}, 'client': ('169.254.8.129', 54971), 'headers': [(b'host', b'latest-with-plugins.datasette.io'), (b'user-agent', b'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:84.0) Gecko' b'/20100101 Firefox/84.0'), (b'accept', b'text/html,application/xhtml+xml,application/xml;q=0.9,image/' b'webp,*/*;q=0.8'), (b'accept-language', b'en-US,en;q=0.5'), (b'dnt', b'1'), (b'cookie', b'_ga_LL6M7BK6D4=GS1.1.1609886546.49.1.1609886923.0; _ga=GA1.1' b'.894633707.1607575712'), (b'upgrade-insecure-requests', b'1'), (b'x-client-data', b'CgSL6ZsV'), (b'x-cloud-trace-context', b'e776af843c657d2a3da28a73b726e6fe/14187666787557102189;o=1'), (b'x-forwarded-for', b'148.64.98.14'), (b'x-forwarded-proto', b'https'), (b'forwarded', b'for="148.64.98.14";proto=https'), (b'accept-encoding', b'gzip, deflate, br'), (b'content-length', b'0')], 'http_version': '1.1', 'method': 'GET', 'path': '/-/asgi-scope', 'query_string': b'', 'raw_path': b'/-/asgi-scope', 'root_path': '', 'scheme': 'http', 'server': ('169.254.8.130', 8080), 'type': 'http'} Note the 'scheme': 'http' but also the (b'x-forwarded-proto', b'https').

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755159583 https://github.com/simonw/datasette/issues/1176#issuecomment-755159583 https://api.github.com/repos/simonw/datasette/issues/1176 MDEyOklzc3VlQ29tbWVudDc1NTE1OTU4Mw== simonw 9599 2021-01-06T08:28:20Z 2021-01-06T08:28:20Z OWNER

I used from datasette.utils import path_with_format in https://github.com/simonw/datasette-export-notebook/blob/0.1/datasette_export_notebook/init.py just now.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Policy on documenting "public" datasette.utils functions 779691739  
755158310 https://github.com/simonw/datasette/issues/1178#issuecomment-755158310 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTE1ODMxMA== simonw 9599 2021-01-06T08:25:31Z 2021-01-06T08:25:31Z OWNER

Moving this to the Datasette repo.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755157732 https://github.com/simonw/datasette/issues/1178#issuecomment-755157732 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTE1NzczMg== simonw 9599 2021-01-06T08:24:12Z 2021-01-06T08:24:12Z OWNER

https://latest-with-plugins.datasette.io/fixtures/sortable.json has the bug too - the next_url is http:// when it should be https://.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755157281 https://github.com/simonw/datasette/issues/1178#issuecomment-755157281 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTE1NzI4MQ== simonw 9599 2021-01-06T08:23:14Z 2021-01-06T08:23:14Z OWNER

https://latest-with-plugins.datasette.io/-/settings says "force_https_urls": false

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755157066 https://github.com/simonw/datasette/issues/1178#issuecomment-755157066 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTE1NzA2Ng== simonw 9599 2021-01-06T08:22:47Z 2021-01-06T08:22:47Z OWNER

Weird... https://github.com/simonw/datasette/blob/a882d679626438ba0d809944f06f239bcba8ee96/datasette/app.py#L609-L613

python def absolute_url(self, request, path): url = urllib.parse.urljoin(request.url, path) if url.startswith("http://") and self.setting("force_https_urls"): url = "https://" + url[len("http://") :] return url That looks like it should work. Needs more digging.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755156606 https://github.com/simonw/datasette/issues/1178#issuecomment-755156606 https://api.github.com/repos/simonw/datasette/issues/1178 MDEyOklzc3VlQ29tbWVudDc1NTE1NjYwNg== simonw 9599 2021-01-06T08:21:49Z 2021-01-06T08:21:49Z OWNER

https://github.com/simonw/datasette-export-notebook/blob/aec398eab4f34791d240d7bc47b6eec575b357be/datasette_export_notebook/init.py#L18-L23

Maybe this is a bug in datasette.absolute_url? Perhaps it doesn't take the scheme into account.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Use force_https_urls on when deploying with Cloud Run 780267857  
755134771 https://github.com/simonw/datasette/issues/1101#issuecomment-755134771 https://api.github.com/repos/simonw/datasette/issues/1101 MDEyOklzc3VlQ29tbWVudDc1NTEzNDc3MQ== simonw 9599 2021-01-06T07:28:01Z 2021-01-06T07:28:01Z OWNER

With this structure it will become possible to stream non-newline-delimited JSON array-of-objects too - the stream_rows() method could output [ first, then each row followed by a comma, then ] after the very last row.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
register_output_renderer() should support streaming data 749283032  
755133937 https://github.com/simonw/datasette/issues/1101#issuecomment-755133937 https://api.github.com/repos/simonw/datasette/issues/1101 MDEyOklzc3VlQ29tbWVudDc1NTEzMzkzNw== simonw 9599 2021-01-06T07:25:48Z 2021-01-06T07:26:43Z OWNER

Idea: instead of returning a dictionary, register_output_renderer could return an object. The object could have the following properties:

  • .extension - the extension to use
  • .can_render(...) - says if it can render this
  • .can_stream(...) - says if streaming is supported
  • async .stream_rows(rows_iterator, send) - method that loops through all rows and uses send to send them to the response in the correct format

I can then deprecate the existing dict return type for 1.0.

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
register_output_renderer() should support streaming data 749283032  
755128038 https://github.com/simonw/datasette/issues/1101#issuecomment-755128038 https://api.github.com/repos/simonw/datasette/issues/1101 MDEyOklzc3VlQ29tbWVudDc1NTEyODAzOA== simonw 9599 2021-01-06T07:10:22Z 2021-01-06T07:10:22Z OWNER

Yet another use-case for this: I want to be able to stream newline-delimited JSON in order to better import into Pandas:

pandas.read_json("https://latest.datasette.io/fixtures/compound_three_primary_keys.json?_shape=array&_nl=on", lines=True)
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
register_output_renderer() should support streaming data 749283032  

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