home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

9 rows where "updated_at" is on date 2022-03-08 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

issue 5

  • Move hashed URL mode out to a plugin 5
  • End-user documentation 1
  • Plugin hook for dynamic metadata 1
  • Sensible `cache-control` headers for static assets, including those served by plugins 1
  • Get rid of the no-longer necessary ?_format=json hack for tables called x.json 1

user 2

  • simonw 8
  • khusmann 1

author_association 2

  • OWNER 8
  • NONE 1
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1062124485 https://github.com/simonw/datasette/issues/1384#issuecomment-1062124485 https://api.github.com/repos/simonw/datasette/issues/1384 IC_kwDOBm6k_c4_TrvF khusmann 167160 2022-03-08T19:26:32Z 2022-03-08T19:26:32Z NONE

Looks like I'm late to the party here, but wanted to join the convo if there's still time before this interface is solidified in v1.0. My plugin use case is for education / social science data, which is meta-data heavy in the documentation of measurement scales, instruments, collection procedures, etc. that I want to connect to columns, tables, and dbs (and render in static pages, but looks like I can do that with the jinja plugin hook). I'm still digging in and I think @brandonrobertz 's approach will work for me at least for now, but I want to bump this thread in the meantime -- are there still plans for an async metadata hook at some point in the future? (or are you considering other directions?)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook for dynamic metadata 930807135  
1061891851 https://github.com/simonw/datasette/issues/932#issuecomment-1061891851 https://api.github.com/repos/simonw/datasette/issues/932 IC_kwDOBm6k_c4_Sy8L simonw 9599 2022-03-08T15:20:48Z 2022-03-08T15:20:48Z OWNER

Made a start on this here: https://datasette.io/tutorials

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
End-user documentation 678760988  
1061359915 https://github.com/simonw/datasette/issues/1651#issuecomment-1061359915 https://api.github.com/repos/simonw/datasette/issues/1651 IC_kwDOBm6k_c4_QxEr simonw 9599 2022-03-08T03:08:14Z 2022-03-08T03:09:24Z OWNER

A lot of the code complexity here is caused by DataView (here), which has the logic for CSV streaming and plugin formats such that it can be shared between tables and custom queries.

It would be good to get rid of that subclassed shared code, figure out how to do it via a utility function instead.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Get rid of the no-longer necessary ?_format=json hack for tables called x.json 1161584460  
1061355871 https://github.com/simonw/datasette/issues/1645#issuecomment-1061355871 https://api.github.com/repos/simonw/datasette/issues/1645 IC_kwDOBm6k_c4_QwFf simonw 9599 2022-03-08T02:59:28Z 2022-03-08T02:59:28Z OWNER

Hah, found a TODO about this: https://github.com/simonw/datasette/blob/c5791156d92615f25696ba93dae5bb2dcc192c98/datasette/app.py#L997-L999

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 1,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Sensible `cache-control` headers for static assets, including those served by plugins 1154399841  
1061282743 https://github.com/simonw/datasette/issues/647#issuecomment-1061282743 https://api.github.com/repos/simonw/datasette/issues/647 IC_kwDOBm6k_c4_QeO3 simonw 9599 2022-03-08T00:32:34Z 2022-03-08T00:32:47Z OWNER

It would be neat if the plugin could spot old-style hyphen hash URLs (maybe on 404) and redirect those too.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Move hashed URL mode out to a plugin 531755959  
1061276646 https://github.com/simonw/datasette/issues/647#issuecomment-1061276646 https://api.github.com/repos/simonw/datasette/issues/647 IC_kwDOBm6k_c4_Qcvm simonw 9599 2022-03-08T00:22:11Z 2022-03-08T00:22:11Z OWNER

I'm now convinced this is feasible enough that it's worth doing in time for Datasette 1.0.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Move hashed URL mode out to a plugin 531755959  
1061276399 https://github.com/simonw/datasette/issues/647#issuecomment-1061276399 https://api.github.com/repos/simonw/datasette/issues/647 IC_kwDOBm6k_c4_Qcrv simonw 9599 2022-03-08T00:21:47Z 2022-03-08T00:21:47Z OWNER

This seems to do the job: python @hookimpl def startup(datasette): for name, database in datasette.databases.items(): if database.hash: new_name = "{}_{}".format(name, database.hash[:7]) del datasette.databases[name] datasette.databases[new_name] = database Would have to teach the rest of the plugin to split on _ and to only redirect if the user seems to be hitting the URL for an old hash after which Datasette has been restarted with an updated database.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Move hashed URL mode out to a plugin 531755959  
1061272544 https://github.com/simonw/datasette/issues/647#issuecomment-1061272544 https://api.github.com/repos/simonw/datasette/issues/647 IC_kwDOBm6k_c4_Qbvg simonw 9599 2022-03-08T00:14:42Z 2022-03-08T00:14:42Z OWNER

Maybe the plugin should interfere with datasette.databases on startup and change the registered name for each one?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Move hashed URL mode out to a plugin 531755959  
1061267615 https://github.com/simonw/datasette/issues/647#issuecomment-1061267615 https://api.github.com/repos/simonw/datasette/issues/647 IC_kwDOBm6k_c4_Qaif simonw 9599 2022-03-08T00:05:43Z 2022-03-08T00:05:43Z OWNER

Built a prototype of that plugin: ```python from datasette import hookimpl from functools import wraps

@hookimpl def asgi_wrapper(datasette): def wrap_with_hashed_urls(app): @wraps(app) async def hashed_urls(scope, receive, send): # Only triggers on pages with a path not starting in /-/ # and where the first page component matches a database name if scope.get("type") != "http": await app(scope, receive, send) return path = scope["path"].lstrip("/") if not path or path.startswith("-/"): await app(scope, receive, send) return potential_database = path.split("/")[0] # It may or may not be already dbname~hash if "~" in potential_database: db_name, hash = potential_database.split("~", 1) else: db_name = potential_database hash = "" # Is db_name a database we have a hash for? try: db = datasette.get_database(db_name) except KeyError: await app(scope, receive, send) return

        if db.hash is not None:
            # TODO: make sure db.hash is documented
            if db.hash[:7] != hash:
                # Send a redirect
                path_bits = path.split("/")
                new_path = "/" + "/".join(["{}-{}".format(db_name, db.hash[:7])] + path_bits[1:])
                if scope.get("query_string"):
                    new_path += "?" + scope["query_string"].decode("latin-1")

                await send({
                    "type": "http.response.start",
                    "status": 302,
                    "headers": [
                        [b"location", new_path.encode("latin1")]
                    ],
                })
                await send({"type": "http.response.body", "body": b""})
                return
            else:
                # Add a far-future cache header
                async def wrapped_send(event):
                    if event["type"] == "http.response.start":
                        original_headers = event.get("headers") or []
                        event = {
                            "type": event["type"],
                            "status": event["status"],
                            "headers": original_headers + [
                                [b"Cache-Control", b"max-age=31536000"]
                            ],
                        }
                    await send(event)

                await app(scope, receive, wrapped_send)
                return

        await app(scope, receive, send)
    return hashed_urls
return wrap_with_hashed_urls

``` One catch: it doesn't affect the way URLs are generated - so every internal link within Datasette links to the non-hash version and then triggers a 302 redirect to the hashed version.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Move hashed URL mode out to a plugin 531755959  

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