-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add dashboard notification count dataset #1553
Open
whabanks
wants to merge
4
commits into
main
Choose a base branch
from
dashboard-counts-dataset
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- The dataset combines the notification, notification_history, and fact_notification_status tables so we can track and identify any discrepancies
Staging: quicksight✅ Terraform Init: Plan: 2 to add, 1 to change, 0 to destroy Show summary
Show planResource actions are indicated with the following symbols:
+ create
~ update in-place
Terraform will perform the following actions:
# aws_quicksight_data_set.dashboard-notification-counts will be created
+ resource "aws_quicksight_data_set" "dashboard-notification-counts" {
+ arn = (known after apply)
+ aws_account_id = (known after apply)
+ data_set_id = "dashboard-notification-counts"
+ id = (known after apply)
+ import_mode = "SPICE"
+ name = "Dashboard notification counts"
+ output_columns = (known after apply)
+ tags_all = (known after apply)
+ permissions {
+ actions = [
+ "quicksight:CancelIngestion",
+ "quicksight:CreateIngestion",
+ "quicksight:DeleteDataSet",
+ "quicksight:DescribeDataSet",
+ "quicksight:DescribeDataSetPermissions",
+ "quicksight:DescribeIngestion",
+ "quicksight:ListIngestions",
+ "quicksight:PassDataSet",
+ "quicksight:UpdateDataSet",
+ "quicksight:UpdateDataSetPermissions",
]
+ principal = "arn:aws:quicksight:ca-central-1:239043911459:group/default/quicksight-dataset-owners"
}
+ permissions {
+ actions = [
+ "quicksight:DescribeDataSet",
+ "quicksight:DescribeDataSetPermissions",
+ "quicksight:DescribeIngestion",
+ "quicksight:ListIngestions",
+ "quicksight:PassDataSet",
]
+ principal = "arn:aws:quicksight:ca-central-1:239043911459:group/default/quicksight-dataset-viewers"
}
+ physical_table_map {
+ physical_table_map_id = "notification-counts"
+ custom_sql {
+ data_source_arn = "arn:aws:quicksight:ca-central-1:239043911459:datasource/NotificationCanadaCastaging"
+ name = "dashboard-notification-counts"
+ sql_query = <<-EOT
WITH n AS (
SELECT
service_id,
COUNT(id) AS n_count,
DATE_PART('day', created_at) AS day
FROM notifications
WHERE
created_at >= DATE_TRUNC('day', NOW()) - interval '14 days'
AND created_at <= (DATE_TRUNC('day', NOW()) + interval '1 day' - interval '1 second')
AND key_type <> 'test'
GROUP BY
DATE_PART('day', created_at),
service_id
ORDER BY day
),
nh AS (
SELECT
service_id,
COUNT(id) AS nh_count,
DATE_PART('day', created_at) AS day
FROM notification_history
WHERE
created_at >= DATE_TRUNC('day', NOW()) - interval '14 days'
AND created_at <= (DATE_TRUNC('day', NOW()) + interval '1 day' - interval '1 second')
AND key_type <> 'test'
GROUP BY
DATE_PART('day', created_at),
service_id
ORDER BY day, service_id
),
ft AS (
SELECT
service_id,
SUM(notification_count) AS ft_count,
DATE_PART('day', bst_date) AS day
FROM ft_notification_status
WHERE
bst_date >= DATE_TRUNC('day', NOW()) - interval '14 days'
AND bst_date <= (DATE_TRUNC('day', NOW()) + interval '1 day' - interval '1 second')
AND key_type <> 'test'
GROUP BY
DATE_PART('day', bst_date),
service_id
ORDER BY day
)
SELECT
COALESCE(n.service_id, nh.service_id, ft.service_id) AS service_id,
COALESCE(n.day, nh.day, ft.day) AS day,
n.n_count,
nh.nh_count,
ft.ft_count,
CASE
WHEN nh.nh_count IS NOT NULL AND ft.ft_count IS NOT NULL AND nh.nh_count <> ft.ft_count THEN '❌'
ELSE '✅'
END AS count_comparison
FROM n
FULL OUTER JOIN nh
ON n.day = nh.day AND n.service_id = nh.service_id
FULL OUTER JOIN ft
ON COALESCE(n.day, nh.day) = ft.day
AND COALESCE(n.service_id, nh.service_id) = ft.service_id
ORDER BY day, service_id
EOT
+ columns {
+ name = "service_id"
+ type = "STRING"
}
+ columns {
+ name = "day"
+ type = "INTEGER"
}
+ columns {
+ name = "n_count"
+ type = "INTEGER"
}
+ columns {
+ name = "nh_count"
+ type = "INTEGER"
}
+ columns {
+ name = "ft_count"
+ type = "INTEGER"
}
+ columns {
+ name = "count_comparison"
+ type = "STRING"
}
}
}
}
# aws_quicksight_refresh_schedule.dashboard-notification-counts will be created
+ resource "aws_quicksight_refresh_schedule" "dashboard-notification-counts" {
+ arn = (known after apply)
+ aws_account_id = (known after apply)
+ data_set_id = "dashboard-notification-counts"
+ id = (known after apply)
+ schedule_id = "schedule-dashboard-notification-counts"
+ schedule {
+ refresh_type = "FULL_REFRESH"
+ start_after_date_time = (known after apply)
+ schedule_frequency {
+ interval = "DAILY"
+ time_of_the_day = "01:00"
+ timezone = (known after apply)
}
}
}
# aws_s3_object.manifest_file will be updated in-place
~ resource "aws_s3_object" "manifest_file" {
~ etag = "4f558e8d8cdbbf914a95755cbda61968" -> "221f592f333f2fc284626cfdb8c4bc80"
id = "quicksight/s3-manifest-sms-usage.json"
tags = {}
+ version_id = (known after apply)
# (12 unchanged attributes hidden)
}
Plan: 2 to add, 1 to change, 0 to destroy.
─────────────────────────────────────────────────────────────────────────────
Saved the plan to: plan.tfplan
To perform exactly these actions, run the following command to apply:
terraform apply "plan.tfplan"
Show Conftest resultsWARN - plan.json - main - Missing Common Tags: ["aws_cloudformation_stack.sms-usage-notifications"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight-rds"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight-s3-usage"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight_vpc_connection_ec2"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight_vpc_connection_iam"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_role.quicksight"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_role.vpc_connection_role"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.dashboard-notification-counts"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.jobs"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.login_events"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.notifications"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.organisation"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.services"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.sms_usage"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.template-category-history"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.templates"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.users"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_source.rds"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_source.s3_sms_usage"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_vpc_connection.rds"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_object.manifest_file"]
40 tests, 19 passed, 21 warnings, 0 failures, 0 exceptions
|
staging: quicksight✅ Terraform Init: Plan: 2 to add, 1 to change, 0 to destroy Show summary
Show planResource actions are indicated with the following symbols:
+ create
~ update in-place
Terraform will perform the following actions:
# aws_quicksight_data_set.dashboard-notification-counts will be created
+ resource "aws_quicksight_data_set" "dashboard-notification-counts" {
+ arn = (known after apply)
+ aws_account_id = (known after apply)
+ data_set_id = "dashboard-notification-counts"
+ id = (known after apply)
+ import_mode = "SPICE"
+ name = "Dashboard notification counts"
+ output_columns = (known after apply)
+ tags_all = (known after apply)
+ data_set_usage_configuration (known after apply)
+ logical_table_map (known after apply)
+ permissions {
+ actions = [
+ "quicksight:CancelIngestion",
+ "quicksight:CreateIngestion",
+ "quicksight:DeleteDataSet",
+ "quicksight:DescribeDataSet",
+ "quicksight:DescribeDataSetPermissions",
+ "quicksight:DescribeIngestion",
+ "quicksight:ListIngestions",
+ "quicksight:PassDataSet",
+ "quicksight:UpdateDataSet",
+ "quicksight:UpdateDataSetPermissions",
]
+ principal = "arn:aws:quicksight:ca-central-1:239043911459:group/default/quicksight-dataset-owners"
}
+ permissions {
+ actions = [
+ "quicksight:DescribeDataSet",
+ "quicksight:DescribeDataSetPermissions",
+ "quicksight:DescribeIngestion",
+ "quicksight:ListIngestions",
+ "quicksight:PassDataSet",
]
+ principal = "arn:aws:quicksight:ca-central-1:239043911459:group/default/quicksight-dataset-viewers"
}
+ physical_table_map {
+ physical_table_map_id = "notification-counts"
+ custom_sql {
+ data_source_arn = "arn:aws:quicksight:ca-central-1:239043911459:datasource/NotificationCanadaCastaging"
+ name = "dashboard-notification-counts"
+ sql_query = <<-EOT
WITH n AS (
SELECT
service_id,
COUNT(id) AS n_count,
DATE_PART('day', created_at) AS day
FROM notifications
WHERE
created_at >= DATE_TRUNC('day', NOW()) - interval '14 days'
AND created_at <= (DATE_TRUNC('day', NOW()) + interval '1 day' - interval '1 second')
AND key_type <> 'test'
GROUP BY
DATE_PART('day', created_at),
service_id
ORDER BY day
),
nh AS (
SELECT
service_id,
COUNT(id) AS nh_count,
DATE_PART('day', created_at) AS day
FROM notification_history
WHERE
created_at >= DATE_TRUNC('day', NOW()) - interval '14 days'
AND created_at <= (DATE_TRUNC('day', NOW()) + interval '1 day' - interval '1 second')
AND key_type <> 'test'
GROUP BY
DATE_PART('day', created_at),
service_id
ORDER BY day, service_id
),
ft AS (
SELECT
service_id,
SUM(notification_count) AS ft_count,
DATE_PART('day', bst_date) AS day
FROM ft_notification_status
WHERE
bst_date >= DATE_TRUNC('day', NOW()) - interval '14 days'
AND bst_date <= (DATE_TRUNC('day', NOW()) + interval '1 day' - interval '1 second')
AND key_type <> 'test'
GROUP BY
DATE_PART('day', bst_date),
service_id
ORDER BY day
)
SELECT
COALESCE(n.service_id, nh.service_id, ft.service_id) AS service_id,
COALESCE(n.day, nh.day, ft.day) AS day,
n.n_count,
nh.nh_count,
ft.ft_count,
CASE
WHEN nh.nh_count IS NOT NULL AND ft.ft_count IS NOT NULL AND nh.nh_count <> ft.ft_count THEN '❌'
ELSE '✅'
END AS count_comparison
FROM n
FULL OUTER JOIN nh
ON n.day = nh.day AND n.service_id = nh.service_id
FULL OUTER JOIN ft
ON COALESCE(n.day, nh.day) = ft.day
AND COALESCE(n.service_id, nh.service_id) = ft.service_id
ORDER BY day, service_id
EOT
+ columns {
+ name = "service_id"
+ type = "STRING"
}
+ columns {
+ name = "day"
+ type = "INTEGER"
}
+ columns {
+ name = "n_count"
+ type = "INTEGER"
}
+ columns {
+ name = "nh_count"
+ type = "INTEGER"
}
+ columns {
+ name = "ft_count"
+ type = "INTEGER"
}
+ columns {
+ name = "count_comparison"
+ type = "STRING"
}
}
+ s3_source (known after apply)
}
}
# aws_quicksight_refresh_schedule.dashboard-notification-counts will be created
+ resource "aws_quicksight_refresh_schedule" "dashboard-notification-counts" {
+ arn = (known after apply)
+ aws_account_id = (known after apply)
+ data_set_id = "dashboard-notification-counts"
+ id = (known after apply)
+ schedule_id = "schedule-dashboard-notification-counts"
+ schedule {
+ refresh_type = "FULL_REFRESH"
+ start_after_date_time = (known after apply)
+ schedule_frequency {
+ interval = "DAILY"
+ time_of_the_day = "01:00"
+ timezone = (known after apply)
}
}
}
# aws_s3_object.manifest_file will be updated in-place
~ resource "aws_s3_object" "manifest_file" {
~ etag = "4f558e8d8cdbbf914a95755cbda61968" -> "221f592f333f2fc284626cfdb8c4bc80"
id = "quicksight/s3-manifest-sms-usage.json"
tags = {}
+ version_id = (known after apply)
# (24 unchanged attributes hidden)
}
Plan: 2 to add, 1 to change, 0 to destroy.
─────────────────────────────────────────────────────────────────────────────
Saved the plan to: plan.tfplan
To perform exactly these actions, run the following command to apply:
terraform apply "plan.tfplan"
Show Conftest resultsWARN - plan.json - main - Missing Common Tags: ["aws_cloudformation_stack.sms-usage-notifications"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight-rds"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight-s3-usage"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight_vpc_connection_ec2"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.quicksight_vpc_connection_iam"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_role.quicksight"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_role.vpc_connection_role"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.dashboard-notification-counts"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.jobs"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.login_events"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.notifications"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.organisation"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.services"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.sms_usage"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.template-category-history"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.templates"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_set.users"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_source.rds"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_data_source.s3_sms_usage"]
WARN - plan.json - main - Missing Common Tags: ["aws_quicksight_vpc_connection.rds"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_object.manifest_file"]
40 tests, 19 passed, 21 warnings, 0 failures, 0 exceptions
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary | Résumé
This dataset combines the notification, notification_history, and fact_notification_status tables so we can track and identify any discrepancies.
Related Issues | Cartes liées
Before merging this PR
Read code suggestions left by the
cds-ai-codereviewer bot. Address
valid suggestions and shortly write down reasons to not address others. To help
with the classification of the comments, please use these reactions on each of the
comments made by the AI review:
The classifications will be extracted and summarized into an analysis of how helpful
or not the AI code review really is.
Test instructions | Instructions pour tester la modification
TODO: Fill in test instructions for the reviewer.
Release Instructions | Instructions pour le déploiement
None.
Reviewer checklist | Liste de vérification du réviseur