CodeforSouth/fbi-api

Sort and/or filter Inspections on /inspection/:id response

Closed this issue · 2 comments

Currently I tested on production app and got:

violation19: 0,
violation30: 0,
violation43: 0,
violation11: 0,
violation31: 0,
violation12: 0,
violation07: 0,
violation32: 0,
violation41: 0,
violation46: 0,
violation03: 1,
violation45: 0,
violation01: 1,
violation33: 0,
violation15: 0,
violation10: 0,
violation21: 0,
violation53: 0,
violation55: 0,
violation51: 0,
violation36: 0,
violation38: 0,
violation18: 0,
violation49: 0,
violation27: 0,
violation56: 0,
violation28: 0,
violation47: 0,
violation50: 0,
violation39: 0,
violation04: 0,
violation37: 0,
violation34: 0,
violation16: 0,
violation42: 0,
violation40: 0,
violation54: 0,
violation05: 0,
violation52: 0,
violation26: 0,
violation57: 0,
violation23: 0,
violation20: 0,
violation58: 0,
violation13: 0,
violation24: 0,
violation08: 0,
violation09: 0,
violation35: 0,
violation14: 0,
violation06: 0,
violation29: 0,
violation25: 0,
violation44: 0,
violation02: 1,
violation22: 2,
violation17: 0,
violation48: 0

This is not sorted, and is very confusing. Would it make sense to filter the ones that have 0 value, or at least sort from 01 to 58?

Also, would it make sense to add a link to the violation description, maybe as part of another api endpoint?

I think we do need another api like /violations which lists all the violation descriptions.

Let's do this to the violations list:

    violations: [
        { id: 1, count: 10 },
        { id: 15, count: 3},
        { id: 27, count: 7}
    ]

And then it's going to be ordered and we are not going to bring unused violations. The problem of the sort right now is because it's a map structure and map keys are never sorted. So changing to a list is going to fix it out.

@quilesbaker please check

Inspection with some violations:
http://198.199.73.168/fra/inspection/5807286

Inspection with no violations:
http://198.199.73.168/fra/inspection/5820203

And let me know if I can close or if you have any best improvements ok?