Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW7 #30

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

HW7 #30

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
15 changes: 8 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
// "context": "."
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
},
"name": "Existing Docker Compose (Extend)",

"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
],
"service": "devcontainer",
"workspaceFolder": "/workspaces",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ jobs:
ports:
- 9000:9000
- 8123:8123

metabase:
image: metabase/metabase:v0.49.6
ports:
- 3000:3000

cube:
image: cubejs/cube:latest
ports:
- 4000:4000
- 15432:15432
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -42,6 +53,10 @@ jobs:
uses: kzzzr/mybi-dbt-action@v4
with:
command: dbt build --full-refresh
- name: test cube api
uses: kzzzr/mybi-dbt-action@v4
with:
command: curl http:cube:4000/api/v1/load?query={"measures": ["f_tracker.bounces"]}
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# if: ${{ failure() }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM fishtownanalytics/dbt:${DBT_VERSION}

RUN set -ex \
&& python -m pip install --upgrade pip setuptools \
&& python -m pip install --upgrade dbt-clickhouse numpy
&& python -m pip install --upgrade dbt-clickhouse==1.4.0 dbt-core==1.4.6 numpy

WORKDIR /usr/app/
ENV DBT_PROFILES_DIR=.
Expand Down
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- 8123:8123

metabase:
image: metabase/metabase:v0.44.6
image: metabase/metabase:v0.49.6
volumes:
- ./metabase/plugins:/plugins
- ./metabase/metabase.db:/metabase.db/
Expand All @@ -27,3 +27,12 @@ services:
- .env
volumes:
- .:/cube/conf

devcontainer:
build:
context: .
args:
DBT_VERSION: 1.0.0
entrypoint: ["tail", "-f", "/dev/null"]
volumes:
- .:/workspace
Binary file modified metabase/metabase.db/metabase.db.mv.db
Binary file not shown.
1,513 changes: 1,513 additions & 0 deletions metabase/metabase.db/metabase.db.trace.db

Large diffs are not rendered by default.

Binary file added metabase/metabase.db/metabase.db.v1-backup.mv.db
Binary file not shown.
32 changes: 32 additions & 0 deletions models/metrics/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,35 @@ metrics:
time_grains: [day, week, month, quarter, year]

dimensions: [traffic_grouping, traffic_source, traffic_medium, traffic_campaign, device_category, location_country]

- name: bounces
label: 'Bounces'
model: ref('f_tracker')
calculation_method: sum
expression: bounces

timestamp: dt
time_grains: [day, week, month, quarter, year]

dimensions: [traffic_grouping, traffic_source, traffic_medium, traffic_campaign, device_category, location_country]

- name: sessions
label: 'Sessions'
model: ref('f_tracker')
calculation_method: sum
expression: sessions

timestamp: dt
time_grains: [day, week, month, quarter, year]

dimensions: [traffic_grouping, traffic_source, traffic_medium, traffic_campaign, device_category, location_country]

- name: bounce_rate
label: 'Bounce rate'
calculation_method: derived
expression: "{{metric('bounces')}} / {{metric('sessions')}}"

timestamp: dt
time_grains: [day, week, month, quarter, year]

dimensions: [traffic_grouping, traffic_source, traffic_medium, traffic_campaign, device_category, location_country]
9 changes: 9 additions & 0 deletions schema/f_tracker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ cubes:
- name: CPC
sql: '{CUBE.costs} / nullif(coalesce({CUBE.clicks}, 1), 0)'
type: number
- name: bounces
sql: bounces
type: sum
- name: sessions
sql: sessions
type: sum
- name: bounce_rate
sql: '{CUBE.bounces}/{CUBE.sessions}'
type: number
dimensions:
- name: date
sql: 'dt'
Expand Down