Migrate serialization to jsonapi-serializer (#9682)

This replaces the abandoned fast_jsonapi.
This commit is contained in:
Jan Klimo 2020-08-08 20:41:44 +07:00 committed by GitHub
parent 1e21815ce7
commit a6ea2c9618
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 21 additions and 45 deletions

View file

@ -38,7 +38,6 @@ gem "email_validator", "~> 2.0" # Email validator for Rails and ActiveModel
gem "emoji_regex", "~> 3.0" # A pair of Ruby regular expressions for matching Unicode Emoji symbols
gem "envied", "~> 0.9" # Ensure presence and type of your app's ENV-variables
gem "faraday-http-cache", "~> 2.2" # Middleware to handle HTTP caching
gem "fast_jsonapi", "~> 1.5" # Serializer for Ruby objects
gem "fastly", "~> 2.5" # Client library for the Fastly acceleration system
gem "feedjira", "~> 3.1" # A feed fetching and parsing library
gem "field_test", "~> 0.4" # A/B testing
@ -58,6 +57,7 @@ gem "httparty", "~> 0.18" # Makes http fun! Also, makes consuming restful web se
gem "inline_svg", "~> 1.7" # Embed SVG documents in your Rails views and style them with CSS
gem "jbuilder", "~> 2.10" # Create JSON structures via a Builder-style DSL
gem "jquery-rails", "~> 4.4" # A gem to automate using jQuery with Rails
gem "jsonapi-serializer", "~> 2.0" # Serializer for Ruby objects
gem "kaminari", "~> 1.2" # A Scope & Engine based, clean, powerful, customizable and sophisticated paginator
gem "katex", "~> 0.6.0" # This rubygem enables you to render TeX math to HTML using KaTeX. It uses ExecJS under the hood
gem "liquid", "~> 4.0" # A secure, non-evaling end user template engine with aesthetic markup

View file

@ -298,8 +298,6 @@ GEM
faraday (>= 0.8)
faraday_middleware (1.0.0)
faraday (~> 1.0)
fast_jsonapi (1.5)
activesupport (>= 4.2)
fastimage (2.1.1)
fastly (2.5.3)
feedjira (3.1.1)
@ -423,6 +421,8 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.3.0)
jsonapi-serializer (2.0.0)
activesupport (>= 4.2)
jwt (2.2.1)
kaminari (1.2.1)
activesupport (>= 4.1.0)
@ -885,7 +885,6 @@ DEPENDENCIES
factory_bot_rails (~> 6.1)
faker (~> 2.13)
faraday-http-cache (~> 2.2)
fast_jsonapi (~> 1.5)
fastly (~> 2.5)
feedjira (~> 3.1)
field_test (~> 0.4)
@ -910,6 +909,7 @@ DEPENDENCIES
inline_svg (~> 1.7)
jbuilder (~> 2.10)
jquery-rails (~> 4.4)
jsonapi-serializer (~> 2.0)
kaminari (~> 1.2)
katex (~> 0.6.0)
knapsack_pro (~> 2.1.1)

View file

@ -0,0 +1,3 @@
class ApplicationSerializer
include JSONAPI::Serializer
end

View file

@ -1,7 +1,5 @@
module Search
class ArticleSerializer
include FastJsonapi::ObjectSerializer
class ArticleSerializer < ApplicationSerializer
attribute :id, &:search_id
attributes :approved, :body_text, :class_name, :cloudinary_video_url,

View file

@ -1,7 +1,5 @@
module Search
class ChatChannelMembershipSerializer
include FastJsonapi::ObjectSerializer
class ChatChannelMembershipSerializer < ApplicationSerializer
attributes :id, :status, :viewable_by, :chat_channel_id, :last_opened_at,
:channel_text, :channel_last_message_at, :channel_status,
:channel_status, :channel_type, :channel_username, :channel_name,

View file

@ -1,7 +1,5 @@
module Search
class CommentSerializer
include FastJsonapi::ObjectSerializer
class CommentSerializer < ApplicationSerializer
attribute :id, &:search_id
attributes :path, :public_reactions_count

View file

@ -1,7 +1,5 @@
module Search
class ListingAuthorSerializer
include FastJsonapi::ObjectSerializer
class ListingAuthorSerializer < ApplicationSerializer
attributes :username, :name, :profile_image_90
end
end

View file

@ -1,7 +1,5 @@
module Search
class ListingSerializer
include FastJsonapi::ObjectSerializer
class ListingSerializer < ApplicationSerializer
attributes :id,
:body_markdown,
:bumped_at,

View file

@ -1,7 +1,5 @@
module Search
class NestedUserSerializer
include FastJsonapi::ObjectSerializer
class NestedUserSerializer < ApplicationSerializer
attributes :id, :name, :pro, :profile_image_90, :username
end
end

View file

@ -1,7 +1,5 @@
module Search
class PodcastEpisodeSerializer
include FastJsonapi::ObjectSerializer
class PodcastEpisodeSerializer < ApplicationSerializer
attribute :id, &:search_id
attributes :body_text, :class_name, :comments_count, :hotness_score, :path,

View file

@ -1,7 +1,5 @@
module Search
class ReactionSerializer
include FastJsonapi::ObjectSerializer
class ReactionSerializer < ApplicationSerializer
attributes :id, :category, :status, :user_id
attribute :reactable do |reaction|

View file

@ -1,7 +1,5 @@
module Search
class TagSerializer
include FastJsonapi::ObjectSerializer
class TagSerializer < ApplicationSerializer
attributes :id, :name, :hotness_score, :supported, :short_summary, :rules_html
end
end

View file

@ -1,7 +1,5 @@
module Search
class UserSerializer
include FastJsonapi::ObjectSerializer
class UserSerializer < ApplicationSerializer
attributes :id,
:available_for,
:comments_count,

View file

@ -1,6 +1,5 @@
module Webhook
class ArticleDestroyedSerializer
include FastJsonapi::ObjectSerializer
class ArticleDestroyedSerializer < ApplicationSerializer
set_type :article
attributes :title
end

View file

@ -1,7 +1,5 @@
module Webhook
class ArticleSerializer
include FastJsonapi::ObjectSerializer
class ArticleSerializer < ApplicationSerializer
set_type :article
attributes :title, :description, :readable_publish_date, :cached_tag_list, :cached_tag_list_array,
:slug, :path, :url, :comments_count, :public_reactions_count, :body_markdown

View file

@ -1,7 +1,5 @@
module Webhook
class EventSerializer
include FastJsonapi::ObjectSerializer
class EventSerializer < ApplicationSerializer
set_type :webhook_event
set_id :event_id

View file

@ -1,7 +1,5 @@
module Webhook
class UserSerializer
include FastJsonapi::ObjectSerializer
class UserSerializer < ApplicationSerializer
attributes :name, :username, :twitter_username, :github_username
attribute :website_url, &:processed_website_url
attribute :profile_image do |user|

Binary file not shown.

Binary file not shown.