12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/models/think_feel_do_engine/reports/user_agent.rb', line 12
def self.all
Participant.not_moderator.select(:id, :study_id).map do |participant|
user_agents = EventCapture::Event
.where(participant_id: participant.id)
.map { |event| event.payload["ua"] }
.uniq
user_agents.map do |agent|
ua = UserAgentParser.parse(agent)
next if ua.family == "Other" && ua.version.to_s == ""
{
participant_id: participant.study_id,
user_agent_family: ua.family,
user_agent_version: ua.version.to_s,
user_agent_os: ua.os.to_s
}
end
end.flatten.compact
end
|