Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event display endpoint #210

Merged
merged 4 commits into from
Oct 14, 2015
Merged

Add event display endpoint #210

merged 4 commits into from
Oct 14, 2015

Conversation

eeeschwartz
Copy link
Member

A new use case

This is a step towards a use case we've found useful in the city of Lexington:

The event is a polygon that I subscribe to

Our example is for notifications when leaf collection crews visit your neighborhood. Here's a GIF of the Citygram UI for this dataset.

Thanks to Citygram's backend flexibility, making this work is minor UI issue. Citygram triggers notifications equally well for any intersection:

  • normal Citygram case: an event point inside of my subscription polygon
  • leaf collection case: my subscription point (my house) inside of an event polygon

The proposed change

This PR irons out a kink in the way Citygram displays events during sign-up:

  • Currently, it shows the last 7 days of events
  • In this case, we want to show the single most recent event for a given polygon no matter when it happened

Rather than change the way the Citygram works on the server-side, this PR let's a given publisher fetch events from a specified endpoint if desired. In our case, a citygram-services endpoint with a slightly different format works perfectly.

A side perk is that this would allow a standard publisher to display more than 7 days of events or change the wording of the Leaflet pop-up during sign-up, for example.

Any thoughts welcome.

app.state.publisher_id = $publisher.data('publisher-id');

// todo: make eventsArePolygons a property of a publisher
app.eventsArePolygons = $publisher.data('publisher-title').match(/Leaf Collection/);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make this matching less "magical"? Leaf Collection might not be the only polygon point of interest. Is this something that could/should be moved to the Publisher model?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bigfleet definitely. The magical matching is a weirdbeard holdover from a polygon proof of concept last year.

I'll put something together for this PR that works more generally.

@eeeschwartz
Copy link
Member Author

@bigfleet
Copy link
Contributor

Without totally having thought about this, is it related at all to #212 ?

@bigfleet
Copy link
Contributor

@eeeschwartz This looks good, I'm going to evaluate on my laptop before merging. If that checks out, I'll get it deployed along with bringing Tulsa online.

@eeeschwartz
Copy link
Member Author

Thanks @bigfleet!

If you want to test against the production leaf collection dataset, you could:

  • Merge and deploy the citygram-services CORS PR
  • Run the following in IRB:
Publisher.where(city: 'Lexington', title: 'Leaf Collection').first.update_all(events_are_polygons:true, event_display_endpoint: 'https://citygram-services.herokuapp.com/lexington-leaf-collection-citygram-events-format')

@eeeschwartz eeeschwartz force-pushed the add-event-display-endpoint branch from e123ad7 to 349729a Compare October 13, 2015 16:50
@eeeschwartz
Copy link
Member Author

@bigfleet I fixed the conflict in script.js. Holler if anything else I can take a look at.

@bigfleet bigfleet merged commit c0647df into master Oct 14, 2015
@bigfleet bigfleet deleted the add-event-display-endpoint branch October 14, 2015 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants