Compare commits

...

1 Commits

Author SHA1 Message Date
Ankur Malik
f664314b29 Add db_push_scores branch contents
All checks were successful
Build and Push Docker Image / setup (push) Successful in 5s
Build and Push Docker Image / build_and_push (push) Successful in 33s
2025-11-26 12:08:33 -05:00
6 changed files with 104 additions and 10 deletions

View File

@ -11,4 +11,5 @@ COPY . .
RUN ls ./
# 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"]

View File

@ -1 +1,21 @@
**Hello world!!!**
# Block for inserting/upserting scores into the scores table
This block is responsible for inserting or updating score records in the `scores` table using the same database configuration as `db_push_v1`.
## Table DDL
The following DDL illustrates the `scores` table structure (Postgres style, conceptually compatible with DuckDB for tests):
```sql
-- creating scores table
CREATE TABLE IF NOT EXISTS scores (
application_key TEXT PRIMARY KEY,
application_timestamp TIMESTAMP NOT NULL,
hd_score_m1 DOUBLE PRECISION NULL,
hd_score_m2 DOUBLE PRECISION NULL,
hd_score_iso_m2 DOUBLE PRECISION NULL
);
CREATE INDEX IF NOT EXISTS idx_scores_application_key ON scores(application_key);
CREATE INDEX IF NOT EXISTS idx_scores_application_timestamp ON scores(application_timestamp);
```

View File

@ -1,6 +1,14 @@
[
{
"namespace": "",
"connectionId": ""
}
]
{
"namespace": "staging",
"connectionId": "56be80f8-7139-466f-b883-e4a695812d52"
},
{
"namespace": "production",
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
},
{
"namespace": "production-beta",
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
}
]

View File

@ -1 +1,21 @@
Select * from dummy_table limit 10;
INSERT INTO public.scores (
application_key,
application_timestamp,
hd_score_m1,
hd_score_m2,
hd_score_iso_m2
)
VALUES (
$application_key,
$application_timestamp,
$hd_score_m1,
$hd_score_m2,
$hd_score_iso_m2
)
ON CONFLICT (application_key)
DO UPDATE
SET application_timestamp = EXCLUDED.application_timestamp,
hd_score_m1 = EXCLUDED.hd_score_m1,
hd_score_m2 = EXCLUDED.hd_score_m2,
hd_score_iso_m2 = EXCLUDED.hd_score_iso_m2;

View File

@ -1 +1,27 @@
{}
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"application_key": {
"type": "string"
},
"application_timestamp": {
"type": "string",
"format": "date-time"
},
"hd_score_m1": {
"type": ["number", "null"]
},
"hd_score_m2": {
"type": ["number", "null"]
},
"hd_score_iso_m2": {
"type": ["number", "null"]
}
},
"required": [
"application_key",
"application_timestamp"
]
}

View File

@ -1 +1,20 @@
{}
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"result": {
"type": [
"string",
"null"
]
},
"error": {
"type": [
"string",
"null"
]
}
},
"required": []
}