fix(social-layer): add start_time to event query, type, and ordering - #49
Open
pastarita wants to merge 1 commit into
Open
fix(social-layer): add start_time to event query, type, and ordering#49pastarita wants to merge 1 commit into
pastarita wants to merge 1 commit into
Conversation
The Social Layer Event was modeled and fetched with end_time but no start_time, in both the GraphQL query and the TS types. Downstream UI could therefore never order events chronologically and fell back to raw array order (.slice(-3).reverse()). The omission was silent: the missing field read as undefined and TypeScript could not flag it. Changes: - Extract EVENTS_QUERY/PROFILES_QUERY into socialLayer/queries.ts (no next/server import) so they are unit-testable; add start_time to both. - Add start_time to the Event and ProfileEvent interfaces. - Add pure helpers sortEventsByStartDesc / recentEventsByStart that order by start_time desc and push missing/invalid timestamps last. - Use the helper for both the Events Hosted and Events Attended lists in ProfileStats, replacing the array-order workaround. Tests (node --test, zero new deps): - tests/socialLayer.queries.test.ts - query projection (TC-A*) - tests/events.helper.test.ts - ordering behaviour (TC-C*) - tests/types.assert.ts - compile-time type contract (TC-B*) - add npm scripts: test, test:types Docs: issue report + test plan/automation protocol under docs/issues/. NOTE: start_time is the symmetric counterpart to the existing end_time; the live Hasura 'events' schema field name should be confirmed by a maintainer (endpoint was unreachable from the dev environment).
|
@pastarita is attempting to deploy a commit to the p2planes Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
The Social Layer Event was modeled and fetched with an
end_timebut nostart_time— the field was absent in both the GraphQL query and the TypeScript types. As a result, the profile event lists (ProfileStats) could never order events chronologically and fell back to raw array order (.slice(-3).reverse()). The omission was silent: the missing field read asundefinedand TypeScript couldn't flag it because the type agreed with the bug.Full write-up and the test plan are included in
docs/issues/.Changes
Fix
EVENTS_QUERY/PROFILES_QUERYintosrc/app/api/socialLayer/queries.ts(nonext/serverimport) so they're unit-testable; addstart_timeto both.start_timeto theEventandProfileEventinterfaces (src/types/StatsSocialLayer.ts).sortEventsByStartDesc/recentEventsByStart(src/helpers/events.ts) that order bystart_timedescending and push missing/invalid timestamps last (never crash, neverNaN-poison the order).ProfileStats.tsx, replacing the array-order workaround.Tests — run with
npm test(Node's built-in runner on TS, zero new dependencies, nonode_modulesrequired):tests/socialLayer.queries.test.ts— query projection (TC-A*)tests/events.helper.test.ts— ordering behaviour incl. missing/invalid/empty (TC-C*)tests/types.assert.ts— compile-time type contract viatsc --noEmit(TC-B*)package.json: addtestandtest:typesscriptstsconfig.json: exclude the runtime*.test.tsfiles fromtsc(they use Node's native TS loader, which requires explicit.tsimport extensions incompatible with the bundler config). The no-extensiontypes.assert.tsstays type-checked.Docs
docs/issues/social-layer-event-missing-start-time.md— identification, investigation trace, root-cause & impact analysis, proposed fixes, evidence index.docs/issues/social-layer-event-start-time.test-plan.md— test-criterion set, automation/agentic execution protocol, pass/fail gates, traceability matrix.Verification
npm testnpx tsc --noEmitnpm run lintnpm run build¹ One pre-existing, unrelated error remains (
src/constants/config.ts→icon.png), untouched by this PR — a standalone-tscimage-types artifact thatnext buildresolves.²
sharpcouldn't build native bindings in the dev sandbox; CI/Vercel build is unaffected.start_timeis the symmetric counterpart to the already-presentend_time, and matches the canonical Social Layer events schema. However, the live Hasura endpoint (hasura-graph.fly.dev) was unreachable from the dev environment, so I could not introspect it to confirm the exact column name. If the source column is named differently (e.g.start_at), only the two query strings inqueries.tsneed to match it. A maintainer with schema access should verify.