socrata / opendatanetwork.com

The Open Data Network
https://www.opendatanetwork.com/
Other
19 stars 12 forks source link

Add Search Result Links to Geo Regions #344

Closed zang0 closed 8 years ago

zang0 commented 8 years ago

Because of the autosuggest outage, we'll need to rapidly push out a fall back. Here's what I propose:

whenever a dataset search gets launched (i.e. the user hits enter or the magnifying glass in the search box anywhere), we, in addition to launching the dataset query to cetera (what we're already doing), use this API call:

https://odn.data.socrata.com/resource/7g2b-8brv.json?$q=king%20county&$order=population%20desc&$limit=5

If there are results, then above the displayed datasets, we include another white rectangle with a region icon and we say: regions:

and list out the top 5 matching results with links to the pages.

ToshMeston commented 8 years ago

How does this look? http://opendatanetwork-staging.herokuapp.com/search?q=seattle

Fixed.

zang0 commented 8 years ago

How about this where we only show the second row if there are >=6 results and we only use 2 columns (splits the screen evenly) if there are 2 results.

screen shot 2016-03-24 at 5 39 54 pm
zang0 commented 8 years ago

How's the fix coming here?

ToshMeston commented 8 years ago

Fixed. How's this logic? We only show a max of 6 and the number of columns is determined by this:

getColumns() {

        const regionCount = this.searchResultsRegions.length;
        const width = $(document).width();
        const widthForThree = 1200;
        const widthForTwo = 800;

        var columns;

        if (regionCount >= 3) {

            if (width >= widthForThree)
                columns = 3;
            else if (width >= widthForTwo)
                columns = 2;
            else 
                columns = 1;
        }
        else if (regionCount >= 2) {

            columns = (width >= widthForTwo) ? 2 : 1;
        }
        else {

            columns = 1;
        }

        return columns;
    }
zang0 commented 8 years ago

Some comments:

_1 can we add the icons and text changes in the attached image, i.e. the region and dataset icon

_2 can we shrink the font size a bit OR drop the row height and padding?

_3 can we never show more than 2 rows - currently, if you shrink width like for mobile, we wind up w/ 6 rows

_4 lets be consisten and use the shorter metro names, see new york autosuggest vs search, should be same name and the one used in AS, currently search one is using the long form, i.e. New York-Newark-Jersey City, NY-NJ-PA Metro Area

instead of

New York Metro Area (NY-NJ-PA)

_5 we need the links to be bot visible. we have a lot of links coming in on search queries, so getting the bot exposed to the link structure is important

_6 category links from the homepage: http://opendatanetwork-staging.herokuapp.com/search?categories=infrastructure show regions, shouldn't show anything

ToshMeston commented 8 years ago

Fixed with the exception of #_4. The short name doesn't come back from the autosuggest request.

[{"autocomplete_name":"New York-Newark-Jersey City NY-NJ-PA Metro Area","id":"310M200US35620","name":"New York-Newark-Jersey City, NY-NJ-PA Metro Area","population":"19716880","type":"msa","regionType":"Metropolitan Statistical Area"},{"autocomplete_name":"New York State","id":"0400000US36","name":"New York","population":"19487053","type":"state","regionType":"US State"},{"autocomplete_name":"New York city New York","id":"1600000US3651000","name":"New York city, New York","population":"8268999","type":"place","regionType":"City"},{"autocomplete_name":"Kings County New York","id":"0500000US36047","name":"Kings County, New York","population":"2539789","type":"county","regionType":"US County"},{"autocomplete_name":"Queens County New York","id":"0500000US36081","name":"Queens County, New York","population":"2256400","type":"county","regionType":"US County"},{"autocomplete_name":"New York County New York","id":"0500000US36061","name":"New York County, New York","population":"1605272","type":"county","regionType":"US County"}]

zang0 commented 8 years ago

@aaasen Lane, can you chime in on how to get the short name?

aaasen commented 8 years ago

Looks like this was using a version of the roster with the old names. Changed it to use the new roster. https://odn.data.socrata.com/view/si4e-nzep

Fixed on staging: http://opendatanetwork-staging.herokuapp.com/search?q=seattle

zang0 commented 8 years ago

few more:

_7 change results to datasets per the image as in '2969 datasets for "seattle"

_8 drop case on first letter of Regions as in "regions for "seattle"

zang0 commented 8 years ago

_9 looks likes we are using the autosuggest call to populate the regions for "seattle" part. is that correct? recall, the original intent here was to make sure users can still get to region pages when the autosuggest service is down. that said, i think the current behavior makes sense, but can we fall back if we get a 500 from the AS to the original query posted at the beginning of this ticket?

aaasen commented 8 years ago

For 9, we are not using the autosuggest API. We are using the $q parameter as described in the original ticket. See here: https://github.com/socrata/opendatanetwork.com/blob/staging/controllers/api.js#L41

zang0 commented 8 years ago

Ok. Wow, the results are super similar. Closing this ticket. Opening up individuals now that we're in the final stretch. I'll port 7 n 8 above.