Skip to content

Commit

Permalink
incremental todos : full refresh for recurring tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
luutuankiet committed Dec 6, 2024
1 parent b006087 commit 1088b29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"python.venvFolders": [
"${workspaceFolder}/.venv"
],
"python.envFile": "${workspaceFolder}/.env",
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.envFile": "${workspaceFolder}/../.env",
"python.defaultInterpreterPath": "${workspaceFolder}/../.venv/bin/python",

"python.terminal.activateEnvironment": true,
"terminal.integrated.inheritEnv": true,
Expand All @@ -27,7 +27,7 @@
"/**/.github/**/*.yml": "github-actions-workflow"
},
"terminal.integrated.environmentChangesRelaunch": true,
"dbt.dbtPythonPathOverride": "${workspaceFolder}/.venv/bin/python",
"dbt.dbtPythonPathOverride": "${workspaceFolder}/../.venv/bin/python",



Expand Down
5 changes: 3 additions & 2 deletions models/marts/core/fact_todos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ FROM
source

{% if is_incremental() %}
WHERE todo_modifiedtime >= (select coalesce(max(todo_modifiedtime),'1900-01-01 00:00:00') from {{ this }} )
OR
WHERE
_modified_time >= (select coalesce(max(_modified_time),'1900-01-01 00:00:00') from {{ this }} )
OR
todo_modifiedtime IS NULL
{% endif %}
10 changes: 8 additions & 2 deletions models/staging/stg_todos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,19 @@ joined AS (
)
SELECT
{{ dbt_utils.generate_surrogate_key(['todo_id']) }} AS todo_key,
*
*,
{{dbt_date.now("Asia/Ho_Chi_Minh")}} as _modified_time
FROM
joined

{% if is_incremental() %}
WHERE
todo_completedtime >= todo_modifiedtime -- address this bug tasks completed dont get updated in modified time
(-- address this bug tasks completed dont get updated in modified time
todo_completedtime >= todo_modifiedtime
AND todo_completedtime::date >= {{dbt_date.n_days_ago(7)}}
)
OR
todo_derived__is_repeat is True -- full refresh all habit tasks
OR
todo_modifiedtime >= (select coalesce(max(todo_modifiedtime),'1900-01-01 00:00:00') from {{ this }} )
{% endif %}

0 comments on commit 1088b29

Please sign in to comment.