home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

11 rows where author_association = "OWNER", "created_at" is on date 2021-02-26 and user = 9599 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 5

  • Custom pages don't work with base_url setting 3
  • sqlite-utils extract could handle nested objects 3
  • Allow facetting on custom queries 2
  • Suggest for ArrayFacet possibly confused by blank values 2
  • Plugin tip: look at the examples linked from the hooks page 1

user 1

  • simonw · 11 ✖

author_association 1

  • OWNER · 11 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
786849095 https://github.com/simonw/datasette/issues/1238#issuecomment-786849095 https://api.github.com/repos/simonw/datasette/issues/1238 MDEyOklzc3VlQ29tbWVudDc4Njg0OTA5NQ== simonw 9599 2021-02-26T19:29:38Z 2021-02-26T19:29:38Z OWNER

Here's the test I wrote: ```diff git diff tests/test_custom_pages.py diff --git a/tests/test_custom_pages.py b/tests/test_custom_pages.py index 6a23192..5a71f56 100644 --- a/tests/test_custom_pages.py +++ b/tests/test_custom_pages.py @@ -2,11 +2,19 @@ import pathlib import pytest from .fixtures import make_app_client

+TEST_TEMPLATE_DIRS = str(pathlib.Path(file).parent / "test_templates") +

@pytest.fixture(scope="session") def custom_pages_client(): + with make_app_client(template_dir=TEST_TEMPLATE_DIRS) as client: + yield client + + +@pytest.fixture(scope="session") +def custom_pages_client_with_base_url(): with make_app_client( - template_dir=str(pathlib.Path(file).parent / "test_templates") + template_dir=TEST_TEMPLATE_DIRS, config={"base_url": "/prefix/"} ) as client: yield client

@@ -23,6 +31,12 @@ def test_request_is_available(custom_pages_client): assert "path:/request" == response.text

+def test_custom_pages_with_base_url(custom_pages_client_with_base_url): + response = custom_pages_client_with_base_url.get("/prefix/request") + assert 200 == response.status + assert "path:/prefix/request" == response.text + + def test_custom_pages_nested(custom_pages_client): response = custom_pages_client.get("/nested/nest") assert 200 == response.status ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Custom pages don't work with base_url setting 813899472  
786848654 https://github.com/simonw/datasette/issues/1238#issuecomment-786848654 https://api.github.com/repos/simonw/datasette/issues/1238 MDEyOklzc3VlQ29tbWVudDc4Njg0ODY1NA== simonw 9599 2021-02-26T19:28:48Z 2021-02-26T19:28:48Z OWNER

I added a debug line just before for regex, wildcard_template here:

https://github.com/simonw/datasette/blob/afed51b1e36cf275c39e71c7cb262d6c5bdbaa31/datasette/app.py#L1148-L1155

And it showed that for some reason request.path is /prefix/prefix/request here - the prefix got doubled somehow.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Custom pages don't work with base_url setting 813899472  
786841261 https://github.com/simonw/datasette/issues/1238#issuecomment-786841261 https://api.github.com/repos/simonw/datasette/issues/1238 MDEyOklzc3VlQ29tbWVudDc4Njg0MTI2MQ== simonw 9599 2021-02-26T19:13:44Z 2021-02-26T19:13:44Z OWNER

Sounds like a bug - thanks for reporting this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Custom pages don't work with base_url setting 813899472  
786840734 https://github.com/simonw/datasette/issues/1246#issuecomment-786840734 https://api.github.com/repos/simonw/datasette/issues/1246 MDEyOklzc3VlQ29tbWVudDc4Njg0MDczNA== simonw 9599 2021-02-26T19:12:39Z 2021-02-26T19:12:47Z OWNER

