ONSdigital / sdg-indicators

Development website for collecting and disseminating UK data for the Sustainable Development Goal global indicators.
https://ONSdigital.github.io/sdg-indicators/
37 stars 65 forks source link

Goals page indicator order #2829

Closed AnnCorp closed 6 years ago

AnnCorp commented 6 years ago

On the goals pages, the indicators are listed in alphanumeric order, but they should be numeric. This affects goals 8, 16 and 17.

AnnCorp commented 6 years ago

Suggestion from Martin: I had a look at the problem of the ordering that you mentioned eg 16.10.1 < 16.2.1. If the ordering was being done in the Javascript it would be possible to write a function to compare two indicator values by stripping out the numbers between the dots and then comparing them numerically rather than alphanumerically. However the indicators are laid out using Liquid. I don’t know anything about Liquid but having googled around I can’t find any way of sorting using a function as described above. So the easy solution (in terms of coding) would be to add a new property to each of the .md files, called “display_order”. Then you would assign “001” to 16.1.1, “002” to 16.1.2, etc, etc, then the Liquid code can be changed to sort by “display_order”. I don’t know how you guys feel about having to add an additional property to every .md file like this? (There would be another advantage to this approach though – if at any point anyone wanted to put the most “important” indicators at the top of the page they could use this approach to implement a bespoke ordering not based on the indicator numbering, so it does give more flexibility). The alternative would be to double-check with anyone we know with more Liquid expertise (US or Shane?) whether there is a way to specify a custom function to do the sorting. Cheers Martin

AnnCorp commented 6 years ago

@dougmet @shaneporter any thoughts on this suggestion from Martin @shenavall ?

shaneporter commented 6 years ago

I'll take a look and get back to you.

shaneporter commented 6 years ago

The sdg-build reference, above, describes what needs to be done to fix this.

shenavall commented 6 years ago

@AnnCorp My initial functional solution was to define the sorting explicitly. Following that conversation, we heard from Jean-Claude that he would like to use the website to display non-SDG indicators, which in my opinion adds weight to this approach. What the guys from Mango have done is suggested a technical solution to order SDGs by indicator ID. This may be the quickest way to fix the immediate problem but may not allow the flexibility we need in the long term. Please advise which way you want to go.

AnnCorp commented 6 years ago

@shenavall just discussed at team meeting and thoughts are that if Mango fix is v quick to implement then do that first for speed as not likely to explore longer term fix until at least Aug when you're back from your trip. There's a bigger requirement generally re ordering as issues with how sub-categories display in data filtering too.

shenavall commented 6 years ago

@AnnCorp On reflection I don't think Doug's solution will be any quicker to implement than mine. Mine is simpler in terms of coding but involves adding an extra property to the meta data. Doug's does not involve any metadata changes but I will have to make sense of what what he is suggesting - the coding is more complicated. My solution will support all future use cases rather than just the specific format of the SDG indicator ID so in my opinion we should just go for that from the outset rather than wasting time on something we will have to come back to again later. However I didn't want to mandate an additional metadata property without checking with you first, so.....your call|!

dougmet commented 6 years ago

Seeing as the sort order is essentially a presentation thing, the new field could live in the page metadata (in sdg-indicators along with permalink etc). That way you don't need anything new in the main metadata. I'm not wedded to either solution.

shenavall commented 6 years ago

Hi @dougmet thanks for your contribution however I don't follow you.

For me the key line of code is the following in goal.html:

{% assign goal_indicators = site.data.meta | where: 'sdg_goal', page.sdg_goal %}

If the metadata file for each indicator contained a property called something like 'sort_order' and was a simple numeric sequence that defined the indicators order within the goal, eg 0010, 0020, etc, then we could change the above line of code to the following

{% assign goal_indicators = site.data.meta | where: 'sdg_goal', page.sdg_goal | sort: 'sort_order' %}

I don't see how defining a sort order within the page metadata (rather than in the actual files you are sorting) could integrate with this approach

shenavall commented 6 years ago

also @dougmet, re: your Python solution, as I understand it, this approach involves ordering the indicators during the build stage, not specifying any specific sort in the presentation layer and so relying on them staying in the same order as they were built in. IMO if we care about the sort ordering it would be preferable to specify this explicitly in the presentation layer how do you feel about that?

dougmet commented 6 years ago

Yes you’re right that we loop over meta data not pages so maybe it is best to put the sort order in there. On Wed, 20 Jun 2018 at 10:06, shenavall notifications@github.com wrote:

also @dougmet https://github.com/dougmet, re: your Python solution, as I understand it, this approach involves ordering the indicators during the build stage, not specifying any specific sort in the presentation layer and so relying on them staying in the same order as they were built in. IMO if we care about the sort ordering it would be preferable to specify this explicitly in the presentation layer how do you feel about that?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ONSdigital/sdg-indicators/issues/2829#issuecomment-398678896, or mute the thread https://github.com/notifications/unsubscribe-auth/AFmyIe26BImZ4EjQng02BC3COUWRQVtuks5t-hCGgaJpZM4Ufqm3 .

dougmet commented 6 years ago

The Python version would have implicitly sorted the meta data (not adding a sort field). I prefer having sort order in the page metadata but it’s a little ugly as you would need to join it on to the main metadata.

It sounds like you have a plan that’s quick to implement so just go with that.

shenavall commented 6 years ago

Now completed