34 Commits

Author SHA1 Message Date
d85d6285d2 Revert "var for images"
This reverts commit 0c3ecb27302a5f29d072c382dc75bd633b44f155.
2023-10-26 17:34:07 -07:00
3e80545d6b var for images 2023-10-26 17:34:07 -07:00
b511e5a81a more concise 2023-10-26 17:34:07 -07:00
8b5b5b539b Revert "more concise"
This reverts commit a0e6005acd55bf86a73ef180c425a67e7a040bef.
2023-10-26 17:34:07 -07:00
f5b7db930d more concise 2023-10-26 17:34:07 -07:00
8e0984e7b1 re-merge file 2023-10-26 17:34:07 -07:00
4957b36355 only run on some path changes 2023-10-26 17:34:07 -07:00
614d7b8a20 remove runner tag 2023-10-26 17:34:07 -07:00
c5f723210b try removing runner tag 2023-10-26 17:34:07 -07:00
691afc382d change triggers 2023-10-26 17:34:07 -07:00
cd4333cacd change triggers 2023-10-26 17:34:07 -07:00
de9d8dde88 reorder triggers 2023-10-26 17:34:07 -07:00
55ec00d1fb only run for push on main, or for pr 2023-10-26 17:34:07 -07:00
05b6ffc807 image changes 2023-10-26 17:34:07 -07:00
7360bba00e add build deps to ci docker image 2023-10-26 17:34:07 -07:00
8c46018fee image changes 2023-10-26 17:34:07 -07:00
dc01798dfa names and images changes 2023-10-26 17:34:07 -07:00
2aad6e49cd automated build and test 2023-10-26 17:34:07 -07:00
b7c37613ce move some steps into the base image 2023-10-26 17:34:07 -07:00
d8b6e31836 fix fmt 2023-10-26 17:34:07 -07:00
0babf35c1e test 2023-10-26 17:34:07 -07:00
57313ddf7c test 2023-10-26 17:34:07 -07:00
5ae1314bb7 add node 2023-10-26 17:34:07 -07:00
0cd0e54b66 add checkout 2023-10-26 17:34:07 -07:00
54db9795fe add debug ls 2023-10-26 17:34:07 -07:00
e27d224d3d add debug ls 2023-10-26 17:34:07 -07:00
3b14b93d17 add rustfmt 2023-10-26 17:34:07 -07:00
1c719b3061 Revert "test"
This reverts commit 81158ca8187e1a21615e216a9e8bf0468441ff72.
2023-10-26 17:34:07 -07:00
cab056ea69 test 2023-10-26 17:34:07 -07:00
1fbe2d6911 add automated format check 2023-10-26 17:34:07 -07:00
c5ebcc8204 adds more store-focused data structures 2023-10-25 12:41:54 -04:00
4bba521103 adds OtherProducts and Collections data structures 2023-10-25 12:00:09 -04:00
abe545397b more model refinement 2023-10-20 09:37:57 -04:00
cb3f76aa17 refines MODELS around cart functionality, moves all pricing into Sku model, adds CouponCode model 2023-10-20 09:32:52 -04:00
5 changed files with 309 additions and 57 deletions

View File

@ -0,0 +1,44 @@
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

106
MODELS.md
View File

