Basic sql and linting
This commit is contained in:
8
.pre-commit-config.yaml
Normal file
8
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/sqlfluff/sqlfluff
|
||||||
|
rev: 3.0.7 # Use the latest stable version
|
||||||
|
hooks:
|
||||||
|
- id: sqlfluff-lint
|
||||||
|
args: [--dialect, postgres]
|
||||||
|
# Only run on files in the db/ directory ending in .sql
|
||||||
|
files: ^collector/db/.*\.sql$
|
||||||
10
collector/db/Dockerfile
Normal file
10
collector/db/Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM postgres:16-alpine
|
||||||
|
|
||||||
|
# Test variables - do not use these in real builds >:(
|
||||||
|
ENV POSTGRES_DB=collector_db
|
||||||
|
ENV POSTGRES_USER=collector_user
|
||||||
|
ENV POSTGRES_PASSWORD=collector_dev_sample123
|
||||||
|
|
||||||
|
|
||||||
|
COPY init.sql /docker-entrypoint-initdb.d/
|
||||||
|
|
||||||
2
collector/db/init.sql
Normal file
2
collector/db/init.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
\i stores.sql;
|
||||||
|
\i products.sql;
|
||||||
23
collector/db/items.sql
Normal file
23
collector/db/items.sql
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
-- Modeling the products
|
||||||
|
CREATE TABLE products (
|
||||||
|
-- Internal product ID
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
|
||||||
|
-- Store-specific Identifiers
|
||||||
|
business_id UUID REFERENCES businesses (id) NOT NULL,
|
||||||
|
|
||||||
|
-- Product Details
|
||||||
|
product_name VARCHAR(255) NOT NULL,
|
||||||
|
product_type VARCHAR(100), -- e.g., 'service', 'goods'
|
||||||
|
|
||||||
|
-- Pricing (Numeric is preferred over Float for money)
|
||||||
|
-- Also tracking in USD at the time
|
||||||
|
price NUMERIC(12, 2) NOT NULL,
|
||||||
|
currency VARCHAR(100) NOT NULL,
|
||||||
|
|
||||||
|
-- Also tracking the price per unit
|
||||||
|
unit_type VARCHAR(100) NOT NULL, -- e.g. 'item', 'weight', 'hour', etc.
|
||||||
|
|
||||||
|
-- Tracking time that we checked
|
||||||
|
track_time TIMESTAMPTZ DEFAULT current_timestamp
|
||||||
|
);
|
||||||
6
collector/db/lint.sh
Normal file
6
collector/db/lint.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
sqlfluff lint --dialect postgres *.sql
|
||||||
5
collector/db/readme.md
Normal file
5
collector/db/readme.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Collecter DB
|
||||||
|
|
||||||
|
|
||||||
|
Here we are setting up the schemas for housing all the data
|
||||||
|
regarding the stuff we track.
|
||||||
6
collector/db/stores.sql
Normal file
6
collector/db/stores.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-- Modeling the stores that we track overall
|
||||||
|
|
||||||
|
CREATE TABLE businesses (
|
||||||
|
store_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
store_name VARCHAR(255) NOT NULL
|
||||||
|
);
|
||||||
16
readme.md
Normal file
16
readme.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Cash Tracker
|
||||||
|
|
||||||
|
|
||||||
|
This project is a special personal graphing service thing that I personally use
|
||||||
|
to scrape and track the prices of real things that people actually buy in stores
|
||||||
|
and around town.
|
||||||
|
|
||||||
|
# Why?
|
||||||
|
|
||||||
|
There are tons of tools to track the prices of securities, commodities, bonds,
|
||||||
|
options, stocks, futures, assets, and tons of other finnancial products/services
|
||||||
|
but for the layperson this is all greek. This project aims to track things that
|
||||||
|
they would see in a store so they could say "huh `some food` at
|
||||||
|
`my favorite grocery store` went up/down by `some_amount` in the last `time interval`.
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user