-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate panko serializers, change APi for using panko serializers
- Loading branch information
Showing
22 changed files
with
175 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class CompanySerializer < ApplicationSerializer | ||
set_id :uuid | ||
class CompanySerializer < PankoApplicationSerializer | ||
ATTRIBUTES = %w[uuid title repositories_count accessable].freeze | ||
|
||
attribute :uuid, if: proc { |_, params| required_field?(params, 'uuid') }, &:uuid | ||
attribute :title, if: proc { |_, params| required_field?(params, 'title') }, &:title | ||
# rubocop: disable Layout/LineLength | ||
attribute :repositories_count, if: proc { |_, params| required_field?(params, 'repositories_count') }, &:repositories_count | ||
# rubocop: enable Layout/LineLength | ||
attribute :accessable, if: proc { |_, params| required_field?(params, 'accessable') }, &:accessable | ||
attributes :uuid, :title, :repositories_count, :accessable | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
class InsightSerializer < ApplicationSerializer | ||
extend Helpers::Insight | ||
class InsightSerializer < PankoApplicationSerializer | ||
include Helpers::Insight | ||
|
||
attribute :values do |object, params| | ||
params[:insight_fields].index_with do |insight_field| | ||
attributes :id, :values, :entity | ||
|
||
def id = SecureRandom.hex | ||
|
||
def values | ||
context[:insight_fields].index_with do |insight_field| | ||
value = object[insight_field] | ||
{ | ||
value: Insight::DECIMAL_ATTRIBUTES.include?(insight_field.to_sym) ? value.to_f : value, | ||
ratio_value: params[:ratio_enabled] ? compare_with_previous_period(object, insight_field, params) : nil | ||
ratio_value: context[:ratio_enabled] ? compare_with_previous_period(object, insight_field, context) : nil | ||
}.compact | ||
end | ||
end | ||
|
||
attribute :entity do |object, params| | ||
params[:no_entity] ? nil : (Rails.cache.read("entity_payload_#{object.entity_id}_v1") || Entity::EMPTY_PAYLOAD) | ||
def entity | ||
context[:no_entity] ? nil : (Rails.cache.read("entity_payload_#{object.entity_id}_v1") || Entity::EMPTY_PAYLOAD) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class PankoApplicationSerializer < Panko::Serializer | ||
end |
Oops, something went wrong.