Compare commits

...

6 Commits

Author SHA1 Message Date
cascode b98fd1352a add rustfmt
checks / format (push) Failing after 2s Details
checks / format (pull_request) Failing after 2s Details
2023-10-21 01:39:23 -07:00
cascode a27214c8da Revert "test"
This reverts commit 81158ca818.
2023-10-21 01:39:23 -07:00
cascode b53c875eac test 2023-10-21 01:39:23 -07:00
cascode 0e92eda123 add automated format check 2023-10-21 01:39:23 -07:00
Sundog abe545397b more model refinement 2023-10-20 09:37:57 -04:00
Sundog cb3f76aa17 refines MODELS around cart functionality, moves all pricing into Sku model, adds CouponCode model 2023-10-20 09:32:52 -04:00
2 changed files with 65 additions and 35 deletions

View File

@ -0,0 +1,16 @@
name: checks
on:
- push
- pull_request
jobs:
lint:
runs_on: "alpine_amd64"
container:
image: "rust:1.73-alpine3.18"
name: format
steps:
- name: TODO put in image base
run: rustup component add rustfmt
- name: rustfmt
run: cargo fmt --check

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>,
@ -405,7 +393,6 @@ struct Collection {
albums: Option<Vec<Album>>,
tracks: Option<Vec<Track>>,
other_products: Option<Vec<OtherProduct>>,
price: Option<rusty_money::Money>,
}
```
@ -429,7 +416,7 @@ struct OtherProduct {
is_available: bool,
deleted_by: Option<PersonId>,
deleted_at: Option<chrono::DateTime>,
price: Option<rusty_money::Money>
requires_shipping: bool,
}
```
@ -439,10 +426,10 @@ A Purchase represents one or more Tracks or Albums that a Person purchases from
``` rust
enum PurchaseItemType {
Album,
Track,
Collection,
OtherProduct,
Album(AlbumId),
Track(TrackId),
Collection(CollectionId),
OtherProduct(OtherProductId),
}
struct PurchaseItemId {
id: String,
@ -452,18 +439,15 @@ 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: Option<rusty_money::Money>,
requires_shipping: bool,
}
struct PurchaseItem {
id: PurchaseItemId,
type: PurchaseItemType,
sku: Option<SkuId>,
sku: SkuId,
quantity: usize,
}
enum PurchaseState {
@ -481,5 +465,35 @@ struct Purchase {
state: PurchaseState,
purchased_by: Person,
purchased_at: Option<chrono::DateTime>,
fulfilled_by: Option<Person>,
fulfilled_at: Option<chrono::DateTime>,
}
```
# 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>,
}
```