Class: GithubDailyDigest::ActivityAnalyzer
- Inherits:
-
Object
- Object
- GithubDailyDigest::ActivityAnalyzer
- Defined in:
- lib/activity_analyzer.rb
Instance Method Summary collapse
- #analyze(username:, activity_data:, time_window_days: 7) ⇒ Object
-
#initialize(gemini_service:, github_graphql_service:, logger:) ⇒ ActivityAnalyzer
constructor
A new instance of ActivityAnalyzer.
Constructor Details
#initialize(gemini_service:, github_graphql_service:, logger:) ⇒ ActivityAnalyzer
Returns a new instance of ActivityAnalyzer.
5 6 7 8 9 |
# File 'lib/activity_analyzer.rb', line 5 def initialize(gemini_service:, github_graphql_service:, logger:) @gemini_service = gemini_service @github_graphql_service = github_graphql_service @logger = logger end |
Instance Method Details
#analyze(username:, activity_data:, time_window_days: 7) ⇒ Object
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 38 39 40 41 42 43 44 45 46 |
# File 'lib/activity_analyzer.rb', line 11 def analyze(username:, activity_data:, time_window_days: 7) @logger.info("Analyzing activity for user: #{username}") commits = activity_data[:commits] review_count = activity_data[:review_count] commits_with_code = if @github_graphql_service @github_graphql_service.fetch_commits_changes(commits) else @logger.debug("GraphQL service not available, proceeding without detailed commit changes") commits end analysis_result = @gemini_service.analyze_activity( username: username, commits_with_code: commits_with_code, review_count: review_count, time_window_days: time_window_days ) @logger.debug("Gemini analysis result for #{username}: #{analysis_result}") # Add username and timestamp to the result for context analysis_result[:username] = username analysis_result[:analysis_timestamp] = Time.now.iso8601 # Calculate language distribution analysis_result[:language_distribution] = LanguageAnalyzer.calculate_distribution(commits_with_code.map{ |f| f[:code_changes][:files] }.flatten) if analysis_result[:error] @logger.error("Analysis failed for #{username}: #{analysis_result[:error]}") else @logger.info("Analysis successful for #{username}") end analysis_result end |