Add DateTime attribute range filtering (__after / __before / between)#9074
Open
FragmentedPacket wants to merge 9 commits intostablefrom
Open
Add DateTime attribute range filtering (__after / __before / between)#9074FragmentedPacket wants to merge 9 commits intostablefrom
FragmentedPacket wants to merge 9 commits intostablefrom
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Relax default_attribute_query_filter to accept datetime values and route before/after filter names to a `>` / `<` comparison against av.value. Filter values are normalized to canonical UTC strings via Timestamp(...).to_string(), mirroring what _build_metadata_filter_requirement already does for node_metadata__*__before/after. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ttributes Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…butes Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ity under C901 The new before/after branch in default_attribute_query_filter pushed the function's cyclomatic complexity to 21, tripping the project's ruff C901 threshold of 20. Move the branch body into a small _datetime_range_filter_clause helper so the inline elif drops back to a flat extend/update/extend. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…e filters
Wires every DateTime attribute (CoreCheck.created_at, CoreValidator.completed_at /
started_at, CoreAccountToken.expiration, etc.) to the new range filter inputs
exposed by DateTime.get_graphql_filters. Generated by:
uv run invoke schema.generate-graphqlschema
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Picks up `<attr>__after` / `<attr>__before` inputs on every node kind
that has a DateTime attribute (CoreCheck, CoreValidator, CoreAccountToken,
etc.). Generated by:
pnpm codegen
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or 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
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.
Closes #9073.
Summary
Adds
before/after/betweenfiltering on node attributes of kindDateTime, mirroring the picker UX 1.9 already provides fornode_metadata__created_at/node_metadata__updated_at. Six commits, three layers — none large.291f14btime__after/time__before/ range /__isnullregression baseline (4 tests)efa6cf9get_graphql_filtersonDateTimedata type to expose<name>__after/<name>__before0cda9e6default_attribute_query_filteracceptsdatetimeand routesbefore/afterto>/<againstav.value; filter values normalized to canonical UTC viaTimestamp(value.isoformat()).to_string()(mirrors_build_metadata_filter_requirement)83d9d8bDATETIME_FILTER_CONDITION_OPTIONSwithBEFORE/AFTER/BETWEEN3c080f9DateMetadataFilterForm's picker block into sharedDateRangePickerFieldscomponent8eb6c8dAttributeFilterFormroutes DateTime kind + range condition to the new picker; default condition for DateTime flips fromIS_EMPTYtoAFTERTest plan
Unknown argument 'time__after'GraphQL errors beforeefa6cf9.TestDateTimeAttributeFiltertests pass after0cda9e6.backend/tests/component/graphql/test_graphql_query_metadata.py— 37/37 pass.backend/tests/component/core/test_node_get_list_query.py— 57/57 pass.uv run invoke backend.test-unit) — 608/608 pass.graphql/+core/) — 1446 passed, 13 skipped, 3 xfailed; pytest exit 0. Local run hit--session-timeout=1800at ~53% of files; CI has a longer budget.CoreAccountToken.expirationis the easiest path (generate a few API tokens with varied expirations, filter byexpiration__after/__before/between). Other built-in DateTime fields exist onCoreValidatorandCoreCheck. None of the default-loaded demo nodes (models/base/,models/infrastructure_edge.py) currently have a custom DateTime attribute — separate optional follow-up could add e.g.InfraDevice.last_seenfor richer demo coverage.Implementation notes
__isnull/__valuefilters on DateTime attributes still work identically. The__isnullregression test confirms it.frontend/app/src/shared/api/graphql/generated/types.tsis regenerated bypnpm codegenfromschema/schema.graphql, which itself is exported from a live backend viainfrahub dev export-graphql-schema. Codegen against the currentschema.graphqlis a no-op — the file pre-dates the new filter args. Since the frontend builds list-page queries dynamically viajsonToGraphQLQuery(nogql-tagged static queries reference these new args), runtime behavior works regardless. Schema/types regeneration should happen as part of the normal release workflow.getCurrentFilterConditionalready maps<attr>__after→AFTER/<attr>__before→BEFORE.active-filter-tags.tsxalready renders chips forbefore/aftersuffixes on non-relationship definitions.Caveat: stored value timezone canonicalization
DateTime attribute values are stored as user-supplied strings (
BaseAttribute.serialize_valueis identity). Lexicographic Cypher</>is correct only when stored values are also in canonical form. In practice values written via the standard grapheneDateTimeingestion path are canonical, but values inserted via direct DB writes or non-standard paths could produce off-by-tz results. Same limitation applies to the existing metadata path; flagged in #9073 for a separate hardening effort (either write-time normalization ordatetime()casts in Cypher).🤖 Generated with Claude Code