charts through API - filter by filters...

Hi devs,
I’m trying to query the API for charts where the ou dimension is set as “filter”, something like this:

…api/charts.json?filter=filters.id:in:[ou]

But I get 409 “Simple type was found before finished parsing path expression, please check your path string.”

A similar (I think) request to filter by periods works fine, like this:

…api/charts.json?filter=periods.id:in:[2015Q1]

which I would think would be similar since both “filters” and “periods” are arrays, with objects that has a property “id” I try to filter on.

Any advice, or alternative approaches?

The end goal is to identify chart favourites where the orgunit can be modified without messing up the chart thing. Then, we want to make it easy to produce the same charts for multiple orgunits side by side using the chart plugin and modifying the orgunit, e.g. select a region and get the same time trend chart for all districts in that region next to each other to identify those that stand out.

Olav

Hi Olav

I see there is an issue there with collection of simple type, I will have a look at it. That said, the filters (and rows) properties are only available if you use /api/charts/ID, as they are populated based on other props, so this filter will not work like that anyways.

Maybe you want to have a look at the filterDimensions property instead?

···

On Fri, Sep 16, 2016 at 2:12 AM, Olav Poppe olav.poppe@me.com wrote:

Hi devs,
I’m trying to query the API for charts where the ou dimension is set as “filter”, something like this:

…api/charts.json?filter=filters.id:in:[ou]

But I get 409 “Simple type was found before finished parsing path expression, please check your path string.”

A similar (I think) request to filter by periods works fine, like this:

…api/charts.json?filter=periods.id:in:[2015Q1]

which I would think would be similar since both “filters” and “periods” are arrays, with objects that has a property “id” I try to filter on.

Any advice, or alternative approaches?

The end goal is to identify chart favourites where the orgunit can be modified without messing up the chart thing. Then, we want to make it easy to produce the same charts for multiple orgunits side by side using the chart plugin and modifying the orgunit, e.g. select a region and get the same time trend chart for all districts in that region next to each other to identify those that stand out.

Olav


Morten

Hi Olav

At least the bug with simple collections are now fixed in 224 and master

···

On Fri, Sep 16, 2016 at 10:24 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi Olav

I see there is an issue there with collection of simple type, I will have a look at it. That said, the filters (and rows) properties are only available if you use /api/charts/ID, as they are populated based on other props, so this filter will not work like that anyways.

Maybe you want to have a look at the filterDimensions property instead?


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org


Morten

On Fri, Sep 16, 2016 at 2:12 AM, Olav Poppe olav.poppe@me.com wrote:

Hi devs,
I’m trying to query the API for charts where the ou dimension is set as “filter”, something like this:

…api/charts.json?filter=filters.id:in:[ou]

But I get 409 “Simple type was found before finished parsing path expression, please check your path string.”

A similar (I think) request to filter by periods works fine, like this:

…api/charts.json?filter=periods.id:in:[2015Q1]

which I would think would be similar since both “filters” and “periods” are arrays, with objects that has a property “id” I try to filter on.

Any advice, or alternative approaches?

The end goal is to identify chart favourites where the orgunit can be modified without messing up the chart thing. Then, we want to make it easy to produce the same charts for multiple orgunits side by side using the chart plugin and modifying the orgunit, e.g. select a region and get the same time trend chart for all districts in that region next to each other to identify those that stand out.

Olav

Thanks Morten.

I tried filterDimensions (api/charts.json?filter=filterDimensions:in:[ou]), but that gives “internal server error”: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near “)” (see attached stacktrace).

Is this a bug again, or is my filter wrong somehow?

Olav

Hm sounds like a bug, but different but. Let me have a look.

···

On Friday, 16 September 2016, Olav Poppe olav.poppe@me.com wrote:

Thanks Morten.

I tried filterDimensions (api/charts.json?filter=filterDimensions:in:[ou]), but that gives “internal server error”: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near “)” (see attached stacktrace).

Is this a bug again, or is my filter wrong somehow?

Olav

Morten

Actually, it’s the same bug… I assume you tried on /demo ? or 224, CI hasn’t build it yet… I have started it now, so in about 30 min there should be a new war file to test

That said… the filtering doesn’t actually work for these kinds of arrays, I will look into it

···

On Fri, Sep 16, 2016 at 1:31 PM, Morten Olav Hansen morten@dhis2.org wrote:

Hm sounds like a bug, but different but. Let me have a look.

On Friday, 16 September 2016, Olav Poppe olav.poppe@me.com wrote:

Thanks Morten.

I tried filterDimensions (api/charts.json?filter=filterDimensions:in:[ou]), but that gives “internal server error”: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near “)” (see attached stacktrace).

Is this a bug again, or is my filter wrong somehow?

Olav


Morten


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Hi Olav

This should now be working properly in 224 and master

https://play.dhis2.org/dev/api/charts.json?fields=id,displayName,filterDimensions&filter=filterDimensions:in:[pe]

https://play.dhis2.org/demo/api/charts.json?fields=id,displayName,filterDimensions&filter=filterDimensions:in:[pe]

···

On Fri, Sep 16, 2016 at 1:39 PM, Morten Olav Hansen morten@dhis2.org wrote:

Actually, it’s the same bug… I assume you tried on /demo ? or 224, CI hasn’t build it yet… I have started it now, so in about 30 min there should be a new war file to test

That said… the filtering doesn’t actually work for these kinds of arrays, I will look into it

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Fri, Sep 16, 2016 at 1:31 PM, Morten Olav Hansen morten@dhis2.org wrote:

Hm sounds like a bug, but different but. Let me have a look.

On Friday, 16 September 2016, Olav Poppe olav.poppe@me.com wrote:

Thanks Morten.

I tried filterDimensions (api/charts.json?filter=filterDimensions:in:[ou]), but that gives “internal server error”: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near “)” (see attached stacktrace).

Is this a bug again, or is my filter wrong somehow?

Olav


Morten


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp