Add db_push_thx branch contents
This commit is contained in:
parent
33c2b95125
commit
703aab6a33
@ -5,10 +5,11 @@ FROM ${CONTAINER_REGISTRY}/db-activity-wrapper:latest
|
|||||||
# Set up working directory
|
# Set up working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy user-specific files (block.py, schemas, requirements)
|
# Copy user-specific files (schemas, SQL, config)
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN ls ./
|
RUN ls ./
|
||||||
|
|
||||||
# Set CMD to execute the symbolic link, making it look like block.py is the entry
|
# Set CMD to execute the symbolic link, making it look like block.py is the entry
|
||||||
CMD ["python", "/app/block_wrapper.py"]
|
CMD ["python", "/app/block_wrapper.py"]
|
||||||
|
|
||||||
|
|||||||
30
README.md
30
README.md
@ -1 +1,29 @@
|
|||||||
**Hello world!!!**
|
# Block for inserting/upserting THX attributes into the thx table
|
||||||
|
|
||||||
|
This block is responsible for inserting or updating THX-related records in the `thx` table using the same database configuration as `db_push_v1`.
|
||||||
|
|
||||||
|
## Table DDL
|
||||||
|
|
||||||
|
The following DDL illustrates the `thx` table structure (Postgres style, conceptually compatible with DuckDB for tests):
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- creating thx table
|
||||||
|
CREATE TABLE IF NOT EXISTS thx (
|
||||||
|
application_key TEXT PRIMARY KEY,
|
||||||
|
application_timestamp TIMESTAMP NULL,
|
||||||
|
digital_id_first_seen TEXT NULL,
|
||||||
|
summary_risk_score TEXT NULL,
|
||||||
|
cpu_clock TEXT NULL,
|
||||||
|
true_ip_first_seen TEXT NULL,
|
||||||
|
ssn_hash_first_seen TEXT NULL,
|
||||||
|
account_email_attributes TEXT NULL,
|
||||||
|
tps_ip_latitude TEXT NULL,
|
||||||
|
tps_ip_longitude TEXT NULL,
|
||||||
|
account_telephone_first_seen TEXT NULL,
|
||||||
|
account_login_first_seen TEXT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_thx_application_key ON thx(application_key);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_thx_application_timestamp ON thx(application_timestamp);
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
18
config.json
18
config.json
@ -1,6 +1,14 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"namespace": "",
|
"namespace": "staging",
|
||||||
"connectionId": ""
|
"connectionId": "56be80f8-7139-466f-b883-e4a695812d52"
|
||||||
}
|
},
|
||||||
]
|
{
|
||||||
|
"namespace": "production",
|
||||||
|
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"namespace": "production-beta",
|
||||||
|
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
|
||||||
|
}
|
||||||
|
]
|
||||||
43
main.sql
43
main.sql
@ -1 +1,42 @@
|
|||||||
Select * from dummy_table limit 10;
|
INSERT INTO public.thx (
|
||||||
|
application_key,
|
||||||
|
application_timestamp,
|
||||||
|
digital_id_first_seen,
|
||||||
|
summary_risk_score,
|
||||||
|
cpu_clock,
|
||||||
|
true_ip_first_seen,
|
||||||
|
ssn_hash_first_seen,
|
||||||
|
account_email_attributes,
|
||||||
|
tps_ip_latitude,
|
||||||
|
tps_ip_longitude,
|
||||||
|
account_telephone_first_seen,
|
||||||
|
account_login_first_seen
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
$application_key,
|
||||||
|
$application_timestamp,
|
||||||
|
$digital_id_first_seen,
|
||||||
|
$summary_risk_score,
|
||||||
|
$cpu_clock,
|
||||||
|
$true_ip_first_seen,
|
||||||
|
$ssn_hash_first_seen,
|
||||||
|
$account_email_attributes,
|
||||||
|
$tps_ip_latitude,
|
||||||
|
$tps_ip_longitude,
|
||||||
|
$account_telephone_first_seen,
|
||||||
|
$account_login_first_seen
|
||||||
|
)
|
||||||
|
ON CONFLICT (application_key)
|
||||||
|
DO UPDATE
|
||||||
|
SET application_timestamp = EXCLUDED.application_timestamp,
|
||||||
|
digital_id_first_seen = EXCLUDED.digital_id_first_seen,
|
||||||
|
summary_risk_score = EXCLUDED.summary_risk_score,
|
||||||
|
cpu_clock = EXCLUDED.cpu_clock,
|
||||||
|
true_ip_first_seen = EXCLUDED.true_ip_first_seen,
|
||||||
|
ssn_hash_first_seen = EXCLUDED.ssn_hash_first_seen,
|
||||||
|
account_email_attributes = EXCLUDED.account_email_attributes,
|
||||||
|
tps_ip_latitude = EXCLUDED.tps_ip_latitude,
|
||||||
|
tps_ip_longitude = EXCLUDED.tps_ip_longitude,
|
||||||
|
account_telephone_first_seen = EXCLUDED.account_telephone_first_seen,
|
||||||
|
account_login_first_seen = EXCLUDED.account_login_first_seen;
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,48 @@
|
|||||||
{}
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"application_key": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"application_timestamp": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"digital_id_first_seen": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"summary_risk_score": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"cpu_clock": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"true_ip_first_seen": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"ssn_hash_first_seen": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"account_email_attributes": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"tps_ip_latitude": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"tps_ip_longitude": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"account_telephone_first_seen": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
},
|
||||||
|
"account_login_first_seen": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"application_key",
|
||||||
|
"application_timestamp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,20 @@
|
|||||||
{}
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"result": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": []
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user