Skip to content

Fix nil error in Analytics.last_month#10

Closed
jvendetti wants to merge 29 commits into
ontoportal:masterfrom
ncbo:fix/analytics-nil-safe-lookup
Closed

Fix nil error in Analytics.last_month#10
jvendetti wants to merge 29 commits into
ontoportal:masterfrom
ncbo:fix/analytics-nil-safe-lookup

Conversation

@jvendetti
Copy link
Copy Markdown
Collaborator

Summary

  • Replace unsafe chained hash access (analytics[ont][:"#{year_num}"][:"#{month_num}"]) with Hash#dig to prevent NoMethodError when analytics[ont] is nil
  • Default to 0 views and log a debug-level message when analytics data is missing for an ontology
  • Add class-level LOGGER constant for structured logging

Test plan

  • Verify Analytics.last_month returns results without errors when all ontology data is present
  • Verify no exception is raised when analytics[ont] is nil for some ontologies
  • Confirm debug log message appears when analytics data is missing

🤖 Generated with Claude Code

mdorf and others added 29 commits September 10, 2025 13:21
Fixes "method redefined; discarding old encode_with" warnings
Enhanced HTTP delete API to allow for more flexible input and response
Upgrade to Active Support 8.0.3 and Ruby 3.2.9
Use Hash#dig for nil-safe nested hash access instead of chained bracket
lookups, which raised NoMethodError when analytics[ont] was nil. Defaults
to 0 views and logs a debug message when data is missing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jvendetti jvendetti closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants