The code you’ve written is looking for a variable defined in your dbt_project.yml called tag. To access the tags on a model, you can use the {{ model }} object: model | dbt Developer Hub
Keep in mind that it could be an array, so you’d have to do an in check, something like this:
--models/some_model.sql
select *
from {{ ref('an_upstream_model') }}
{{ filter_based_on_tag(model.tags) }}
--macros/filter_based_on_tag.sql
{% macro filter_based_on_tag(tags) %}
where
{% if execute %} -- https://docs.getdbt.com/reference/dbt-jinja-functions/execute
{% if 'hourly' in tags %}
some_thing > dateadd('hour', -1, getdate())
{% elif 'daily' in tags %}
some_thing > dateadd('day', -1, getdate())
{% else %}
true
{% endif %}
{% endif %}
{% endmacro %}