From cb18791e3d5c0fbdeef3c3c891f254cee55217da Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sun, 3 Jun 2018 16:38:22 +0200 Subject: [PATCH 1/3] Remove database ID from public JSON URLs Having database IDs in some places, but not supporting them throughout the API is confusing. * add slug to related events metadata, remove id in a later commit * generated urls use guid for events * generated urls use acronym for conferences * recordings still use database ID --- app/views/public/shared/_conference.json.jbuilder | 2 +- app/views/public/shared/_event.json.jbuilder | 5 +++-- app/views/public/shared/_recording.json.jbuilder | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/public/shared/_conference.json.jbuilder b/app/views/public/shared/_conference.json.jbuilder index e2bf3e85..76e42f79 100644 --- a/app/views/public/shared/_conference.json.jbuilder +++ b/app/views/public/shared/_conference.json.jbuilder @@ -3,4 +3,4 @@ json.webgen_location conference.slug json.logo_url conference.logo_url json.images_url conference.get_images_url json.recordings_url conference.get_recordings_url -json.url public_conference_url(conference, format: :json) +json.url public_conference_url(id: conference.acronym, format: :json) diff --git a/app/views/public/shared/_event.json.jbuilder b/app/views/public/shared/_event.json.jbuilder index 243ffd32..130358f7 100644 --- a/app/views/public/shared/_event.json.jbuilder +++ b/app/views/public/shared/_event.json.jbuilder @@ -4,9 +4,10 @@ json.duration event.duration json.thumb_url event.get_thumb_url json.poster_url event.get_poster_url json.frontend_link frontend_event_url(slug: event.slug) -json.url public_event_url(event, format: :json) -json.conference_url public_conference_url(event.conference, format: :json) +json.url public_event_url(id: event.guid, format: :json) +json.conference_url public_conference_url(id: event.conference.acronym, format: :json) json.related(event.metadata['related']) do |id, weight| json.event_id id + json.event_slug Event.find(id)&.slug json.weight weight end diff --git a/app/views/public/shared/_recording.json.jbuilder b/app/views/public/shared/_recording.json.jbuilder index 4895f4a5..0f3016e1 100644 --- a/app/views/public/shared/_recording.json.jbuilder +++ b/app/views/public/shared/_recording.json.jbuilder @@ -1,5 +1,5 @@ json.extract! recording, :size, :length, :mime_type, :language, :filename, :state, :folder, :high_quality, :width, :height, :updated_at json.recording_url recording.get_recording_url json.url public_recording_url(recording, format: :json) -json.event_url public_event_url(recording.event, format: :json) -json.conference_url public_conference_url(recording.conference, format: :json) +json.event_url public_event_url(id: recording.event.guid, format: :json) +json.conference_url public_conference_url(id: recording.conference.acronym, format: :json) From 4bac7d497c04c16e3341e68b6ac4a7d8d159d215 Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sun, 3 Jun 2018 20:37:32 +0200 Subject: [PATCH 2/3] Guid instead of slug --- app/views/public/shared/_event.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/public/shared/_event.json.jbuilder b/app/views/public/shared/_event.json.jbuilder index 130358f7..94199f1b 100644 --- a/app/views/public/shared/_event.json.jbuilder +++ b/app/views/public/shared/_event.json.jbuilder @@ -8,6 +8,6 @@ json.url public_event_url(id: event.guid, format: :json) json.conference_url public_conference_url(id: event.conference.acronym, format: :json) json.related(event.metadata['related']) do |id, weight| json.event_id id - json.event_slug Event.find(id)&.slug + json.event_guid Event.find(id)&.guid json.weight weight end From d4b813d2f8709ed09a2d29c5c9dc31c9e9b9a2e5 Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sun, 3 Jun 2018 20:37:43 +0200 Subject: [PATCH 3/3] Remove metadata from event json --- app/views/public/shared/_event.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/public/shared/_event.json.jbuilder b/app/views/public/shared/_event.json.jbuilder index 94199f1b..6760d9ab 100644 --- a/app/views/public/shared/_event.json.jbuilder +++ b/app/views/public/shared/_event.json.jbuilder @@ -1,4 +1,4 @@ -json.extract! event, :guid, :title, :subtitle, :slug, :link, :description, :original_language, :persons, :tags, :view_count, :promoted, :metadata, :date, :release_date, :updated_at +json.extract! event, :guid, :title, :subtitle, :slug, :link, :description, :original_language, :persons, :tags, :view_count, :promoted, :date, :release_date, :updated_at json.length event.duration json.duration event.duration json.thumb_url event.get_thumb_url