-
-
Notifications
You must be signed in to change notification settings - Fork 228
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
Allows you to override the root path directly on a per-instance basis #287
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ module Statements | |
# SELECT * FROM users WHERE users.active = 't' | ||
# SQL | ||
# | ||
def create_view(name, version: nil, sql_definition: nil, materialized: false) | ||
def create_view(name, version: nil, sql_definition: nil, materialized: false, root_path: Rails.root) | ||
if version.present? && sql_definition.present? | ||
raise( | ||
ArgumentError, | ||
|
@@ -34,7 +34,7 @@ def create_view(name, version: nil, sql_definition: nil, materialized: false) | |
version = 1 | ||
end | ||
|
||
sql_definition ||= definition(name, version) | ||
sql_definition ||= definition(name, version, root_path: root_path) | ||
|
||
if materialized | ||
Scenic.database.create_materialized_view( | ||
|
@@ -88,7 +88,7 @@ def drop_view(name, revert_to_version: nil, materialized: false) | |
# @example | ||
# update_view :engagement_reports, version: 3, revert_to_version: 2 | ||
# | ||
def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false) | ||
def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false, root_path: Rails.root) | ||
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. Metrics/ParameterLists: Avoid parameter lists longer than 5 parameters. [6/5] |
||
if version.blank? && sql_definition.blank? | ||
raise( | ||
ArgumentError, | ||
|
@@ -103,7 +103,7 @@ def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, | |
) | ||
end | ||
|
||
sql_definition ||= definition(name, version) | ||
sql_definition ||= definition(name, version, root_path: root_path) | ||
|
||
if materialized | ||
Scenic.database.update_materialized_view( | ||
|
@@ -132,7 +132,7 @@ def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, | |
# @example | ||
# replace_view :engagement_reports, version: 3, revert_to_version: 2 | ||
# | ||
def replace_view(name, version: nil, revert_to_version: nil, materialized: false) | ||
def replace_view(name, version: nil, revert_to_version: nil, materialized: false, root_path: Rails.root) | ||
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. Lint/UnusedMethodArgument: Unused method argument - revert_to_version. |
||
if version.blank? | ||
raise ArgumentError, "version is required" | ||
end | ||
|
@@ -141,15 +141,15 @@ def replace_view(name, version: nil, revert_to_version: nil, materialized: false | |
raise ArgumentError, "Cannot replace materialized views" | ||
end | ||
|
||
sql_definition = definition(name, version) | ||
sql_definition = definition(name, version, root_path: root_path) | ||
|
||
Scenic.database.replace_view(name, sql_definition) | ||
end | ||
|
||
private | ||
|
||
def definition(name, version) | ||
Scenic::Definition.new(name, version).to_sql | ||
def definition(name, version, root_path: Rails.root) | ||
Scenic::Definition.new(name, version, root_path: root_path).to_sql | ||
end | ||
|
||
def no_data(materialized) | ||
|
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.
Metrics/LineLength: Line is too long. [104/80]