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 2019-05-28 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 4

  • Plugin hook: filters_from_request 6
  • Improvements to table label detection 1
  • Option to ignore inserts if primary key exists already 1
  • Pagination breaks when combined with expanded foreign keys 1

user 1

  • simonw 9

author_association 1

  • OWNER 9
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
496665669 https://github.com/simonw/sqlite-utils/issues/21#issuecomment-496665669 https://api.github.com/repos/simonw/sqlite-utils/issues/21 MDEyOklzc3VlQ29tbWVudDQ5NjY2NTY2OQ== simonw 9599 2019-05-28T19:57:47Z 2019-05-28T19:57:47Z OWNER

https://www.sqlite.org/lang_insert.html

Looks like it's as simple as INSERT OR IGNORE - and we already have code related to that here:

https://github.com/simonw/sqlite-utils/blob/1e28eeee8ce55ea68eddb228294a1eff6785b497/sqlite_utils/db.py#L498-L501

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Option to ignore inserts if primary key exists already 448391492  
496367866 https://github.com/simonw/datasette/issues/485#issuecomment-496367866 https://api.github.com/repos/simonw/datasette/issues/485 MDEyOklzc3VlQ29tbWVudDQ5NjM2Nzg2Ng== simonw 9599 2019-05-28T05:14:06Z 2019-05-28T05:14:06Z OWNER

I'm going to generate statistics for every TEXT column.

Any column with more than 90% distinct rows (compared to the total count of rows) will be a candidate for the label.

I will then pick the candidate column with the shortest average length.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Improvements to table label detection  447469253  
496345660 https://github.com/simonw/datasette/issues/489#issuecomment-496345660 https://api.github.com/repos/simonw/datasette/issues/489 MDEyOklzc3VlQ29tbWVudDQ5NjM0NTY2MA== simonw 9599 2019-05-28T02:48:57Z 2019-05-28T02:48:57Z OWNER

Fixed: https://latest.datasette.io/fixtures/roadside_attraction_characteristics?_sort=attraction_id&_size=2

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Pagination breaks when combined with expanded foreign keys 448977444  
496339819 https://github.com/simonw/datasette/issues/473#issuecomment-496339819 https://api.github.com/repos/simonw/datasette/issues/473 MDEyOklzc3VlQ29tbWVudDQ5NjMzOTgxOQ== simonw 9599 2019-05-28T02:13:44Z 2019-05-28T02:13:44Z OWNER

I'm leaning towards supporting both hooks.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook: filters_from_request 445850934  
496339574 https://github.com/simonw/datasette/issues/473#issuecomment-496339574 https://api.github.com/repos/simonw/datasette/issues/473 MDEyOklzc3VlQ29tbWVudDQ5NjMzOTU3NA== simonw 9599 2019-05-28T02:12:13Z 2019-05-28T02:13:07Z OWNER

Here's an older version of what that custom table filtering plugin might look like: https://github.com/simonw/datasette/commit/5116c4ec8aed5091e1f75415424b80f613518dc6

```python from datasette.utils import TableFilter

@hookimpl def table_filter(): async def inner(view, name, table, request): extra_human_descriptions = [] where_clauses = [] params = {} # ... build those things here return TableFilter( human_description_extras=extra_human_descriptions, where_clauses=where_clauses, params=params, ) return inner ```

I built this for the https://github.com/simonw/russian-ira-facebook-ads-datasette project.

It's pretty neat. Maybe I should go with that?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook: filters_from_request 445850934  
496338808 https://github.com/simonw/datasette/issues/473#issuecomment-496338808 https://api.github.com/repos/simonw/datasette/issues/473 MDEyOklzc3VlQ29tbWVudDQ5NjMzODgwOA== simonw 9599 2019-05-28T02:07:23Z 2019-05-28T02:07:23Z OWNER

Assuming I do go ahead with this plugin hook, the existing InFilter makes for a nice simple example that illustrates the two key methods: .where_clause() and .human_clause():

```python class InFilter(Filter): key = "in" display = "in"

def split_value(self, value):
    if value.startswith("["):
        return json.loads(value)
    else:
        return [v.strip() for v in value.split(",")]

def where_clause(self, table, column, value, param_counter):
    values = self.split_value(value)
    params = [":p{}".format(param_counter + i) for i in range(len(values))]
    sql = "{} in ({})".format(escape_sqlite(column), ", ".join(params))
    return sql, values

def human_clause(self, column, value):
    return "{} in {}".format(column, json.dumps(self.split_value(value)))

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook: filters_from_request 445850934  
496338666 https://github.com/simonw/datasette/issues/473#issuecomment-496338666 https://api.github.com/repos/simonw/datasette/issues/473 MDEyOklzc3VlQ29tbWVudDQ5NjMzODY2Ng== simonw 9599 2019-05-28T02:06:23Z 2019-05-28T02:06:23Z OWNER

I'm having trouble coming up with interesting column-based filters which don't make sense to ship as default behaviour.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook: filters_from_request 445850934  
496338533 https://github.com/simonw/datasette/issues/473#issuecomment-496338533 https://api.github.com/repos/simonw/datasette/issues/473 MDEyOklzc3VlQ29tbWVudDQ5NjMzODUzMw== simonw 9599 2019-05-28T02:05:39Z 2019-05-28T02:05:39Z OWNER

I wonder if this is the right hook?

The more likely case is that we need a hook that registers a new type of lookup entirely - ?_spatial_within={geojson} for example. These aren't necessarily attached to a specific column and may have entirely custom syntax - but they still need to be able to influence the query (like the _where= clause does) and the human-readable description of the page.

Is there a strong case for supporting both custom filter plugins AND custom table where plugins, or could those where plugins cover both bases?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook: filters_from_request 445850934  
496337533 https://github.com/simonw/datasette/issues/473#issuecomment-496337533 https://api.github.com/repos/simonw/datasette/issues/473 MDEyOklzc3VlQ29tbWVudDQ5NjMzNzUzMw== simonw 9599 2019-05-28T01:59:19Z 2019-05-28T01:59:19Z OWNER

It would be nice if this plugin was passed the current database/table so it can decide to enable new filters only for specific tables. This will require a bit of refactoring because the filters list is static at the moment - it would instead have to be returned by a function that runs when the table view is rendered.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin hook: filters_from_request 445850934  

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