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

[DISCO-2325] Create JSON Schema Validation for Control Mechanism #93

Merged
merged 13 commits into from
Apr 21, 2023

Conversation

taddes
Copy link
Contributor

@taddes taddes commented Apr 14, 2023

References

JIRA: DISCO-2325
GitHub: #95

Description

The goal of this task is to create the new JSON Schema for the Allocations of Kevel and adM partner advertisements. The document allows the distribution of ads by percentage supplying a percentage from 0 - 100 between the two and their occurrence in the array/list defines the Contile tiles from left to right, or the 0th index up.

The schema has description values for each key which supply sufficient context for anyone viewing the ticket.

Note: this task is only to create the valid schema. Subsequent tickets will cover the validation process, tests and potentially defining a model for this data.

A lengthy regex has been supplied to validate the title label in the format: SOV-<UTC datetime:YYYYMMDDHHMMSS>. For readability, here are the capture groups and their restrictions as it's not super readable in the JSON. We want an accurate representation of actual correct datetimes, hence the need to define multiple capture groups that ensure Y, M, D, h, m, s values are correct

^(SOV-) 
([0-9]{4}) # year
(0[1-9]|1[0-2]) # month
(0[1-9]|[1-2][0-9]|3[0-1]) # day
(2[0-3]|[01][0-9]) # hour
([0-5][0-9]) # minute
([0-5][0-9])$ # second

See JSON Schema docs on regex matching here

@taddes taddes changed the title WIP: [DISCO-2325] Create JSON Schema Validation for Control Mechanism [DISCO-2325] Create JSON Schema Validation for Control Mechanism Apr 15, 2023
@taddes taddes self-assigned this Apr 19, 2023
@taddes taddes marked this pull request as ready for review April 20, 2023 01:28
@taddes taddes requested review from tiftran and a team April 20, 2023 01:29
Copy link
Contributor

@tiftran tiftran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some tiny things, but tyty for getting this done 🙂

.env.example Outdated
Comment on lines 4 to 10
DB_USER=postgres
DB_HOST=localhost
DB_PASS=postgres
DJANGO_SETTINGS_MODULE=consvc_shepherd.settings
OPENIDC_HEADER_PREFIX="accounts.google.com:"
OPENIDC_HEADER="x-goog"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this out since it's included in your last PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I may just match to what's on main now and there shouldn't be any conflicts when merging.

Comment on lines +131 to +136
# DS_Store files for macOS
**/.DS_Store

# VS Code configuration files
.vscode/*
!.vscode/launch.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -22,7 +22,7 @@ def publish_snapshot(modeladmin, request, queryset):
snapshot.launched_by = request.user
snapshot.launched_date = timezone.now()
content = json.dumps(snapshot.json_settings, indent=2)
with open("./schema/shepherd.schema.json", "r") as f:
with open("./schema/filter.schema.json", "r") as f:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually can we rename it as adm_filter instead? sorry 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, wfm! 👍

@@ -10,7 +10,7 @@ class JSONSchema(TestCase):

def test_schema(self):

with open("./schema/shepherd.schema.json", "r") as f:
with open("./schema/filter.schema.json", "r") as f:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here please and thank you

@@ -0,0 +1,56 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! We'll add tests when Shepherd is able to produce json!

@taddes taddes requested a review from tiftran April 21, 2023 19:12
@taddes taddes merged commit 9136f97 into main Apr 21, 2023
@taddes taddes deleted the DISCO-2235-json-schema-validation-for-contol-mechanism branch April 21, 2023 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants