mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
* Add OpenID Connect login support * Add docs for OIDC config with Google Auth * Use Google styles for log in - Add support for linking existing account - Force users to sign-in with passoword first, when linking existing accounts - Add support to create new user when using OIDC - Add identities to user to prevent account take-ver - Make tests mocking instead of being integration tests - Manage session handling correctly - use OmniAuth.config.mock_auth instead of passing auth data via request env * Conditionally render Oauth button - Set a config item `configuration.x.auth.oidc_enabled` - Hide button if disabled --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Signed-off-by: soky srm <sokysrm@gmail.com> Co-authored-by: sokie <sokysrm@gmail.com>
35 lines
1013 B
Ruby
35 lines
1013 B
Ruby
class Settings::LlmUsagesController < ApplicationController
|
|
layout "settings"
|
|
|
|
def show
|
|
@breadcrumbs = [
|
|
[ "Home", root_path ],
|
|
[ "LLM Usage", nil ]
|
|
]
|
|
@family = Current.family
|
|
|
|
# Get date range from params or default to last 30 days
|
|
@end_date = safe_parse_date(params[:end_date]) || Date.today
|
|
@start_date = safe_parse_date(params[:start_date]) || (@end_date - 30.days)
|
|
if @start_date > @end_date
|
|
@start_date, @end_date = @end_date - 30.days, @end_date
|
|
end
|
|
|
|
# Get usage data
|
|
@llm_usages = @family.llm_usages
|
|
.for_date_range(@start_date.beginning_of_day, @end_date.end_of_day)
|
|
.recent
|
|
.limit(100)
|
|
|
|
# Get statistics
|
|
@statistics = LlmUsage.statistics_for_family(@family, start_date: @start_date.beginning_of_day, end_date: @end_date.end_of_day)
|
|
end
|
|
|
|
private
|
|
def safe_parse_date(s)
|
|
Date.iso8601(s)
|
|
rescue ArgumentError, TypeError
|
|
nil
|
|
end
|
|
end
|