Skip to content

Commit

Permalink
example changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sung Won Chung committed Feb 6, 2024
1 parent 402e32a commit 1a2ea4a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ If you have questions unique to your tech stack, schedule a call with us at: [Da
- Automated deployment of changed dbt models to production and their downstream models when pull requests merge into the main production branch
- Automated staging schema cleanup after a pull request is closed so you don't have schema clutter

## How to set up S3 for Slim CI
## Getting Started

> This guide is self-contained and can run from scratch. Once you get the hang of it, you can repeat the steps for your own dbt project.
1. Search the entire repo for `TODO` and replace with your own values
2. Setup your S3 bucket for Slim CI: [Video Tutorial]()
3. Set up your GitHub secrets
4. Commit your changes and push to your remote repository
5. Run the below to build your dbt project on the `main` branch

```bash
dbt build --target prod
```

6. Run the below to switch branches and test your CI pipelines

```bash
git checkout -b feature/your-feature
```

7. Make some changes to your dbt models and push to your remote repository

TODO
46 changes: 46 additions & 0 deletions example_dbt_changes/dim_orgs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
WITH orgs AS (
--prod
SELECT
org_id
, org_name
, employee_range
, created_at
FROM {{ ref('org_created') }}

-- --dev
-- SELECT
-- org_id
-- , org_name
-- , employee_range
-- , created_at
-- FROM {{ ref('org_created') }}
)

, user_count AS (
SELECT
org_id
, count(distinct user_id) AS num_users
FROM {{ ref('user_created') }}
GROUP BY 1
)

, subscriptions AS (
SELECT
org_id
, event_timestamp AS sub_created_at
, plan as sub_plan
, coalesce(price, 0) as sub_price
FROM {{ ref('subscription_created') }}
)


SELECT
org_id
, created_at
, num_users
, sub_created_at
, case when num_users = 1 then 'Individual' else sub_plan end as sub_plan
, sub_price
FROM orgs
LEFT JOIN user_count USING (org_id)
LEFT JOIN subscriptions USING (org_id)
21 changes: 21 additions & 0 deletions example_dbt_changes/sales_sync.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
WITH org_events AS (
SELECT
*
FROM {{ ref('dim_orgs') }}
LEFT JOIN {{ ref('feature_used') }} USING (org_id)
WHERE sub_plan IS NULL or sub_plan = 'Individual'
)

, final AS (
SELECT
DISTINCT ORG_ID
, count(*) AS usage
FROM org_events
WHERE
-- select orgs created within the last 60 days, with usage within the 30 days
event_timestamp::date > ('2022-11-01'::date - 30)
AND created_at::date > ('2022-11-01'::date - 60)
GROUP BY 1
)

SELECT * FROM final

0 comments on commit 1a2ea4a

Please sign in to comment.