-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Denormalize event type for request and event logs #829
Open
ezekg
wants to merge
3
commits into
master
Choose a base branch
from
feature/denormalize-event-type-for-request-logs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
denormalize event type for request and event logs
- Loading branch information
commit 5dde81538f833bb334f962bc30cba0e3efe425e6
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
class RequestLog < ApplicationRecord | ||
include Keygen::EE::ProtectedClass[entitlements: %i[request_logs]] | ||
include Denormalizable | ||
include Environmental | ||
include Accountable | ||
include DateRangeable | ||
|
@@ -11,12 +12,15 @@ class RequestLog < ApplicationRecord | |
|
||
belongs_to :requestor, polymorphic: true, optional: true | ||
belongs_to :resource, polymorphic: true, optional: true | ||
belongs_to :event_type, optional: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this being set? |
||
has_one :event_log, | ||
inverse_of: :request_log | ||
|
||
has_environment | ||
has_account | ||
|
||
denormalizes :event, from: :event_type, prefix: :event_type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be denormalizing |
||
|
||
# NOTE(ezekg) Would love to add a default instead of this, but alas, | ||
# the table is too big and it would break everything. | ||
before_create -> { self.created_date ||= (created_at || Date.current) } | ||
|
7 changes: 7 additions & 0 deletions
7
db/migrate/20240501124919_add_event_type_event_to_event_logs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddEventTypeEventToEventLogs < ActiveRecord::Migration[7.1] | ||
verbose! | ||
|
||
def change | ||
add_column :event_logs, :event_type_event, :string, null: true | ||
ezekg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
db/migrate/20240501124926_add_event_type_event_to_request_logs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class AddEventTypeEventToRequestLogs < ActiveRecord::Migration[7.1] | ||
verbose! | ||
|
||
def change | ||
add_column :request_logs, :event_type_event, :string, null: true | ||
add_column :request_logs, :event_type_id, :uuid, null: true | ||
ezekg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible race condition here since there's no guarantee an event log will be inserted after a request log. Need to rethink this (and write appropriate tests).