ESDet / esdportal_profile

drupal install profile for portal.excellentschoolsdetroit.org
0 stars 4 forks source link

Add search facets #51

Closed bnchdrff closed 8 years ago

bnchdrff commented 8 years ago

The ones that definitely need to be added:

More to come! @anderoy will post them to the issue.

Work on API schema with @uniosx

bnchdrff commented 8 years ago

As far as the API goes, unfortunately jsonapi doesn't have a brilliant answer for specifying filters on included (and in turn JOINed) resources -- in this case, we're querying schools but want to filter on school profiles, an included resource. The other special filters are on/off only -- without arbitrary conditions -- so this query is a little different.

See https://github.com/cerebris/jsonapi-resources/issues/314 for discussion.

For now I'm adding a filter_values parameter where I'll put these special filters that take parameters.

bnchdrff commented 8 years ago

Now that I'm thinking about it, a syntax like filter[school.field_special_ed_level]=moderate,intensive might work...

bnchdrff commented 8 years ago

Done!

I'll push work to the 51 devsite later this eve.

Docs for filter_values parameter:

An array of special fields paired with comma-separated values to use to filter the result set. Allowed values for schools: field_special_ed_level (basic,intensive,moderate,none), field_special_ed_programs (autism,blindness,cognitive,deafness,developmental_delay,emotional,ld,multiple,orthopedic,other,speech). Filter values are added to the query using an IN clause (OR).

bnchdrff commented 8 years ago

Pushed!

Examle query: https://50-proximity-3mhev6qb5ihtc.us.platform.sh/api/1.0/schools.json?flatten_fields=true&includes=school_profile&filter_values[field_special_ed_level]=basic&filter_values[field_special_ed_programs]=ld,speech

anderoy commented 8 years ago

Things that we will need to add to search facets:

Governance:

Operator:

There could be more, especially on the Early Learning side of things.

bnchdrff commented 8 years ago

Both of these are taxonomy term reference fields, and can be handled by the filter argument.

For governance:

EAA schools: https://50-proximity-3mhev6qb5ihtc.us.platform.sh/api/1.0/schools.json?flatten_fields=true&filter[field_governance]=908

Both EAA and River Rouge schools: https://50-proximity-3mhev6qb5ihtc.us.platform.sh/api/1.0/schools.json?flatten_fields=true&filter[field_governance]=908,918&filter_op[field_governance]=IN

Operator:

Cornerstone schools: https://50-proximity-3mhev6qb5ihtc.us.platform.sh/api/1.0/schools.json?flatten_fields=true&filter[field_operator]=1090

We can build the options list by querying the API as documented in https://github.com/ESDet/esdportal_str/wiki/School-Data-API#an-example-of-how-to-use-the-school-data-api

Since most of these values won't be changing any time soon, we can probably just use the data I just fetched below:

Operators:

[
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Bay Mills Community College",
        "parents": [
            "0"
        ],
        "revision_id": "1223",
        "tid": "1179",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "e9d55ffd-f831-4b81-99aa-2fea91de91b7",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Central Michigan University",
        "parents": [
            "0"
        ],
        "revision_id": "1062",
        "tid": "1018",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "ea7a6bae-9bd1-4fe1-aa0e-c6c48f10e506",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Detroit City School District",
        "parents": [
            "0"
        ],
        "revision_id": "1029",
        "tid": "985",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "c31512b9-95bb-4f3d-92f7-8c3984189c95",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Eastern Michigan University",
        "parents": [
            "0"
        ],
        "revision_id": "1043",
        "tid": "999",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "d06cf557-bcfd-45c5-a1a4-6a799484bc0b",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Education Achievement System-EAS",
        "parents": [
            "0"
        ],
        "revision_id": "1160",
        "tid": "1116",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "0184b949-1e62-4ffe-bd3b-cb261bcee810",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Ferris State University",
        "parents": [
            "0"
        ],
        "revision_id": "1001",
        "tid": "957",
        "timestamp": "1375727803",
        "uid": "0",
        "uuid": "582cc07c-24e5-4970-9fdd-abec9be784b7",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Grand Valley State University",
        "parents": [
            "0"
        ],
        "revision_id": "1058",
        "tid": "1014",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "61543059-94f0-4101-8700-a14117b5db0e",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Highland Park City Schools",
        "parents": [
            "0"
        ],
        "revision_id": "1346",
        "tid": "1302",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "7948b600-8a31-48a1-9dfe-814a0ebbb237",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Lake Superior State University",
        "parents": [
            "0"
        ],
        "revision_id": "1072",
        "tid": "1028",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "6487b2bc-a262-41cb-9d60-a8d0d51a397b",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "Northern Michigan University",
        "parents": [
            "0"
        ],
        "revision_id": "3665",
        "tid": "2274",
        "timestamp": "1384903368",
        "uid": "1760",
        "uuid": "a349a812-097c-4e1a-a123-c88929f62e3e",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Oakland University",
        "parents": [
            "0"
        ],
        "revision_id": "1052",
        "tid": "1008",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "a40884ff-b78a-4ac1-bb64-c6ba888df90b",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Saginaw Valley State University",
        "parents": [
            "0"
        ],
        "revision_id": "1032",
        "tid": "988",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "c29c2e67-e20a-4e4f-9db5-19d4b048a31e",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": null,
        "format": null,
        "log": null,
        "name": "Wayne RESA",
        "parents": [
            "0"
        ],
        "revision_id": "1135",
        "tid": "1091",
        "timestamp": "1375728095",
        "uid": "0",
        "uuid": "621ef17e-5f27-41ba-9d39-14b4dc56f5d0",
        "vid": "11",
        "vocabulary_machine_name": "authorizer",
        "weight": "0"
    }
]