Could I take this part: python suggested_facet_sql = """ select distinct json_type({column}) from ({sql}) """.format( column=escape_sqlite(column), sql=self.sql ) And add where {column} is not null and {column} != '' perhaps?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Suggest for ArrayFacet possibly confused by blank values 817597268  
786840425 https://github.com/simonw/datasette/issues/1246#issuecomment-786840425 https://api.github.com/repos/simonw/datasette/issues/1246 MDEyOklzc3VlQ29tbWVudDc4Njg0MDQyNQ== simonw 9599 2021-02-26T19:11:56Z 2021-02-26T19:11:56Z OWNER

Relevant code: https://github.com/simonw/datasette/blob/afed51b1e36cf275c39e71c7cb262d6c5bdbaa31/datasette/facets.py#L271-L295

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Suggest for ArrayFacet possibly confused by blank values 817597268  
786830832 https://github.com/simonw/sqlite-utils/issues/239#issuecomment-786830832 https://api.github.com/repos/simonw/sqlite-utils/issues/239 MDEyOklzc3VlQ29tbWVudDc4NjgzMDgzMg== simonw 9599 2021-02-26T18:52:40Z 2021-02-26T18:52:40Z OWNER

Could this handle lists of objects too? That would be pretty amazing - if the column has a [{...}, {...}] list in it could turn that into a many-to-many.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
sqlite-utils extract could handle nested objects 816526538  
786813506 https://github.com/simonw/datasette/issues/1240#issuecomment-786813506 https://api.github.com/repos/simonw/datasette/issues/1240 MDEyOklzc3VlQ29tbWVudDc4NjgxMzUwNg== simonw 9599 2021-02-26T18:19:46Z 2021-02-26T18:19:46Z OWNER

Linking to rows from custom queries is a lot harder - because given an arbitrary string of SQL it's difficult to analyze it and figure out which (if any) of the returned columns represent a primary key.

It's possible to manually write a SQL query that returns a column that will be treated as a link to another page using this plugin, but it's not particularly straight-forward: https://datasette.io/plugins/datasette-json-html

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Allow facetting on custom queries 814591962  
786812716 https://github.com/simonw/datasette/issues/1240#issuecomment-786812716 https://api.github.com/repos/simonw/datasette/issues/1240 MDEyOklzc3VlQ29tbWVudDc4NjgxMjcxNg== simonw 9599 2021-02-26T18:18:18Z 2021-02-26T18:18:18Z OWNER

Agreed, this would be extremely useful. I'd love to be able to facet against custom queries. It's a fair bit of work to implement but it's not impossible. Closing this as a duplicate of #972.

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 1,
    "rocket": 0,
    "eyes": 0
}
Allow facetting on custom queries 814591962  
786795132 https://github.com/simonw/sqlite-utils/issues/239#issuecomment-786795132 https://api.github.com/repos/simonw/sqlite-utils/issues/239 MDEyOklzc3VlQ29tbWVudDc4Njc5NTEzMg== simonw 9599 2021-02-26T17:45:53Z 2021-02-26T17:45:53Z OWNER

If there's no primary key in the JSON could use the hash_id mechanism.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
sqlite-utils extract could handle nested objects 816526538  
786794435 https://github.com/simonw/sqlite-utils/issues/239#issuecomment-786794435 https://api.github.com/repos/simonw/sqlite-utils/issues/239 MDEyOklzc3VlQ29tbWVudDc4Njc5NDQzNQ== simonw 9599 2021-02-26T17:44:38Z 2021-02-26T17:44:38Z OWNER

This came up in office hours!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
sqlite-utils extract could handle nested objects 816526538  
786786645 https://github.com/simonw/datasette/issues/1244#issuecomment-786786645 https://api.github.com/repos/simonw/datasette/issues/1244 MDEyOklzc3VlQ29tbWVudDc4Njc4NjY0NQ== simonw 9599 2021-02-26T17:30:38Z 2021-02-26T17:30:38Z OWNER

New paragraph at the top of https://docs.datasette.io/en/latest/writing_plugins.html

Want to start by looking at an example? The Datasette plugins directory lists more than 50 open source plugins with code you can explore. The plugin hooks page includes links to example plugins for each of the documented hooks.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin tip: look at the examples linked from the hooks page 817528452  

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