colab_integration_plugin_controller.rb
666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class ColabIntegrationPluginController < ApplicationController
include ProfileDataExport
def index
timestamp = get_timestamp params[:timestamp]
profiles = if timestamp
environment.profiles.where("updated_at > ?", timestamp)
else
environment.profiles
end
data = {
"timestamp" => Time.zone.now.to_s,
"total" => profiles.count,
"profiles" => []
}
profiles.each do |profile|
data["profiles"] << attr_to_hash(profile)
end
render json: data.to_json
data.to_json
end
private
def get_timestamp timestamp
begin
Time.parse timestamp
rescue
nil
end
end
end