Governances (real word? sorry :mortar_board:!):

[
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Berkley School District",
        "parents": [
            "0"
        ],
        "revision_id": "3925",
        "tid": "902",
        "timestamp": "1398117378",
        "uid": "1760",
        "uuid": "74d00d74-cf8d-4e18-bc4b-d77cee4b1e56",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "Charter",
        "parents": [
            "0"
        ],
        "revision_id": "956",
        "tid": "904",
        "timestamp": "1375716413",
        "uid": "1",
        "uuid": "7fdf52f9-0326-4ed2-8135-7ed739dc3350",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Clintondale Community Schools",
        "parents": [
            "0"
        ],
        "revision_id": "3866",
        "tid": "903",
        "timestamp": "1395937417",
        "uid": "1760",
        "uuid": "f3a4783d-f7cd-4ec4-a2d5-ec134c6d0993",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "DPS",
        "parents": [
            "0"
        ],
        "revision_id": "957",
        "tid": "905",
        "timestamp": "1375716415",
        "uid": "1",
        "uuid": "b8a47c6c-3841-49b7-9096-224385413c5e",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "DPS Charter",
        "parents": [
            "0"
        ],
        "revision_id": "958",
        "tid": "906",
        "timestamp": "1375716419",
        "uid": "1",
        "uuid": "5e1f3f74-43c8-4851-a37c-67b6c3504439",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "DPS Rising",
        "parents": [
            "0"
        ],
        "revision_id": "959",
        "tid": "907",
        "timestamp": "1375716423",
        "uid": "1",
        "uuid": "7e508907-d0a5-4f48-aa73-f0d0976b3e02",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "EAA",
        "parents": [
            "0"
        ],
        "revision_id": "960",
        "tid": "908",
        "timestamp": "1375716426",
        "uid": "1",
        "uuid": "c17c74ed-0679-46c5-a435-49ec098042c5",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "EAA Charter",
        "parents": [
            "0"
        ],
        "revision_id": "2023",
        "tid": "1974",
        "timestamp": "1375734480",
        "uid": "1",
        "uuid": "3230e51b-7334-4c3d-b87a-cdc24704e666",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Ferndale Public Schools",
        "parents": [
            "0"
        ],
        "revision_id": "3867",
        "tid": "909",
        "timestamp": "1395937540",
        "uid": "1760",
        "uuid": "f0ac1426-31c2-44a0-8ccf-8312f3df432d",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Hamtramck Public Schools",
        "parents": [
            "0"
        ],
        "revision_id": "3917",
        "tid": "910",
        "timestamp": "1398116625",
        "uid": "1760",
        "uuid": "ae42ec03-26cd-47a7-9712-1cc829029982",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "Harper Woods District Schools",
        "parents": [
            "0"
        ],
        "revision_id": "4479",
        "tid": "2349",
        "timestamp": "1403544112",
        "uid": "1760",
        "uuid": "fcedcb4c-05e9-419f-8777-3e07e3d25fcc",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Hazel Park Schools",
        "parents": [
            "0"
        ],
        "revision_id": "3911",
        "tid": "913",
        "timestamp": "1398116374",
        "uid": "1760",
        "uuid": "bfa056c6-84ad-489b-a7ae-542e418baae7",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Highland Park School District",
        "parents": [
            "0"
        ],
        "revision_id": "3926",
        "tid": "911",
        "timestamp": "1398117408",
        "uid": "1760",
        "uuid": "d3dec388-afa3-4b0e-8c71-fc8aa38bf442",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "HPPS Charter",
        "parents": [
            "0"
        ],
        "revision_id": "964",
        "tid": "912",
        "timestamp": "1375716444",
        "uid": "1",
        "uuid": "482c8140-368b-47e0-9c1e-ed38b4151daa",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "Independent",
        "parents": [
            "0"
        ],
        "revision_id": "966",
        "tid": "914",
        "timestamp": "1375716453",
        "uid": "1",
        "uuid": "c6b63d68-c8c0-4169-84f9-2d1fb992eabd",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Inkster Public Schools",
        "parents": [
            "0"
        ],
        "revision_id": "3919",
        "tid": "915",
        "timestamp": "1398116832",
        "uid": "1760",
        "uuid": "f42aab88-b81c-48f2-a022-e34c380ab853",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "Macomb ISD",
        "parents": [
            "0"
        ],
        "revision_id": "968",
        "tid": "916",
        "timestamp": "1375716469",
        "uid": "1",
        "uuid": "159207a8-717e-42f4-89ad-e8562ffb8eb8",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "Michigan Department of Corrections",
        "parents": [
            "0"
        ],
        "revision_id": "4481",
        "tid": "2350",
        "timestamp": "1403544203",
        "uid": "1760",
        "uuid": "bb4cdbd2-b48d-42fa-b7fd-03c9148735b9",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Oak Park Schools",
        "parents": [
            "0"
        ],
        "revision_id": "3921",
        "tid": "917",
        "timestamp": "1398117221",
        "uid": "1760",
        "uuid": "9becd112-cfda-41a4-bdd0-fa8a5af03b8d",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "Redford Union Schools",
        "parents": [
            "0"
        ],
        "revision_id": "4483",
        "tid": "2351",
        "timestamp": "1403544355",
        "uid": "1760",
        "uuid": "82f0c5a5-c45c-4e1c-8cfb-f5d0a0634766",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "River Rouge School District",
        "parents": [
            "0"
        ],
        "revision_id": "3922",
        "tid": "918",
        "timestamp": "1398117269",
        "uid": "1760",
        "uuid": "d18c7723-2717-4a79-bd8c-99a05edc8696",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": null,
        "name": "State",
        "parents": [
            "0"
        ],
        "revision_id": "971",
        "tid": "919",
        "timestamp": "1375716478",
        "uid": "1",
        "uuid": "7ed86160-286c-4010-9b98-7eca4d5b5b54",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Taylor School District",
        "parents": [
            "0"
        ],
        "revision_id": "3923",
        "tid": "920",
        "timestamp": "1398117310",
        "uid": "1760",
        "uuid": "b96ef87e-0094-4a58-9d2b-606e2379bdab",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    },
    {
        "depth": 0,
        "description": "",
        "format": "full_html",
        "log": "",
        "name": "Westwood Community School District",
        "parents": [
            "0"
        ],
        "revision_id": "3924",
        "tid": "921",
        "timestamp": "1398117333",
        "uid": "1760",
        "uuid": "3c89ae11-71e4-4fef-ad3d-bbc1551c2865",
        "vid": "7",
        "vocabulary_machine_name": "school_gov",
        "weight": "0"
    }
]
anderoy commented 8 years ago

So am I to understand that ANY term reference field could be retrieved using the filter argument?

@uniosx Does this work for how we discussed setting up the filters on the results page?

bnchdrff commented 8 years ago

Yes, that's the case for not only terms, but all fields on the school object -- filtering on the school profile object takes a lil extra :hammer: :construction_worker: :dancers: :100: if you know what i mean

alectower commented 8 years ago

Yeah this works. I can pre-populate all governances and operators by hitting the API vocabulary endpoint with vids 7 and 11.

bnchdrff commented 8 years ago

the correct vid for school operator is 10 - sorry!

anderoy commented 8 years ago

Since it takes some :hammer: :construction_worker: :dancers: :100: to get the profile fields to filter, what would it take to include:

bnchdrff commented 8 years ago

Application process is already handled in school_profile_application_required

I've added transport opts & academic focus filters -- the available options are listed at https://50-proximity-3mhev6qb5ihtc.us.platform.sh/developers/schools#schools-index

anderoy commented 8 years ago

This all seems good for now. The new filtering works great on the Scorecard, thanks in major part to our discussion around faceted search that you sparked. !!!