Skip to content

Commit

Permalink
adding staging and intermediate models with test
Browse files Browse the repository at this point in the history
  • Loading branch information
Fujistone committed Oct 2, 2024
1 parent a592013 commit 7e9219c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode/
.user.yml
.env
.venv
.idea
.DS_Store
package-lock.yml
Expand Down
13 changes: 13 additions & 0 deletions projects/lyon/models/intermediate/matomo/int_matomo_downloads.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT
-- Extraction du nom du fichier sans l'extension
split_part(split_part(url, '/', -1), '.', 1) AS document_name,

-- Extraction de l'extension (pdf, jpeg, etc.)
split_part(split_part(url, '/', -1), '.', 2) AS document_extension

FROM {{ref ("stg_matomo_downloads")}}





15 changes: 15 additions & 0 deletions projects/lyon/models/intermediate/matomo/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

unit_tests:
- name: testing_that_document_names_are_correctly_extracted
description: "Checks that document names are correctly extracted from URLs"
model: int_matomo_downloads
given:
- input: ref('stg_matomo_downloads')
format: dict
rows:
- {url: "https://oye.participer.lyon.fr/uploads/decidim/attachment/file/18/Règlement_du_budget_participatif.pdf"}
expect:
format: dict
rows:
- {document_name: 'Règlement_du_budget_participatif', document_extension: 'pdf'}
14 changes: 14 additions & 0 deletions projects/lyon/models/staging/matomo/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

sources:
- name: matomo
database: "{{ env_var('DBNAME') }}"
schema: matomo
tables:
- name: pages
- name: visits
- name: referrers
- name: device_type
- name: page_titles
- name : users_city
- name : downloads
10 changes: 10 additions & 0 deletions projects/lyon/models/staging/matomo/stg_matomo_downloads.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SELECT
date,
nb_visits,
nb_hits,
sum_time_spent,
index,
nb_uniq_visitors,
label,
url
FROM {{ source('matomo', 'downloads') }}

0 comments on commit 7e9219c

Please sign in to comment.