home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

10 rows where "updated_at" is on date 2018-04-14 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

  • Support for units 5
  • Support filtering with units and more 3
  • Plot rows on a map with Leaflet and Leaflet.markercluster 1
  • Link foreign keys which don't have labels 1

user 2

  • simonw 7
  • russss 3

author_association 2

  • OWNER 7
  • CONTRIBUTOR 3
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
381361734 https://github.com/simonw/datasette/issues/125#issuecomment-381361734 https://api.github.com/repos/simonw/datasette/issues/125 MDEyOklzc3VlQ29tbWVudDM4MTM2MTczNA== russss 45057 2018-04-14T21:26:30Z 2018-04-14T21:26:30Z CONTRIBUTOR

FWIW I am now doing this on my WTR app (instead of silently limiting maps to 1000).

Telefonica now has about 4000 markers and good old BT has 22,000 or so.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plot rows on a map with Leaflet and Leaflet.markercluster 275135393  
381348849 https://github.com/simonw/datasette/issues/203#issuecomment-381348849 https://api.github.com/repos/simonw/datasette/issues/203 MDEyOklzc3VlQ29tbWVudDM4MTM0ODg0OQ== simonw 9599 2018-04-14T18:12:52Z 2018-04-14T18:12:52Z OWNER

I think I'm going to hold on to the custom sql function idea for the moment and implement it as an example plugin.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for units 313837303  
381336696 https://github.com/simonw/datasette/pull/205#issuecomment-381336696 https://api.github.com/repos/simonw/datasette/issues/205 MDEyOklzc3VlQ29tbWVudDM4MTMzNjY5Ng== simonw 9599 2018-04-14T15:24:04Z 2018-04-14T15:24:04Z OWNER

I merged this to master in c857608738d6b6c3e4f3248304a22f8b2648dd3e - thanks @russss!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support filtering with units and more 314319372  
381334973 https://github.com/simonw/datasette/pull/207#issuecomment-381334973 https://api.github.com/repos/simonw/datasette/issues/207 MDEyOklzc3VlQ29tbWVudDM4MTMzNDk3Mw== simonw 9599 2018-04-14T14:59:52Z 2018-04-14T14:59:52Z OWNER

I'm going to merge this and then add a unit test.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Link foreign keys which don't have labels 314329002  
381332222 https://github.com/simonw/datasette/pull/205#issuecomment-381332222 https://api.github.com/repos/simonw/datasette/issues/205 MDEyOklzc3VlQ29tbWVudDM4MTMzMjIyMg== russss 45057 2018-04-14T14:16:35Z 2018-04-14T14:16:35Z CONTRIBUTOR

I've added some tests and that docs link.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support filtering with units and more 314319372  
381330220 https://github.com/simonw/datasette/pull/205#issuecomment-381330220 https://api.github.com/repos/simonw/datasette/issues/205 MDEyOklzc3VlQ29tbWVudDM4MTMzMDIyMA== simonw 9599 2018-04-14T13:44:15Z 2018-04-14T13:44:15Z OWNER

This looks great so far - love the new documentation. Let's throw in a unit test or two for the basic unit filters (mainly as a protection against accidental regressions in the future).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support filtering with units and more 314319372  
381330075 https://github.com/simonw/datasette/issues/203#issuecomment-381330075 https://api.github.com/repos/simonw/datasette/issues/203 MDEyOklzc3VlQ29tbWVudDM4MTMzMDA3NQ== simonw 9599 2018-04-14T13:41:53Z 2018-04-14T13:41:53Z OWNER

Presumably units only work for numeric fields? If that's the case then automatically processing them if the incoming query string argument has a unit suffix makes total sense to me.

Here's a pretty crazy idea: what if we exposed unit conversion to SQL as a custom SQLite function? That way it would be possible to optionally use units in actual custom SQL queries.

I'd have to think quite carefully about performance implications here - wouldn't want a poorly considered unit calculation over a 500,000 row table to lock up the server. But I think the 1s query time limit might still prevent that.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for units 313837303  
381315675 https://github.com/simonw/datasette/issues/203#issuecomment-381315675 https://api.github.com/repos/simonw/datasette/issues/203 MDEyOklzc3VlQ29tbWVudDM4MTMxNTY3NQ== russss 45057 2018-04-14T09:14:45Z 2018-04-14T09:27:30Z CONTRIBUTOR

I'd like to figure out a sensible opt-in way to expose this in the JSON output as well. Maybe with a &_units=true parameter?

<s>From a machine-readable perspective I'm not sure why it would be useful to decorate the values with units</s>. Edit: Should have had some coffee first. It's clearly useful for stuff like map rendering!

I agree that the unit metadata should definitely be exposed in the JSON.

In #204 you said "I'd like to add support for using units when querying but this is PR is pretty usable as-is." - I'm fascinated to hear more about how this could work.

I'm thinking about a couple of approaches here. I think the simplest one is: if the column has a unit attached, optionally accept units in query fields:

```python column_units = ureg("Hz") # Create a unit object for the column's unit query_variable = ureg("4 GHz") # Supplied query variable

Now we can convert the query units into column units before querying

supplied_value.to(column_units).magnitude

4000000000.0

If the user doesn't supply units, pint just returns the plain

number and we can query as usual assuming it's the base unit

query_variable = ureg("50") query_variable

50

isinstance(query_variable, numbers.Number)

True ```

This also lets us do some nice unit conversion on querying:

```python column_units = ureg("m") query_variable = ureg("50 ft")

supplied_value.to(column_units)

<Quantity(15.239999999999998, 'meter')> ```

The alternative would be to provide a dropdown of units next to the query field (so a "Hz" field would give you "kHz", "MHz", "GHz"). Although this would be clearer to the user, it isn't so easy - we'd need to know more about the context of the field to give you sensible SI prefixes (I'm not so interested in nanoHertz, for example).

You also lose the bonus of being able to convert - although pint will happily show you all the compatible units, it again suffers from a lack of context:

```python ureg("m").compatible_units()

frozenset({<Unit('angstrom')>, <Unit('thou')>, <Unit('inch')>, <Unit('link')>, <Unit('foot')>, <Unit('survey_foot')>, <Unit('yard')>, <Unit('rod')>, <Unit('mile')>, <Unit('survey_mile')>, <Unit('league')>, <Unit('light_year')>}) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for units 313837303  
381300386 https://github.com/simonw/datasette/issues/203#issuecomment-381300386 https://api.github.com/repos/simonw/datasette/issues/203 MDEyOklzc3VlQ29tbWVudDM4MTMwMDM4Ng== simonw 9599 2018-04-14T03:35:56Z 2018-04-14T03:35:56Z OWNER

In #204 you said "I'd like to add support for using units when querying but this is PR is pretty usable as-is." - I'm fascinated to hear more about how this could work.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for units 313837303  
381300336 https://github.com/simonw/datasette/issues/203#issuecomment-381300336 https://api.github.com/repos/simonw/datasette/issues/203 MDEyOklzc3VlQ29tbWVudDM4MTMwMDMzNg== simonw 9599 2018-04-14T03:35:02Z 2018-04-14T03:35:02Z OWNER

This is really cool - I'm very impressed by pint.

I'd like to figure out a sensible opt-in way to expose this in the JSON output as well. Maybe with a &_units=true parameter?

We should definitely expose the units section from the table metadata in the output of https://wtr-api.herokuapp.com/wtr-663ea99/license_frequency.json

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Support for units 313837303  

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