Skip to content

Commit

Permalink
Feat: Add analytics transfer (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen authored Jun 7, 2023
2 parents 909604a + 9b1781a commit 5071d07
Show file tree
Hide file tree
Showing 46 changed files with 313 additions and 212 deletions.
87 changes: 22 additions & 65 deletions .github/workflows/cargo-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,36 @@ env:

jobs:

skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
# skip_check:
# runs-on: ubuntu-latest
# outputs:
# should_skip: ${{ steps.skip_check.outputs.should_skip }}
# steps:
# - id: skip_check
# uses: fkirc/skip-duplicate-actions@v5

backend-build:
needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'

runs-on: ubuntu-latest
# needs: skip_check
# if: needs.skip_check.outputs.should_skip != 'true'

runs-on: self-hosted-build

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
# - uses: actions/cache@v3
# with:
# path: ./target
# key: ${{ runner.os }}-cargo-build-release-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', './rs') }}
# restore-keys: |
# ${{ runner.os }}-cargo-build-release-

- name: Local cargo cache
id: build-cargo-cache
uses: MasterworksIO/[email protected]
with:
path: ./target
key: ${{ runner.os }}-cargo-build-release-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', './rs') }}
restore-keys: |
${{ runner.os }}-cargo-build-release-
# - uses: Swatinem/rust-cache@v2
# with:
# cache-all-crates: true

# with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
# prefix-key: ""

# A cache key that is used instead of the automatic `job`-based key,
# and is stable over multiple jobs.
# default: empty
# shared-key: ""

# An additional cache key that is added alongside the automatic `job`-based
# cache key and can be used to further differentiate jobs.
# default: empty
# key: ""

# A whitespace separated list of env-var *prefixes* who's value contributes
# to the environment cache key.
# The env-vars are matched by *prefix*, so the default `RUST` var will
# match all of `RUSTC`, `RUSTUP_*`, `RUSTFLAGS`, `RUSTDOC_*`, etc.
# default: "CARGO CC CFLAGS CXX CMAKE RUST"
# env-vars: ""

# The cargo workspaces and target directory configuration.
# These entries are separated by newlines and have the form
# `$workspace -> $target`. The `$target` part is treated as a directory
# relative to the `$workspace` and defaults to "target" if not explicitly given.
# default: ". -> target"
# workspaces: ""

# Additional non workspace directories to be cached, separated by newlines.
# cache-directories: ""

# Determines whether workspace `target` directories are cached.
# If `false`, only the cargo registry will be cached.
# default: "true"
# cache-targets: ""

# Determines if the cache should be saved even when the workflow has failed.
# default: "false"
# cache-on-failure: ""
key: build-cargo-target

# Determiners whether the cache should be saved.
# If `false`, the cache is only restored.
# Useful for jobs where the matrix is additive e.g. additional Cargo features.
# default: "true"
# save-if: ""
- name: Cargo Build
run: cargo build
84 changes: 21 additions & 63 deletions .github/workflows/cargo-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,37 @@ env:

jobs:

skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
# skip_check:
# runs-on: ubuntu-latest
# outputs:
# should_skip: ${{ steps.skip_check.outputs.should_skip }}
# steps:
# - id: skip_check
# uses: fkirc/skip-duplicate-actions@v5

backend-integration-tests:
needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'
# needs: skip_check
# if: needs.skip_check.outputs.should_skip != 'true'

runs-on: ubuntu-latest
runs-on: self-hosted-integration-tests

steps:

- uses: actions/checkout@v3

- uses: actions/cache@v3
# - uses: actions/cache@v3
# with:
# path: ./target
# key: "${{ runner.os }}-cargo-integration-tests-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', './rs') }}"
# restore-keys: |
# ${{ runner.os }}-cargo-integration-tests-

- name: Local cargo cache
id: integration-tests-cargo-cache
uses: MasterworksIO/[email protected]
with:
path: ./target
key: "${{ runner.os }}-cargo-integration-tests-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', './rs') }}"
restore-keys: |
${{ runner.os }}-cargo-integration-tests-
# - uses: Swatinem/rust-cache@v2
# with:
# cache-all-crates: true
# with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
# prefix-key: ""

# A cache key that is used instead of the automatic `job`-based key,
# and is stable over multiple jobs.
# default: empty
# shared-key: ""

# An additional cache key that is added alongside the automatic `job`-based
# cache key and can be used to further differentiate jobs.
# default: empty
# key: ""

# A whitespace separated list of env-var *prefixes* who's value contributes
# to the environment cache key.
# The env-vars are matched by *prefix*, so the default `RUST` var will
# match all of `RUSTC`, `RUSTUP_*`, `RUSTFLAGS`, `RUSTDOC_*`, etc.
# default: "CARGO CC CFLAGS CXX CMAKE RUST"
# env-vars: ""

# The cargo workspaces and target directory configuration.
# These entries are separated by newlines and have the form
# `$workspace -> $target`. The `$target` part is treated as a directory
# relative to the `$workspace` and defaults to "target" if not explicitly given.
# default: ". -> target"
# workspaces: ""

# Additional non workspace directories to be cached, separated by newlines.
# cache-directories: ""

# Determines whether workspace `target` directories are cached.
# If `false`, only the cargo registry will be cached.
# default: "true"
# cache-targets: ""

# Determines if the cache should be saved even when the workflow has failed.
# default: "false"
# cache-on-failure: ""
key: integration-tests-cargo-target

# Determiners whether the cache should be saved.
# If `false`, the cache is only restored.
# Useful for jobs where the matrix is additive e.g. additional Cargo features.
# default: "true"
# save-if: ""
- name: Cargo Integration Tests
run: cargo test --test "*"
82 changes: 20 additions & 62 deletions .github/workflows/cargo-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,80 +24,38 @@ env:

jobs:

skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
# skip_check:
# runs-on: self-hosted-unit-tests
# outputs:
# should_skip: ${{ steps.skip_check.outputs.should_skip }}
# steps:
# - id: skip_check
# uses: fkirc/skip-duplicate-actions@v5

backend-unit-tests:

needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'
# needs: skip_check
# if: needs.skip_check.outputs.should_skip != 'true'

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v3

- uses: actions/cache@v3
# - uses: actions/cache@v3
# with:
# path: ./target
# key: "${{ runner.os }}-cargo-unit-tests-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', './rs') }}"
# restore-keys: |
# ${{ runner.os }}-cargo-unit-tests-

- name: Local cargo cache
id: unit-tests-cargo-cache
uses: MasterworksIO/[email protected]
with:
path: ./target
key: "${{ runner.os }}-cargo-unit-tests-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', './rs') }}"
restore-keys: |
${{ runner.os }}-cargo-unit-tests-
#- uses: Swatinem/rust-cache@v2
# with:
# cache-all-crates: true
# with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
# prefix-key: ""

# A cache key that is used instead of the automatic `job`-based key,
# and is stable over multiple jobs.
# default: empty
# shared-key: ""

# An additional cache key that is added alongside the automatic `job`-based
# cache key and can be used to further differentiate jobs.
# default: empty
# key: ""

# A whitespace separated list of env-var *prefixes* who's value contributes
# to the environment cache key.
# The env-vars are matched by *prefix*, so the default `RUST` var will
# match all of `RUSTC`, `RUSTUP_*`, `RUSTFLAGS`, `RUSTDOC_*`, etc.
# default: "CARGO CC CFLAGS CXX CMAKE RUST"
# env-vars: ""

# The cargo workspaces and target directory configuration.
# These entries are separated by newlines and have the form
# `$workspace -> $target`. The `$target` part is treated as a directory
# relative to the `$workspace` and defaults to "target" if not explicitly given.
# default: ". -> target"
# workspaces: ""

# Additional non workspace directories to be cached, separated by newlines.
# cache-directories: ""

# Determines whether workspace `target` directories are cached.
# If `false`, only the cargo registry will be cached.
# default: "true"
# cache-targets: ""

# Determines if the cache should be saved even when the workflow has failed.
# default: "false"
# cache-on-failure: ""
key: unit-tests-cargo-target

# Determiners whether the cache should be saved.
# If `false`, the cache is only restored.
# Useful for jobs where the matrix is additive e.g. additional Cargo features.
# default: "true"
# save-if: ""
- name: Cargo Unit Tests
run: cargo test --bins --lib -- --nocapture
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

release:

runs-on: self-hosted
runs-on: self-hosted-release

strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions defs/analytics/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type Analytics = {
sessions: number;
ips: number;
total_duration_ms: number;
total_transfer_bytes: number;
by_month: Array<AnalyticsItem<YearMonth>>;
by_day: Array<AnalyticsItem<YearMonthDay>>;
by_hour: Array<AnalyticsItem<number>>;
Expand Down
1 change: 1 addition & 0 deletions defs/analytics/AnalyticsItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export type AnalyticsItem<K> = {
key: K;
sessions: number;
total_duration_ms: number;
total_transfer_bytes: number;
};
2 changes: 1 addition & 1 deletion defs/db/StreamConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type StreamConnection = {
_id: string;
station_id: string;
deployment_id: string;
transfer_bytes: number;
transfer_bytes: number | null;
duration_ms: number | null;
is_open: boolean;
created_at: DateTime;
Expand Down
1 change: 1 addition & 0 deletions defs/db/StreamConnectionLite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type StreamConnectionLite = {
ip: string;
cc: CountryCode | null;
du: number | null;
by: number | null;
br: string | null;
os: string | null;
ca: DateTime;
Expand Down
5 changes: 4 additions & 1 deletion front/admin/src/lib/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
/* @import url("./gilroy/gilroy.css"); */
/* @import url("./g/g.css"); */
@import url("./circular/circular.css");
@import url("./azeret-mono/azeret-mono.css");


:root {
font-family: Circular, "Fira Sans", G, Cera, Jost, Overpass, sans-serif;
font-size: 16px;

--monospace: "Azeret Mono", "Chivo Mono", monospace, ui-monospace;

--drawer-width: 250px;
--top-h: 4.5rem;
--player-h: 5rem;
Expand All @@ -20,7 +23,7 @@
--blue-rgb: 0, 116, 217;
--blue: rgb(var(--blue-rgb));

--loading-color: var(--blue);
--loading-color: rgb(32, 118, 232);

--green: #75A633;

Expand Down
Loading

0 comments on commit 5071d07

Please sign in to comment.