Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 90 additions & 1 deletion .github/workflows/dev-client-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,100 @@ concurrency:
cancel-in-progress: true

jobs:
cache_images:
name: cache base images
runs-on: ubuntu-latest
permissions:
packages: read
steps:
- name: login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: restore image cache
id: cache
uses: actions/cache@v4
with:
path: ~/image-cache
key: base-images-v1
- name: pull and retag images
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ~/image-cache
docker pull ghcr.io/systemaccounting/rust:latest
docker tag ghcr.io/systemaccounting/rust:latest public.ecr.aws/docker/library/rust:latest
docker pull ghcr.io/systemaccounting/lambda-provided:al2023
docker tag ghcr.io/systemaccounting/lambda-provided:al2023 public.ecr.aws/lambda/provided:al2023
docker pull ghcr.io/systemaccounting/postgresql:15
docker tag ghcr.io/systemaccounting/postgresql:15 public.ecr.aws/bitnami/postgresql:15
docker pull ghcr.io/systemaccounting/redis:latest
docker tag ghcr.io/systemaccounting/redis:latest public.ecr.aws/bitnami/redis:latest
docker pull ghcr.io/systemaccounting/alpine:latest
docker tag ghcr.io/systemaccounting/alpine:latest public.ecr.aws/docker/library/alpine:latest
docker pull ghcr.io/systemaccounting/node:lts-alpine
docker tag ghcr.io/systemaccounting/node:lts-alpine public.ecr.aws/docker/library/node:lts-alpine
docker save -o ~/image-cache/images.tar \
public.ecr.aws/docker/library/rust:latest \
public.ecr.aws/lambda/provided:al2023 \
public.ecr.aws/bitnami/postgresql:15 \
public.ecr.aws/bitnami/redis:latest \
public.ecr.aws/docker/library/alpine:latest \
public.ecr.aws/docker/library/node:lts-alpine
compile:
name: compile ${{ matrix.service }}
runs-on: ubuntu-latest
strategy:
matrix:
service:
- graphql
- request-create
- request-approve
- rule
- request-by-id
- requests-by-account
- transaction-by-id
- transactions-by-account
- balance-by-account
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.service }}
- name: compile
run: cargo build -p ${{ matrix.service }}
- name: upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.service }}
path: target/debug/${{ matrix.service }}
retention-days: 1
test:
name: test client
needs: [cache_images, compile]
runs-on: ubuntu-latest
env:
SKIP_CARGO_WATCH: true
steps:
- uses: actions/checkout@v4
- name: restore image cache
uses: actions/cache@v4
with:
path: ~/image-cache
key: base-images-v1
- name: load cached images
run: docker load -i ~/image-cache/images.tar
- name: download all binaries
uses: actions/download-artifact@v4
with:
path: target/debug/
merge-multiple: true
- name: set permissions
run: chmod +x target/debug/*
- name: start services
run: make start
# todo: unit tests
Expand Down Expand Up @@ -57,4 +146,4 @@ jobs:
- uses: actions/checkout@v4
- name: deploy to dev cloud environment
# deploy newly tagged image to dev cloud
run: bash scripts/deploy-last-image.sh --app-name $APP_DIR --env dev --env-id ${{ secrets.DEV_ENV_ID }}
run: bash scripts/deploy-last-image.sh --app-name $APP_DIR --env dev --env-id ${{ secrets.DEV_ENV_ID }}
2 changes: 1 addition & 1 deletion .github/workflows/local-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
needs: compile
runs-on: ubuntu-latest
env:
SERVICES_WORKFLOW: true
SKIP_CARGO_WATCH: true
steps:
- uses: actions/checkout@v4
- name: download all binaries
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
needs: [cache_images, compile]
runs-on: ubuntu-latest
env:
SERVICES_WORKFLOW: true
SKIP_CARGO_WATCH: true
steps:
- uses: actions/checkout@v4
- name: restore image cache
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
needs: [cache_images, compile]
runs-on: ubuntu-latest
env:
SERVICES_WORKFLOW: true
SKIP_CARGO_WATCH: true
steps:
- uses: actions/checkout@v4
- name: restore image cache
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,13 @@ client (typescript, svelte, cloudfront/s3: demo web client targeting graphql)
├── request-by-id (rust, lambda: returns a transaction request by id)
│ └── postgres
├── request-create (rust, lambda: creates a transaction request between a buyer and seller)
│ └── postgres
│ ├── rule
│ ├── postgres
│ └── cache (dynamodb/redis)
├── requests-by-account (rust, lambda: returns transaction requests by account)
│ └── postgres
├── rule (rust, lambda: returns transactions with user defined rules applied, e.g. taxes, dividends, etc.)
│ └── postgres
│ └── cache (dynamodb/redis)
├── transaction-by-id (rust, lambda: returns a transaction by id)
│ └── postgres
└── transactions-by-account (rust, lambda: returns transactions by account)
Expand Down
2 changes: 1 addition & 1 deletion client/src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ declare global {
item_id: string;
price: string;
quantity: string;
debitor_first: boolean;
rule_instance_id: string;
rule_exec_ids: string[];
unit_of_measurement: string;
Expand All @@ -40,6 +39,7 @@ declare global {
author_role: string;
equilibrium_time: string;
sum_value: string;
debitor_first?: boolean;
transaction_items: ITransactionItem[];
}

Expand Down
1 change: 0 additions & 1 deletion client/src/data/initial.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"item_id": null,
"price": null,
"quantity": null,
"debitor_first": false,
"rule_instance_id": null,
"unit_of_measurement": null,
"units_measured": null,
Expand Down
4 changes: 2 additions & 2 deletions client/src/graphql/mutation/createRequest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { gql } from "@urql/core";

const CREATE_REQUEST_MUTATION = gql`
mutation createRequest($transaction_items: [TransactionItemInput!], $auth_account: String!) {
createRequest(transaction_items: $transaction_items, auth_account: $auth_account) {
mutation createRequest($transaction: TransactionInput!, $auth_account: String!) {
createRequest(transaction: $transaction, auth_account: $auth_account) {
id
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/graphql/query/requestByID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const REQUEST_BY_ID_QUERY = gql`
author_device_latlng
author_role
sum_value
debitor_first
transaction_items {
id
transaction_id
item_id
price
quantity
debitor_first
rule_exec_ids
rule_instance_id
unit_of_measurement
Expand Down
2 changes: 1 addition & 1 deletion client/src/graphql/query/requestsByAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const REQUESTS_BY_ACCOUNT_QUERY = gql`
author_device_latlng
author_role
sum_value
debitor_first
transaction_items {
id
transaction_id
item_id
price
quantity
debitor_first
rule_instance_id
unit_of_measurement
units_measured
Expand Down
6 changes: 3 additions & 3 deletions client/src/graphql/query/rules.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { gql } from "@urql/core";

const RULES_QUERY = gql`
query getRules($transaction_items: [TransactionItemInput!]) {
rules(transaction_items: $transaction_items) {
query getRules($transaction: TransactionInput!) {
rules(transaction: $transaction) {
id
rule_instance_id
author
author_device_id
author_device_latlng
author_role
sum_value
debitor_first
transaction_items {
id
transaction_id
item_id
price
quantity
debitor_first
rule_instance_id
unit_of_measurement
units_measured
Expand Down
2 changes: 1 addition & 1 deletion client/src/graphql/query/transactionByID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const TRANSACTION_BY_ID_QUERY = gql`
author_device_latlng
author_role
sum_value
debitor_first
transaction_items {
id
transaction_id
item_id
price
quantity
debitor_first
rule_exec_ids
rule_instance_id
unit_of_measurement
Expand Down
2 changes: 1 addition & 1 deletion client/src/graphql/query/transactionsByAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const TRANSACTIONS_BY_ACCOUNT_QUERY = gql`
author_device_latlng
author_role
sum_value
debitor_first
equilibrium_time
transaction_items {
id
transaction_id
item_id
price
quantity
debitor_first
rule_instance_id
unit_of_measurement
units_measured
Expand Down
15 changes: 13 additions & 2 deletions client/src/routes/account/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@

async function getRuleItems(userAdded: App.ITransactionItem[]) {
previouslySubmitted = JSON.stringify(userAdded);
const res = await client.query(RULES_QUERY, { transaction_items: userAdded }).toPromise();
const transaction = {
author: account,
author_role: isCredit ? 'creditor' : 'debitor',
sum_value: sum(userAdded),
transaction_items: userAdded
};
const res = await client.query(RULES_QUERY, { transaction }).toPromise();
if (!res.data || !res.data.rules) {
addRuleItems([]);
} else {
Expand Down Expand Up @@ -135,7 +141,12 @@
client
.mutation(CREATE_REQUEST_MUTATION, {
auth_account: account,
transaction_items: reqItems
transaction: {
author: account,
author_role: isCredit ? 'creditor' : 'debitor',
sum_value: sumValue,
transaction_items: reqItems
}
})
.toPromise()
.then((result) => {
Expand Down
3 changes: 1 addition & 2 deletions crates/pg/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ impl ModelTrait for DatabaseConnection {
transaction_author_device_latlng, // author_device_latlng
transaction.author_role, // author_role
transaction_equilibrium_time, // equilibrium_time
transaction.debitor_first, // debitor_first
transaction_sum_value, // sum_value
transaction_created_at, // created_at
];
Expand All @@ -490,8 +491,6 @@ impl ModelTrait for DatabaseConnection {
let tr_item_quantity = parse_pg_numeric(Some(tr_item.quantity)).unwrap();
values.push_param(tr_item_quantity); // quantity

values.push_param(tr_item.debitor_first); // debitor_first

let tr_item_rule_instance_id = parse_pg_int4(tr_item.rule_instance_id).unwrap();
values.push_param(tr_item_rule_instance_id); // rule_instance_id

Expand Down
Loading