tiefpunkt / thingstore

MIT License
6 stars 3 forks source link

Investigate numeric metric names #16

Open tiefpunkt opened 10 years ago

tiefpunkt commented 10 years ago

After #11 there might be issues with numeric metric names in the API. Need to check that.

ptu commented 10 years ago

issue confirmed, has to be fixed in the following lines. https://github.com/tiefpunkt/thingstore/blob/f22a01a526db34271fd8d7be7e9f1ba77c35bb14/thingstore/api.py#L153

to tired right now.

ptu commented 10 years ago

im pretty sure the url patterns are the cause of this bug. because numeric metric names are interpreted as digits and therefore forwarded as metric_id

urls = patterns('',
        url(r'^thing/(?P<thing_id>\d+)/(?P<metric_id>\d+).json', MetricAPI.as_view(filetype="json")),
        url(r'^thing/(?P<thing_id>\d+)/(?P<metric_name>.+).json', MetricAPI.as_view(filetype="json")),
)

we could add a rest parameter to distinguish between id and name, something like:

urls = patterns('',
        url(r'^thing/(?P<thing_id>\d+)/id/(?P<metric_id>\d+).json', MetricAPI.as_view(filetype="json")),
        url(r'^thing/(?P<thing_id>\d+)/name/(?P<metric_name>.+).json', MetricAPI.as_view(filetype="json")),
)