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

[DC-3513] Update the raw_fitbit_qc.py - sleep_level - level check #1821

Merged
merged 3 commits into from
Dec 14, 2023
Merged
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
26 changes: 12 additions & 14 deletions data_steward/analytics/cdr_ops/raw_fitbit_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@
src_ids_check_results = execute(client, src_ids_check)
zones_check_results = execute(client, zone_names_check)

display(src_ids_check_results)
display(zones_check_results)

check_status = "Look at the result and see if it meets all the following criteria."
msg = (
"The result must show that <br>"
Expand All @@ -154,6 +151,10 @@
HTML(
f'''<h3>Check Status: <span style="color: gold">{check_status}</span></h3><p>{msg}</p>'''
))

display(src_ids_check_results)
display(zones_check_results)

# -

# # ACTIVITY_SUMMARY table
Expand Down Expand Up @@ -214,6 +215,7 @@
))

display(df)

# -

# # SLEEP_LEVEL table
Expand All @@ -236,29 +238,21 @@
person_id,
sleep_date
FROM
`{{project_id}}.{{dataset}}.sleep_level`
(SELECT * FROM `{{project_id}}.{{dataset}}.sleep_level` WHERE level != 'unknown')
GROUP BY
person_id, sleep_date
HAVING levels > 7
HAVING levels > 6
)

SELECT
ROUND((COUNT(DISTINCT person_id)/(
SELECT
COUNT(DISTINCT person_id)
FROM
`{{project_id}}.{{dataset}}.sleep_level`
))*100,2) AS percentage
ROUND((COUNT(DISTINCT person_id)/(SELECT COUNT(DISTINCT person_id) FROM `{{project_id}}.{{dataset}}.sleep_level`))*100,2) AS percentage
FROM
all_levels_for_at_least_one_date
""").render(project_id=project_id, dataset=dataset_id)

src_ids_check_results = execute(client, check_src_ids)
sleep_levels_check_results = execute(client, check_sleep_levels)

display(src_ids_check_results)
display(sleep_levels_check_results)

check_status = "Look at the result and see if it meets all the following criteria."
msg = (
"The result must show that <br>"
Expand All @@ -272,6 +266,10 @@
HTML(
f'''<h3>Check Status: <span style="color: gold">{check_status}</span></h3><p>{msg}</p>'''
))

display(src_ids_check_results)
display(sleep_levels_check_results)

# -

# # DEVICE table
Expand Down