Skip to content

Commit

Permalink
Feature/padw 112 sync function (#31)
Browse files Browse the repository at this point in the history
* chore (PADW-112): Cleanup Imports
* feat (PADW-112): Add Sync
* chore (PADW-112): Consolidate Get DV Schemas
* chore (PADW-112): Fix capitalization of 'Built'
  • Loading branch information
analyzer1 authored Dec 16, 2024
1 parent 58f6d93 commit cb5c775
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
24 changes: 20 additions & 4 deletions extension/src/controller/dv_loader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pg_sys::Hash;
use pgrx::prelude::*;
use std::collections::HashMap;
use crate::model::dv_schema::{self, *};
use crate::model::dv_schema::*;

pub fn column_in_dv_schemas(table_oid: u32, column_ordinal_position: i16) -> bool {

pub fn get_dv_schemas() -> Vec<DVSchema> {

// get DV_SCHEMAS via Query
let get_schemas_query: &str = r#"
Expand Down Expand Up @@ -33,13 +33,29 @@ pub fn column_in_dv_schemas(table_oid: u32, column_ordinal_position: i16) -> boo
}
});

for dv_schema in dv_schemas {
dv_schemas
}

pub fn column_in_dv_schemas(table_oid: u32, column_ordinal_position: i16) -> bool {

for dv_schema in get_dv_schemas() {
if dv_schema.contains_column(table_oid, column_ordinal_position) {return true;}
}

false
}

// Load All DV Schemas

pub fn dv_load_schemas_all() -> bool {

for dv_schema in get_dv_schemas() {
dv_data_loader(&dv_schema);
log!("DV Schema (Build ID) Loaded: {}", dv_schema.id.to_string())
}
true
}

pub fn dv_load_schema_from_build_id(build_id: &String) -> Option<DVSchema> {
let get_schema_query: &str = r#"
SELECT schema
Expand Down
13 changes: 12 additions & 1 deletion extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ fn build_default() -> String {
message
}

// Syncing All DV Schemas
#[pg_extern(name="sync")]
fn sync_default() -> String {
let load_complete = dv_loader::dv_load_schemas_all();
if load_complete {
"All DV schema objects updated.".to_string()
} else {
"Failed Load".to_string()
}
}

#[pg_extern]
fn source_include( schema_pattern_include: &str,
table_pattern_include: default!(Option<&str>, "NULL"),
Expand Down Expand Up @@ -152,7 +163,7 @@ fn source_column() -> Result<
row["column"].value(),
{
if is_built {
Ok(Some("built".to_string()))
Ok(Some("Built".to_string()))
} else {
row["status"].value()
}
Expand Down

0 comments on commit cb5c775

Please sign in to comment.