-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c072cb
commit 03224ab
Showing
18 changed files
with
133,088 additions
and
131,889 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class DynamicDatasetsController < ApplicationController | ||
before_action :set_dynamic_dataset, only: %i[show] | ||
before_action :set_project, only: %i[index] | ||
|
||
def index | ||
@dynamic_datasets = @project.dynamic_datasets | ||
end | ||
|
||
private | ||
|
||
def set_project | ||
@project = Project.find(params[:project_id]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: dynamic_datasets | ||
# | ||
# id :bigint not null, primary key | ||
# code :string | ||
# name :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# project_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_dynamic_datasets_on_project_id (project_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (project_id => projects.id) | ||
# | ||
class DynamicDataset < ApplicationRecord | ||
belongs_to :project | ||
|
||
def execute | ||
# Use `eval` to execute the code. Be very cautious with this approach. | ||
eval(code) | ||
rescue StandardError => e | ||
"Error executing code: #{e.message}" | ||
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
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
json.extract! dynamic_dataset, :id, :name, :project_id | ||
|
||
json.data dynamic_dataset.execute |
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,3 @@ | ||
# frozen_string_literal: true | ||
|
||
json.array! @dynamic_datasets, partial: 'dynamic_datasets/dynamic_dataset', as: :dynamic_dataset |
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,3 @@ | ||
# frozen_string_literal: true | ||
|
||
json.partial! 'dynamic_datasets/dynamic_dataset', dynamic_dataset: @dynamic_dataset |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateDynamicDatasets < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :dynamic_datasets do |t| | ||
t.string :name | ||
t.string :code | ||
t.references :project, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe DynamicDatasetsController, type: :controller do | ||
include_context 'authentication' | ||
render_views | ||
|
||
let(:project) { create(:project) } | ||
let(:dynamic_dataset) do | ||
code = 'Customer.all.pluck(:id, :name)' | ||
create(:dynamic_dataset, code:, project:) | ||
end | ||
|
||
before do | ||
create_list(:customer, 5) | ||
end | ||
|
||
describe 'GET #index' do | ||
it 'returns a success response' do | ||
expected_result = [{ | ||
'id' => dynamic_dataset.id, | ||
'name' => dynamic_dataset.name, | ||
'project_id' => dynamic_dataset.project_id, | ||
'data' => Customer.all.pluck(:id, :name) | ||
}] | ||
|
||
get :index, params: { project_id: project.id } | ||
|
||
expect(response.parsed_body).to eq(expected_result) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: dynamic_datasets | ||
# | ||
# id :bigint not null, primary key | ||
# code :string | ||
# name :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# project_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_dynamic_datasets_on_project_id (project_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (project_id => projects.id) | ||
# | ||
FactoryBot.define do | ||
factory :dynamic_dataset do | ||
name { 'MyString' } | ||
code { 'MyString' } | ||
project { FactoryBot.create(:project) } | ||
end | ||
end |
264,754 changes: 132,870 additions & 131,884 deletions
264,754
spec/fixtures/vcr_cassettes/clients_tts_azure_issue_list.yml
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: dynamic_datasets | ||
# | ||
# id :bigint not null, primary key | ||
# code :string | ||
# name :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# project_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_dynamic_datasets_on_project_id (project_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (project_id => projects.id) | ||
# | ||
require 'rails_helper' | ||
|
||
RSpec.describe DynamicDataset, type: :model do | ||
context '#execute' do | ||
it 'executes the code and returns the result' do | ||
users = create_list(:user, 5) | ||
expected_result = users.map { |user| [user.id, user.first_name] } | ||
code = 'User.all.pluck(:id, :first_name)' | ||
dynamic_dataset = create(:dynamic_dataset, code:) | ||
result = dynamic_dataset.execute | ||
expect(result).to eq(expected_result) | ||
end | ||
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