13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/legion/extensions/apollo/api.rb', line 13
def stats_payload(now: Time.now)
return { error: 'apollo_data_not_available' } unless defined?(Legion::Data::Model::ApolloEntry)
entries = Legion::Data::Model::ApolloEntry
by_status = grouped_counts(entries, :status)
by_status['active'] = entries.exclude(status: 'archived').count
stats = {
total_entries: entries.count,
recent_24h: entries.where { created_at >= (now - 86_400) }.count,
avg_confidence: average_confidence(entries),
by_status: by_status,
by_content_type: grouped_counts(entries, :content_type)
}
stats[:total_relations] = Legion::Data::Model::ApolloRelation.count if defined?(Legion::Data::Model::ApolloRelation)
stats
end
|