selfconference / selfconf

0 stars 1 forks source link

Simplify sponsor levels API data #6

Closed macklinu closed 8 years ago

macklinu commented 8 years ago

GET /api/events/latest/sponsors returns a list of sponsors like so:

[
    {
        "created_at": "2016-01-19T17:12:55.434-05:00",
        "event_id": 2,
        "id": 15,
        "link": "https://www.quizzle.com",
        "name": "Quizzle",
        "photo": "https://s3.amazonaws.com/selfconf/sponsors/bankrate-quizzle.png",
        "sponsor_levels": [
            {
                "created_at": "2015-07-23T13:24:47.161-05:00",
                "event_id": 2,
                "id": 16,
                "name": "Silver",
                "order": 3,
                "updated_at": "2015-07-23T13:24:47.161-05:00"
            }
        ],
        "updated_at": "2016-03-07T11:48:57.946-05:00"
    }
]

The mobile app only needs an array of strings for sponsor_levels instead of objects. It would be ideal to turn the response JSON into this:

[
    {
        "created_at": "2016-01-19T17:12:55.434-05:00",
        "event_id": 2,
        "id": 15,
        "link": "https://www.quizzle.com",
        "name": "Quizzle",
        "photo": "https://s3.amazonaws.com/selfconf/sponsors/bankrate-quizzle.png",
        "sponsor_levels": ["Silver"],
        "updated_at": "2016-03-07T11:48:57.946-05:00"
    }
]
macklinu commented 8 years ago

I'm going to see if I can get a PR up for this later tonight using jbuilder.

crebma commented 8 years ago

I might be wrong, but do we already use active mode serializers?

Thanks, Amber Conville @crebma

macklinu commented 8 years ago

I don't see any serializers in the code base. Is that preferred to Jbuilder for serializing models?

jeffaburt commented 8 years ago

Copied over from Slack (for posterity):

This might be problematic, because the iOS app imports each sponsor level as its own object (keyed off of the id) to cache it. Then, the app only asks for updated data (using from_date). For example, the sponsor may not have been updated but the sponsor level was. In this case, we would get no data when querying /sponsors but we would get some data when querying the sponsor levels. Also, the iOS app uses the order field on the sponsor level to display the sponsors with the desired ordering. At the minimum, we should at least return "sponsor_levels": [{"id": 16}] (so we can store the association) and then do a query on sponsor levels to grab the rest of the data.

macklinu commented 8 years ago

Thanks for the feedback, @jeffaburt. I'm going to close this and move this responsibility to the Android app for now.