Class: RiddlerAdmin::Slug

Inherits:
ApplicationRecord show all
Defined in:
app/models/riddler_admin/slug.rb

Constant Summary collapse

MODEL_KEY =
"sl".freeze
ID_LENGTH =

916_132_832 per second

5

Instance Method Summary collapse

Instance Method Details

#create_remoteObject



32
33
34
# File 'app/models/riddler_admin/slug.rb', line 32

def create_remote
  content_management_grpc.create_slug create_request_proto
end

#daily_statsObject



25
26
27
28
29
30
# File 'app/models/riddler_admin/slug.rb', line 25

def daily_stats
  day_stats = stats_response.slug_stats.detect { |ss| ss.interval == :DAY }
  day_stats.event_counts
rescue GRPC::Unavailable, GRPC::DeadlineExceeded
  []
end

#to_protoObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/models/riddler_admin/slug.rb', line 40

def to_proto
  proto = ::Riddler::Protobuf::Slug.new \
    id: id,
    created_at: timestamp_proto(created_at),
    updated_at: timestamp_proto(updated_at),
    name: name,
    status: status.upcase.to_sym,
    content_definition_id: content_definition.id

  if interaction_identity.to_s.strip != ""
    proto.interaction_identity = interaction_identity
  end

  if target_predicate.to_s.strip != ""
    proto.target_predicate = target_predicate
  end

  proto
end

#update_remoteObject



36
37
38
# File 'app/models/riddler_admin/slug.rb', line 36

def update_remote
  content_management_grpc.update_slug update_request_proto
end