@ -185,7 +185,6 @@ struct Track {
is_available: bool,
preview_source: Option<String>,
source: String,
price: Option<rusty_money::Money>,
created_by: PersonId,
created_at: chrono::DateTime,
modified_by: PersonId,
@ -218,7 +217,6 @@ struct Album {
is_available: bool,
preview_source: Option<String>,
source: String,
price: Option<rusty_money::Money>,
created_by: PersonId,
created_at: chrono::DateTime,
modified_by: PersonId,
@ -289,23 +287,14 @@ struct Article {
A Comment represents a textual comment that a Person wants to attach contextually to an Artist, an Album, a Track, or a Playlist.
``` rust
enum CommentTargetType {
Label,
Artist,
Album,
Track,
Playlist,
Article,
Comment,
}
struct CommentTargetId {
label_id: Option<LabelId>,
artist_id: Option<ArtistId>,
album_id: Option<AlbumId>,
track_id: Option<TrackId>,
playlist_id: Option<PlaylistId>,
article_id: Option<ArticleId>,
comment_id: Option<CommentId>,
enum CommentTarget {
Label(LabelId),
Artist(ArtistId),
Album(AlbumId),
Track(TrackId),
Playlist(PlaylistId),
Article(ArticleId),
Comment(CommentId),
}
struct CommentId {
id: String,
@ -313,8 +302,7 @@ struct CommentId {
struct Comment {
id: CommentId,
body: String,
target_type: CommentTargetType,
target_id: CommentTargetId,
target: CommentTarget,
created_by: PersonId,
created_at: chrono::DateTime,
modified_by: Option<PersonId>,
@ -384,9 +372,14 @@ struct Video {
# Collection
A Collection represents one or more Albums and/or Tracks that are offered together as a package for Purchase
A Collection represents one or more Albums, Tracks, and/or OtherProducts that are offered together as a package for Purchase
``` rust
enum CollectionItem {
Album(AlbumId),
Track(TrackId),
OtherProduct(OtherProductId),
}
struct CollectionId {
id: String,
}
@ -402,10 +395,7 @@ struct Collection {
is_available: bool,
deleted_by: Option<PersonId>,
deleted_at: Option<chrono::DateTime>,
albums: Option<Vec<Album>>,
tracks: Option<Vec<Track>>,
other_products: Option<Vec<OtherProduct>>,
price: Option<rusty_money::Money>,
collection_items: Option<Vec<CollectionMember>>,
}
```
@ -429,20 +419,20 @@ struct OtherProduct {
is_available: bool,
deleted_by: Option<PersonId>,
deleted_at: Option<chrono::DateTime>,
price: Option<rusty_money::Money>
requires_shipping: bool,
}
```
# Purchase
A Purchase represents one or more Tracks or Albums that a Person purchases from an Artist or Label through the server.
A Purchase represents one or more Tracks, Albums, Collections, and/or OtherProducts that a Person purchases from an Artist or Label through the server.
``` rust
enum PurchaseItemType {
Album,
Track,
Collection,
OtherProduct,
Album(AlbumId),
Track(TrackId),
Collection(CollectionId),
OtherProduct(OtherProductId),
}
struct PurchaseItemId {
id: String,
@ -452,18 +442,16 @@ struct SkuId {
}
struct Sku {
id: SkuId,
album_id: Option<AlbumId>,
track_id: Option<TrackId>,
collection_id: Option<CollectionId>,
other_product_id: Option<OtherProductId>,
item: PurchaseItemType,
variant: Option<String>,
discount_percentage: Option<f64>,
discount_flatrate: Option<rusty_money::Money>,
description: Option<String>,
price: rusty_money::Money,
requires_shipping: bool,
shipping_charge: Option<rusty_money::Money>,
}
struct PurchaseItem {
id: PurchaseItemId,
type: PurchaseItemType,
sku: Option<SkuId>,
struct LineItem {
id: LineItemId,
sku: SkuId,
quantity: usize,
}
enum PurchaseState {
@ -477,9 +465,41 @@ enum PurchaseState {
}
struct Purchase {
id: String,
items: Vec<PurchaseItem>,
items: Vec<LineItem>,
state: PurchaseState,
purchased_by: Person,
purchased_at: Option<chrono::DateTime>,
fulfilled_by: Option<Person>,
fulfilled_at: Option<chrono::DateTime>,
coupons_applied: Option<Vec<CouponCodeId>>,
total_charge: rusty_money::Money,
}
```
# CouponCode
A CouponCode represents a code a Person can enter to receive a discount on a PurchateItem or on a Purchase.
``` rust
struct CouponCodeId {
id: String,
}
struct CouponCode {
id: CouponCodeId,
name: String,
code: String,
uses: usize,
max_uses: usize,
expiration: Option<chrono::DateTime>,
discount_flat: Option<rusty_money::Money>,
discount_percentage: Option<f32>,
skus: Option<Vec<SkuId>>,
is_active: bool,
created_by: PersonId,
created_at: chrono::DateTime,
modified_by: PersonId,
modified_at: chrono::DateTime,
deleted_by: Option<PersonId>,
deleted_at: Option<chrono::DateTime>,
}
```

206
SCHEMA.md
View File

@ -705,26 +705,208 @@ CREATE INDEX ArticleComments_article_id_IDX ON ArticleComments (article_id);
CREATE INDEX ArticleComments_comment_id_IDX ON ArticleComments (comment_id);
```
# LabelImages
# OtherProducts
The OtherProducts table will contain products for sale that are not Albums nor Tracks nor Collections.
# LabelVideos
``` sql
CREATE TABLE OtherProducts (
id TEXT(36),
name TEXT,
description TEXT,
created_by TEXT(36),
created_at INTEGER,
modified_by TEXT(36),
modified_at INTEGER,
deleted_by TEXT(36),
deleted_at INTEGER,
is_public INTEGER DEFAULT (0),
is_available INTEGER DEFAULT (0),
requires_shipping INTEGER DEFAULT (0),
CONSTRAINT OtherProducts_PK PRIMARY KEY (id),
CONSTRAINT OtherProducts_FK FOREIGN KEY (created_by) REFERENCES Persons(id),
CONSTRAINT OtherProducts_FK_1 FOREIGN KEY (modified_by) REFERENCES Persons(id),
CONSTRAINT OtherProducts_FK_2 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
);
CREATE INDEX OtherProducts_name_IDX ON OtherProducts (name);
CREATE INDEX OtherProducts_description_IDX ON OtherProducts (description);
CREATE INDEX OtherProducts_created_by_IDX ON OtherProducts (created_by);
CREATE INDEX OtherProducts_created_at_IDX ON OtherProducts (created_at);
CREATE INDEX OtherProducts_modified_by_IDX ON OtherProducts (modified_by);
CREATE INDEX OtherProducts_modified_at_IDX ON OtherProducts (modified_at);
CREATE INDEX OtherProducts_deleted_by_IDX ON OtherProducts (deleted_by);
CREATE INDEX OtherProducts_deleted_at_IDX ON OtherProducts (deleted_at);
CREATE INDEX OtherProducts_is_public_IDX ON OtherProducts (is_public);
CREATE INDEX OtherProducts_is_available_IDX ON OtherProducts (is_available);
CREATE INDEX OtherProducts_requires_shipping_IDX ON OtherProducts (requires_shipping);
```
# ArtistImages
# Collections
The Collections table will contain Collections where each Collection is comprised of one or more Tracks, Albums, and/or OtherProducts packaged together for sale.
# ArtistVideos
``` sql
CREATE TABLE Collections (
id TEXT(36),
name TEXT,
description TEXT,
created_by TEXT(36),
created_at INTEGER,
modified_by TEXT(36),
modified_at INTEGER,
deleted_by TEXT(36),
deleted_at INTEGER,
is_public INTEGER DEFAULT (0),
is_available INTEGER DEFAULT (0),
CONSTRAINT Collections_PK PRIMARY KEY (id),
CONSTRAINT Collections_FK FOREIGN KEY (created_by) REFERENCES Persons(id),
CONSTRAINT Collections_FK_1 FOREIGN KEY (modified_by) REFERENCES Persons(id),
CONSTRAINT Collections_FK_2 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
);
CREATE INDEX Collections_name_IDX ON Collections (name);
CREATE INDEX Collections_description_IDX ON Collections (description);
CREATE INDEX Collections_created_by_IDX ON Collections (created_by);
CREATE INDEX Collections_created_at_IDX ON Collections (created_at);
CREATE INDEX Collections_modified_by_IDX ON Collections (modified_by);
CREATE INDEX Collections_modified_at_IDX ON Collections (modified_at);
CREATE INDEX Collections_deleted_by_IDX ON Collections (deleted_by);
CREATE INDEX Collections_deleted_at_IDX ON Collections (deleted_at);
CREATE INDEX Collections_is_public_IDX ON Collections (is_public);
CREATE INDEX Collections_is_available_IDX ON Collections (is_available);
```
# AlbumImages
# CollectionAlbums
The CollectionAlbums table will relate a Collection to the Album(s) it contains.
# AlbumVideos
``` sql
CREATE TABLE CollectionAlbums (
collection_id TEXT(36),
album_id TEXT(36),
CONSTRAINT CollectionAlbums_PK PRIMARY KEY (collection_id,album_id),
CONSTRAINT CollectionAlbums_FK FOREIGN KEY (collection_id) REFERENCES Collections(id) ON DELETE CASCADE,
CONSTRAINT CollectionAlbums_FK_1 FOREIGN KEY (album_id) REFERENCES Albums(id) ON DELETE CASCADE
);
CREATE INDEX CollectionAlbums_collection_id_IDX ON CollectionAlbums (collection_id);
CREATE INDEX CollectionAlbums_album_id_IDX ON CollectionAlbums (album_id);
```
# TrackImages
# CollectionTracks
The CollectionTracks table will relate a Collection to the Track(s) it contains.
# TrackVideos
``` sql
CREATE TABLE CollectionTracks (
collection_id TEXT(36),
track_id TEXT(36),
CONSTRAINT CollectionTracks_PK PRIMARY KEY (collection_id,track_id),
CONSTRAINT CollectionTracks_FK FOREIGN KEY (collection_id) REFERENCES Collections(id) ON DELETE CASCADE,
CONSTRAINT CollectionTracks_FK_1 FOREIGN KEY (track_id) REFERENCES Tracks(id) ON DELETE CASCADE
);
CREATE INDEX CollectionTracks_collection_id_IDX ON CollectionTracks (collection_id);
CREATE INDEX CollectionTracks_track_id_IDX ON CollectionTracks (track_id);
```
# PlaylistImages
# CollectionOtherProducts
The CollectionOtherProducts table will relate a Collection to the OtherProduct(s) it contains.
# PlaylistVideos
``` sql
CREATE TABLE CollectionOtherProducts (
collection_id TEXT(36),
other_product_id TEXT(36),
CONSTRAINT CollectionOtherProducts_PK PRIMARY KEY (collection_id,other_product_id),
CONSTRAINT CollectionOtherProducts_FK FOREIGN KEY (collection_id) REFERENCES Collections(id) ON DELETE CASCADE,
CONSTRAINT CollectionOtherProducts_FK_1 FOREIGN KEY (other_product_id) REFERENCES OtherProducts(id) ON DELETE CASCADE
);
CREATE INDEX CollectionOtherProducts_collection_id_IDX ON CollectionOtherProducts (collection_id);
CREATE INDEX CollectionOtherProducts_other_product_id_IDX ON CollectionOtherProducts (other_product_id);
```
# ArticleImages
# Skus
The Skus table will contain SKUs () representing items available for Purchase through the server.
# ArticleVideos
``` sql
CREATE TABLE Skus (
id TEXT(36),
item_type TEXT,
item_id TEXT(36),
variant TEXT,
description TEXT,
price NUMERIC DEFAULT (0.00),
requires_shipping INTEGER DEFAULT (0),
shipping_charge NUMERIC DEFAULT (0.00),
CONSTRAINT Skus_PK PRIMARY KEY (id)
);
CREATE INDEX Skus_item_type_IDX ON Skus (item_type);
CREATE INDEX Skus_item_id_IDX ON Skus (item_id);
CREATE INDEX Skus_variant_IDX ON Skus (variant);
CREATE INDEX Skus_description_IDX ON Skus (description);
CREATE INDEX Skus_price_IDX ON Skus (price);
CREATE INDEX Skus_requires_shipping_IDX ON Skus (requires_shipping);
CREATE INDEX Skus_shipping_charge_IDX ON Skus (shipping_charge);
```
# LineItems
The LineItems table will contain individual SKUs and their associated quantites as part of a Purchase.
``` sql
CREATE TABLE LineItems (
id TEXT(36),
sku_id TEXT(36),
quantity INTEGER DEFAULT (1),
CONSTRAINT LineItems_PK PRIMARY KEY (id),
CONSTRAINT LineItems_FK FOREIGN KEY (sku_id) REFERENCES Skus(id)
);
CREATE INDEX LineItems_sku_id_IDX ON LineItems (sku_id);
CREATE INDEX LineItems_quantity_IDX ON LineItems (quantity);
```
# CouponCodes
The CouponCodes table will contain coupon codes that can be redeemed for a discount, either by amount or percentage, on a Purchase.
``` sql
CREATE TABLE CouponCodes (
id TEXT(36),
name TEXT,
code TEXT,
uses INTEGER DEFAULT (0),
max_uses INTEGER DEFAULT (0),
expiration INTEGER,
discount_flat NUMERIC DEFAULT (0.00),
discount_percentage NUMERIC DEFAULT (0.00),
is_sku_specific INTEGER DEFAULT (0),
is_active INTEGER DEFAULT (0),
created_by TEXT(36),
created_at INTEGER,
modified_by TEXT(36),
modified_at INTEGER,
deleted_by TEXT(36),
deleted_at INTEGER,
CONSTRAINT CouponCodes_PK PRIMARY KEY (id),
CONSTRAINT CouponCodes_FK FOREIGN KEY (created_by) REFERENCES Persons(id),
CONSTRAINT CouponCodes_FK_1 FOREIGN KEY (modified_by) REFERENCES Persons(id),
CONSTRAINT CouponCodes_FK_2 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
);
CREATE INDEX CouponCodes_name_IDX ON CouponCodes (name);
CREATE UNIQUE INDEX CouponCodes_code_IDX ON CouponCodes (code);
CREATE INDEX CouponCodes_uses_IDX ON CouponCodes (uses);
CREATE INDEX CouponCodes_max_uses_IDX ON CouponCodes (max_uses);
CREATE INDEX CouponCodes_expiration_IDX ON CouponCodes (expiration);
CREATE INDEX CouponCodes_is_sku_specific_IDX ON CouponCodes (is_sku_specific);
CREATE INDEX CouponCodes_is_active_IDX ON CouponCodes (is_active);
CREATE INDEX CouponCodes_created_by_IDX ON CouponCodes (created_by);
CREATE INDEX CouponCodes_created_at_IDX ON CouponCodes (created_at);
CREATE INDEX CouponCodes_modified_by_IDX ON CouponCodes (modified_by);
CREATE INDEX CouponCodes_modified_at_IDX ON CouponCodes (modified_at);
CREATE INDEX CouponCodes_deleted_by_IDX ON CouponCodes (deleted_by);
CREATE INDEX CouponCodes_deleted_at_IDX ON CouponCodes (deleted_at);
```
# CouponCodeSkus
The CouponCodeSkus table will relate a CouponCode to one or more Skus the CouponCode can be applied to, if CouponCode.is_sku_specific is true. (If CouponCode.is_sku_specific is false the CouponCode can be applied to an entire Purchase regardless of the Skus being purchased.)
``` sql
CREATE TABLE CouponCodeSkus (
coupon_code_id TEXT(36),
sku_id TEXT(36),
CONSTRAINT CouponCodeSkus_PK PRIMARY KEY (coupon_code_id,sku_id),
CONSTRAINT CouponCodeSkus_FK FOREIGN KEY (coupon_code_id) REFERENCES CouponCodes(id),
CONSTRAINT CouponCodeSkus_FK_1 FOREIGN KEY (sku_id) REFERENCES Skus(id)
);
```

7
ci/Dockerfile Normal file
View File

@ -0,0 +1,7 @@
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,8 +2,7 @@ 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;
}