Skip to content

Commit

Permalink
refactor: merge cac and experimentation schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Datron committed Dec 19, 2024
1 parent f4301d8 commit e70c660
Show file tree
Hide file tree
Showing 90 changed files with 8,470 additions and 20,532 deletions.
157 changes: 0 additions & 157 deletions crates/context_aware_config/samples/default_config.json

This file was deleted.

18 changes: 0 additions & 18 deletions crates/context_aware_config/samples/dimensions.json

This file was deleted.

42 changes: 0 additions & 42 deletions crates/context_aware_config/samples/overrides.json

This file was deleted.

2 changes: 1 addition & 1 deletion crates/context_aware_config/src/api/audit_log/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use chrono::{Duration, Utc};
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
use service_utils::service::types::DbConnection;
use superposition_types::{
cac::{models::EventLog, schema::event_log::dsl as event_log},
database::{models::cac::EventLog, schema::event_log::dsl as event_log},
result as superposition, PaginatedResponse,
};

Expand Down
8 changes: 4 additions & 4 deletions crates/context_aware_config/src/api/config/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ use service_utils::{
use superposition_macros::response_error;
use superposition_macros::{bad_argument, db_error, unexpected_error};
use superposition_types::{
cac::{
models::ConfigVersion,
schema::{config_versions::dsl as config_versions, event_log::dsl as event_log},
},
custom_query::{
self as superposition_query, CustomQuery, PaginationParams, QueryMap,
},
database::{
models::cac::ConfigVersion,
schema::{config_versions::dsl as config_versions, event_log::dsl as event_log},
},
result as superposition, Cac, Condition, Config, Context, Overrides,
PaginatedResponse, TenantConfig, User,
};
Expand Down
14 changes: 7 additions & 7 deletions crates/context_aware_config/src/api/context/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ use superposition_macros::{
bad_argument, db_error, not_found, unexpected_error, validation_error,
};
use superposition_types::{
cac::{
models::Context,
custom_query::{self as superposition_query, CustomQuery, DimensionQuery, QueryMap},
database::{
models::cac::Context,
schema::{
contexts::{self, id},
default_configs::dsl,
},
},
custom_query::{self as superposition_query, CustomQuery, DimensionQuery, QueryMap},
result as superposition, Cac, Contextual, Overridden, Overrides, PaginatedResponse,
SortBy, TenantConfig, User,
};
Expand Down Expand Up @@ -557,7 +557,7 @@ async fn get_context_from_condition(
db_conn: DbConnection,
req: Json<Map<String, Value>>,
) -> superposition::Result<Json<Context>> {
use superposition_types::cac::schema::contexts::dsl::*;
use superposition_types::database::schema::contexts::dsl::*;

let context_id = hash(&Value::Object(req.into_inner()));
let DbConnection(mut conn) = db_conn;
Expand All @@ -574,7 +574,7 @@ async fn get_context(
path: Path<String>,
db_conn: DbConnection,
) -> superposition::Result<Json<Context>> {
use superposition_types::cac::schema::contexts::dsl::*;
use superposition_types::database::schema::contexts::dsl::*;

let ctx_id = path.into_inner();
let DbConnection(mut conn) = db_conn;
Expand All @@ -592,7 +592,7 @@ async fn list_contexts(
dimension_params: DimensionQuery<QueryMap>,
db_conn: DbConnection,
) -> superposition::Result<Json<PaginatedResponse<Context>>> {
use superposition_types::cac::schema::contexts::dsl::*;
use superposition_types::database::schema::contexts::dsl::*;
let DbConnection(mut conn) = db_conn;

let filter_params = filter_params.into_inner();
Expand Down Expand Up @@ -835,7 +835,7 @@ async fn weight_recompute(
#[cfg(feature = "high-performance-mode")] tenant: Tenant,
user: User,
) -> superposition::Result<HttpResponse> {
use superposition_types::cac::schema::contexts::dsl::*;
use superposition_types::database::schema::contexts::dsl::*;
let DbConnection(mut conn) = db_conn;

let result: Vec<Context> = contexts.load(&mut conn).map_err(|err| {
Expand Down
2 changes: 1 addition & 1 deletion crates/context_aware_config/src/api/context/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde_json::{Map, Value};
use service_utils::helpers::extract_dimensions;
use superposition_macros::{unexpected_error, validation_error};
use superposition_types::{
cac::schema::{
database::schema::{
default_configs::dsl,
dimensions::{self},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use superposition_macros::{
bad_argument, db_error, not_found, unexpected_error, validation_error,
};
use superposition_types::{
cac::{
models::{self as models, Context, DefaultConfig},
custom_query::PaginationParams,
database::{
models::cac::{self as models, Context, DefaultConfig},
schema::{self, contexts::dsl::contexts, default_configs::dsl},
},
custom_query::PaginationParams,
result as superposition, PaginatedResponse, User,
};

Expand Down
6 changes: 3 additions & 3 deletions crates/context_aware_config/src/api/dimension/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use diesel::{
use service_utils::service::types::{AppState, DbConnection};
use superposition_macros::{bad_argument, db_error, not_found, unexpected_error};
use superposition_types::{
cac::{
models::Dimension,
custom_query::PaginationParams,
database::{
models::cac::Dimension,
schema::dimensions::{self, dsl::*},
types::DimensionWithMandatory,
},
custom_query::PaginationParams,
result as superposition, PaginatedResponse, TenantConfig, User,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/context_aware_config/src/api/dimension/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use service_utils::helpers::extract_dimensions;
use std::collections::HashMap;
use superposition_macros::{bad_argument, db_error, unexpected_error};
use superposition_types::{
cac::{
models::{Context, Dimension},
database::{
models::cac::{Context, Dimension},
schema::{contexts::dsl::contexts, dimensions::dsl::*},
},
result as superposition, Cac, Condition,
Expand Down
6 changes: 3 additions & 3 deletions crates/context_aware_config/src/api/functions/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use serde_json::json;
use service_utils::service::types::DbConnection;
use superposition_macros::{bad_argument, not_found, unexpected_error};
use superposition_types::{
cac::{
models::Function,
custom_query::PaginationParams,
database::{
models::cac::Function,
schema::{
self,
functions::{dsl, dsl::functions, function_name, last_modified_at},
},
},
custom_query::PaginationParams,
result as superposition, PaginatedResponse, User,
};
use validation_functions::{compile_fn, execute_fn};
Expand Down
4 changes: 2 additions & 2 deletions crates/context_aware_config/src/api/functions/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use diesel::{
use std::str;
use superposition_macros::unexpected_error;
use superposition_types::{
cac::{
models::Function,
database::{
models::cac::Function,
schema::{self, functions::dsl::functions},
},
result as superposition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use serde_json::Value;
use service_utils::service::types::DbConnection;
use superposition_macros::{bad_argument, db_error};
use superposition_types::{
cac::{
models::TypeTemplate,
custom_query::PaginationParams,
database::{
models::cac::TypeTemplate,
schema::type_templates::{self, dsl},
},
custom_query::PaginationParams,
result as superposition, PaginatedResponse, User,
};

Expand Down
Loading

0 comments on commit e70c660

Please sign in to comment.