Compare commits

..

1 Commits

Author SHA1 Message Date
Sundog 41a30d1855 updates models and schema doc, adds final purchase related tables 2023-11-01 09:34:33 -04:00
5 changed files with 57 additions and 53 deletions

View File

@ -1,44 +0,0 @@
name: checks
on:
pull_request:
paths: &CODE_PATHS
- 'src/**'
- 'Cargo*'
push:
paths: *CODE_PATHS
branches:
- main
jobs:
# TODO(cascode) cache checkout for build and test stages?
lint:
container:
# TODO use communitymedia docker registry
image: "cascode/aural-isle-ci:0"
steps:
- uses: actions/checkout@v3
with:
github-server-url: "https://code.communitymedia.network"
- name: rustfmt
run: cargo fmt --check
build:
container:
# TODO use communitymedia docker registry
image: "cascode/aural-isle-ci:2"
steps:
- uses: actions/checkout@v3
with:
github-server-url: "https://code.communitymedia.network"
- name: build
run: cargo build
# TODO(cascode) cache builds for test stage
test:
container:
# TODO use communitymedia docker registry
image: "cascode/aural-isle-ci:2"
steps:
- uses: actions/checkout@v3
with:
github-server-url: "https://code.communitymedia.network"
- name: run unit tests
run: cargo test

View File

@ -467,7 +467,7 @@ struct Purchase {
id: String,
items: Vec<LineItem>,
state: PurchaseState,
purchased_by: Person,
purchased_by: Option<Person>,
purchased_at: Option<chrono::DateTime>,
fulfilled_by: Option<Person>,
fulfilled_at: Option<chrono::DateTime>,

View File

@ -909,4 +909,58 @@ CREATE TABLE CouponCodeSkus (
CONSTRAINT CouponCodeSkus_FK FOREIGN KEY (coupon_code_id) REFERENCES CouponCodes(id),
CONSTRAINT CouponCodeSkus_FK_1 FOREIGN KEY (sku_id) REFERENCES Skus(id)
);
```
# Purchases
The Purchases table will contain Purchases!
``` sql
CREATE TABLE Purchases (
id TEXT(36),
state TEXT,
purchased_by TEXT(36),
purchased_at INTEGER,
fulfilled_by TEXT(36),
fulfilled_at INTEGER,
total_charge NUMERIC DEFAULT (0.00),
CONSTRAINT Purchases_PK PRIMARY KEY (id),
CONSTRAINT Purchases_FK FOREIGN KEY (purchased_by) REFERENCES Persons(id),
CONSTRAINT Purchases_FK_1 FOREIGN KEY (fulfilled_by) REFERENCES Persons(id)
);
CREATE INDEX Purchases_state_IDX ON Purchases (state);
CREATE INDEX Purchases_purchased_by_IDX ON Purchases (purchased_by);
CREATE INDEX Purchases_purchased_at_IDX ON Purchases (purchased_at);
CREATE INDEX Purchases_fulfilled_by_IDX ON Purchases (fulfilled_by);
CREATE INDEX Purchases_fulfilled_at_IDX ON Purchases (fulfilled_at);
CREATE INDEX Purchases_total_charge_IDX ON Purchases (total_charge);
```
# PurchaseLineItems
The PurchaseLineItems table will relate a Purchase to one or more LineItems.
``` sql
CREATE TABLE PurchaseLineItems (
purchase_id TEXT(36),
line_item_id TEXT(36),
CONSTRAINT PurchaseLineItems_PK PRIMARY KEY (purchase_id,line_item_id),
CONSTRAINT PurchaseLineItems_FK FOREIGN KEY (purchase_id) REFERENCES Purchases(id),
CONSTRAINT PurchaseLineItems_FK_1 FOREIGN KEY (line_item_id) REFERENCES LineItems(id) ON DELETE CASCADE
);
CREATE INDEX PurchaseLineItems_purchase_id_IDX ON PurchaseLineItems (purchase_id);
CREATE INDEX PurchaseLineItems_line_item_id_IDX ON PurchaseLineItems (line_item_id);
```
# PurchaseCouponCodes
The PurchaseCouponCodes table will relate a Purchase to one or more CouponCodes that were successfully applied to the Purchase.
``` sql
CREATE TABLE PurchaseCouponCodes (
purchase_id TEXT(36),
coupon_code_id TEXT(36),
CONSTRAINT PurchaseCouponCodes_PK PRIMARY KEY (purchase_id,coupon_code_id),
CONSTRAINT PurchaseCouponCodes_FK FOREIGN KEY (purchase_id) REFERENCES Purchases(id),
CONSTRAINT PurchaseCouponCodes_FK_1 FOREIGN KEY (coupon_code_id) REFERENCES CouponCodes(id)
);
CREATE INDEX PurchaseCouponCodes_purchase_id_IDX ON PurchaseCouponCodes (purchase_id);
CREATE INDEX PurchaseCouponCodes_coupon_code_id_IDX ON PurchaseCouponCodes (coupon_code_id);
```

View File

@ -1,7 +0,0 @@
FROM rust:1.73-alpine3.18
#install build tooling
RUN apk add musl-dev && rustup component add rustfmt
# install gitea act_runner dependencies
RUN apk add nodejs git

View File

@ -2,7 +2,8 @@ use warp::Filter;
#[tokio::main]
async fn main() {
let hello = warp::get().map(|| format!("Hello world!"));
let hello = warp::get()
.map(|| format!("Hello world!"));
warp::serve(hello).run(([127, 0, 0, 1], 5309)).await;
}