Compare commits
4 Commits
docs-forma
...
ab9aed00ab
Author | SHA1 | Date | |
---|---|---|---|
ab9aed00ab | |||
e410731e99 | |||
81158ca818 | |||
4be42a6cbe |
16
.gitea/workflows/checks.yml
Normal file
16
.gitea/workflows/checks.yml
Normal 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
|
@ -1,30 +0,0 @@
|
|||||||
# Contribution Guidelines
|
|
||||||
|
|
||||||
## Code Formatting
|
|
||||||
|
|
||||||
We format all Rust code using edition 2021 rules. This edition is defined in our Cargo.toml and most methods below will pick this up automatically.
|
|
||||||
|
|
||||||
### Manual Method
|
|
||||||
|
|
||||||
The most editor agnostic way to format your Rust code is by manually running cargo's fmt sub command.
|
|
||||||
|
|
||||||
To check if your code is formatted without making changes, run `cargo fmt --check`. Then if you want to format your code you can run just `cargo fmt`.
|
|
||||||
|
|
||||||
### VScode
|
|
||||||
|
|
||||||
We recommend the meta extension [Rust Bundle](https://marketplace.visualstudio.com/items?itemName=1YiB.rust-bundle) , which includes rust-analyzer. ([More info](https://code.visualstudio.com/docs/languages/rust) on Rust with VScode) Then to set your editor to format on save:
|
|
||||||
|
|
||||||
* In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option.
|
|
||||||
* Search for format on save setting and check the checkbox.
|
|
||||||
|
|
||||||
You can also set language specific settings as outlined [here](https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings). You will again want to then search for format on save and check the checkbox.
|
|
||||||
|
|
||||||
### Other Editors
|
|
||||||
|
|
||||||
You will first need to [install rust-analyzer](https://rust-analyzer.github.io/manual.html#installation), then configure your editor and install any needed plugins or extensions as outlined on that page.
|
|
||||||
|
|
||||||
### Pre Commit Hook
|
|
||||||
|
|
||||||
If you want to think about formatting your code less and just have git yell at you whe you try to commit code that is not properly formatted, you can use a simple pre-commit hook.
|
|
||||||
|
|
||||||
After cloning the repo, move the file `pre-commit` to `.git/hooks/pre-commit`. That's it.
|
|
84
MODELS.md
84
MODELS.md
@ -185,6 +185,7 @@ struct Track {
|
|||||||
is_available: bool,
|
is_available: bool,
|
||||||
preview_source: Option<String>,
|
preview_source: Option<String>,
|
||||||
source: String,
|
source: String,
|
||||||
|
price: Option<rusty_money::Money>,
|
||||||
created_by: PersonId,
|
created_by: PersonId,
|
||||||
created_at: chrono::DateTime,
|
created_at: chrono::DateTime,
|
||||||
modified_by: PersonId,
|
modified_by: PersonId,
|
||||||
@ -217,6 +218,7 @@ struct Album {
|
|||||||
is_available: bool,
|
is_available: bool,
|
||||||
preview_source: Option<String>,
|
preview_source: Option<String>,
|
||||||
source: String,
|
source: String,
|
||||||
|
price: Option<rusty_money::Money>,
|
||||||
created_by: PersonId,
|
created_by: PersonId,
|
||||||
created_at: chrono::DateTime,
|
created_at: chrono::DateTime,
|
||||||
modified_by: PersonId,
|
modified_by: PersonId,
|
||||||
@ -287,14 +289,23 @@ 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.
|
A Comment represents a textual comment that a Person wants to attach contextually to an Artist, an Album, a Track, or a Playlist.
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
enum CommentTarget {
|
enum CommentTargetType {
|
||||||
Label(LabelId),
|
Label,
|
||||||
Artist(ArtistId),
|
Artist,
|
||||||
Album(AlbumId),
|
Album,
|
||||||
Track(TrackId),
|
Track,
|
||||||
Playlist(PlaylistId),
|
Playlist,
|
||||||
Article(ArticleId),
|
Article,
|
||||||
Comment(CommentId),
|
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>,
|
||||||
}
|
}
|
||||||
struct CommentId {
|
struct CommentId {
|
||||||
id: String,
|
id: String,
|
||||||
@ -302,7 +313,8 @@ struct CommentId {
|
|||||||
struct Comment {
|
struct Comment {
|
||||||
id: CommentId,
|
id: CommentId,
|
||||||
body: String,
|
body: String,
|
||||||
target: CommentTarget,
|
target_type: CommentTargetType,
|
||||||
|
target_id: CommentTargetId,
|
||||||
created_by: PersonId,
|
created_by: PersonId,
|
||||||
created_at: chrono::DateTime,
|
created_at: chrono::DateTime,
|
||||||
modified_by: Option<PersonId>,
|
modified_by: Option<PersonId>,
|
||||||
@ -393,6 +405,7 @@ struct Collection {
|
|||||||
albums: Option<Vec<Album>>,
|
albums: Option<Vec<Album>>,
|
||||||
tracks: Option<Vec<Track>>,
|
tracks: Option<Vec<Track>>,
|
||||||
other_products: Option<Vec<OtherProduct>>,
|
other_products: Option<Vec<OtherProduct>>,
|
||||||
|
price: Option<rusty_money::Money>,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -416,7 +429,7 @@ struct OtherProduct {
|
|||||||
is_available: bool,
|
is_available: bool,
|
||||||
deleted_by: Option<PersonId>,
|
deleted_by: Option<PersonId>,
|
||||||
deleted_at: Option<chrono::DateTime>,
|
deleted_at: Option<chrono::DateTime>,
|
||||||
requires_shipping: bool,
|
price: Option<rusty_money::Money>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -426,10 +439,10 @@ A Purchase represents one or more Tracks or Albums that a Person purchases from
|
|||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
enum PurchaseItemType {
|
enum PurchaseItemType {
|
||||||
Album(AlbumId),
|
Album,
|
||||||
Track(TrackId),
|
Track,
|
||||||
Collection(CollectionId),
|
Collection,
|
||||||
OtherProduct(OtherProductId),
|
OtherProduct,
|
||||||
}
|
}
|
||||||
struct PurchaseItemId {
|
struct PurchaseItemId {
|
||||||
id: String,
|
id: String,
|
||||||
@ -439,15 +452,18 @@ struct SkuId {
|
|||||||
}
|
}
|
||||||
struct Sku {
|
struct Sku {
|
||||||
id: SkuId,
|
id: SkuId,
|
||||||
item: PurchaseItemType,
|
album_id: Option<AlbumId>,
|
||||||
|
track_id: Option<TrackId>,
|
||||||
|
collection_id: Option<CollectionId>,
|
||||||
|
other_product_id: Option<OtherProductId>,
|
||||||
variant: Option<String>,
|
variant: Option<String>,
|
||||||
description: Option<String>,
|
discount_percentage: Option<f64>,
|
||||||
price: Option<rusty_money::Money>,
|
discount_flatrate: Option<rusty_money::Money>,
|
||||||
requires_shipping: bool,
|
|
||||||
}
|
}
|
||||||
struct PurchaseItem {
|
struct PurchaseItem {
|
||||||
id: PurchaseItemId,
|
id: PurchaseItemId,
|
||||||
sku: SkuId,
|
type: PurchaseItemType,
|
||||||
|
sku: Option<SkuId>,
|
||||||
quantity: usize,
|
quantity: usize,
|
||||||
}
|
}
|
||||||
enum PurchaseState {
|
enum PurchaseState {
|
||||||
@ -465,35 +481,5 @@ struct Purchase {
|
|||||||
state: PurchaseState,
|
state: PurchaseState,
|
||||||
purchased_by: Person,
|
purchased_by: Person,
|
||||||
purchased_at: Option<chrono::DateTime>,
|
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>,
|
|
||||||
}
|
|
||||||
```
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cargo fmt --check
|
|
Reference in New Issue
Block a user