-
Notifications
You must be signed in to change notification settings - Fork 325
feat(component-library, insights): added a simple datetime picker and historical fetching to the pyth feeds demo, with URL deeplinking #3351
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
a972c98
feat(component-library, insights): added a simple datetime picker and…
benduran 21937de
fix(insights): fixed app state provider not being wrapped in a suspense
benduran 8fa26a6
chore(insights): added console.info to db config but obfuscating the pwd
benduran 431b189
chore(insights): missed global flag
benduran 452cdeb
chore(insights): one more log
benduran 6e3dc06
chore(insights): added a script to fix env variables with dollar sign…
benduran 7c33093
chore(insights): removed console logging DB config because the issue …
benduran 4e6407e
fix: lint
benduran acf6f28
chore(insights): worked on making the core PriceCard mostly reusable …
benduran a390b68
feat(insights): completed design and layout changes for demo page for…
benduran a44b409
chore(insights): added horizontal scrolling to cards on mobile
benduran 5b24556
feat(component-library, insights): created a Popover abstraction comp…
benduran 5aaa5b5
fix(insights): fixed Value is null and Object is disposed errors that…
benduran 282b905
fix(insights): count a metric as fresh if there wasn't a previous point
benduran be5c229
fix(insights): ensure that date changes properly clear out any previo…
benduran d1d480c
chore: linting
benduran 52deb0e
chore: linting
benduran 87d81b1
Merge pull request #3354 from pyth-network/bduran/t-minus-7-design-tw…
benduran f129f2d
chore(insights): responded to PR feedback
benduran c967425
feat(insights): swapped to using nuqs for better query param management
benduran 71c5cd2
fix(insights): removed typecasting by leveraging zod and fixed some bugs
benduran e6644db
Merge remote-tracking branch 'origin/main' into bduran/T-minus-7-hist…
benduran 301270e
chore: linting
benduran 87dbf3c
chore: linting
benduran 0dc2e8f
Merge remote-tracking branch 'origin/main' into bduran/T-minus-7-hist…
benduran 9a41631
chore: omg, please stop testing json files
benduran 7532c14
fix: force all jest test runs to pass without tests
benduran fdbd725
chore: stop tsc from picking up files it shouldn't care about
benduran 66a51cb
chore disable linting of examples fiels
benduran afe7dae
fix(insights): fixed desktop display having mobile buttons
benduran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Binary file not shown.
65 changes: 36 additions & 29 deletions
65
apps/insights/src/app/api/pyth/get-pyth-feeds-demo-data/[symbol]/route.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,65 @@ | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| import { fetchHistoricalDataForPythFeedsDemo } from "../../../../../pyth-feed-demo-data/fetch-historical-data-from-db"; | ||
| import { GetPythFeedsDemoDataRequestSchema } from "../../../../../schemas/pyth/pyth-pro-demo-schema"; | ||
| import { getNbboAndPythProHistoricalPricesForSymbol } from "../../../../../services/clickhouse"; | ||
|
|
||
| export const GET = async ( | ||
| export async function GET( | ||
| req: NextRequest, | ||
| ctx: { params: Promise<Record<string, string>> }, | ||
| ) => { | ||
| ) { | ||
| const params = await ctx.params; | ||
|
|
||
| const { | ||
| nextUrl: { searchParams }, | ||
| } = req; | ||
| const dataSourcesToUse = searchParams.getAll("datasources[]"); | ||
|
|
||
| const searchParamsToUse = { | ||
| const query = { | ||
| ...Object.fromEntries(searchParams), | ||
| datasources: searchParams.getAll("datasources[]"), | ||
| datasources: dataSourcesToUse, | ||
| }; | ||
|
|
||
| const paramsAndQueryValidation = GetPythFeedsDemoDataRequestSchema.safeParse({ | ||
| const validatedParams = GetPythFeedsDemoDataRequestSchema.safeParse({ | ||
| params, | ||
| searchParams: searchParamsToUse, | ||
| searchParams: query, | ||
| }); | ||
|
|
||
| if (paramsAndQueryValidation.error) { | ||
| if (validatedParams.error) { | ||
| return NextResponse.json( | ||
| { | ||
| error: paramsAndQueryValidation.error.format(), | ||
| }, | ||
| { error: validatedParams.error.format() }, | ||
| { status: 400 }, | ||
| ); | ||
| } | ||
|
|
||
| const { | ||
| params: { symbol: symbolToUse }, | ||
| searchParams: { datasources, startAt }, | ||
| } = paramsAndQueryValidation.data; | ||
| data: { | ||
| params: { symbol }, | ||
| searchParams: { datasources, startAt }, | ||
| }, | ||
| } = validatedParams; | ||
|
|
||
| const end = new Date(startAt); | ||
| // enforce the end time for this API, | ||
| // when called by a public user, | ||
| // only allows for 1 minute beyond the startAt. | ||
| end.setTime(end.getTime() + 1000 * 60); | ||
|
|
||
| try { | ||
| const { data, hasNext } = await fetchHistoricalDataForPythFeedsDemo({ | ||
| datasources, | ||
| startAt: startAt.toISOString(), | ||
| symbol: symbolToUse, | ||
| const response = await getNbboAndPythProHistoricalPricesForSymbol({ | ||
| end, | ||
| sources: datasources, | ||
| start: startAt, | ||
| symbol, | ||
| }); | ||
|
|
||
| return NextResponse.json({ | ||
| data, | ||
| hasNext, | ||
| }); | ||
| return NextResponse.json(response); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { | ||
| error: error instanceof Error ? error.message : String(error), | ||
| }, | ||
| { status: 500 }, | ||
| ); | ||
| if (error instanceof Error) { | ||
| return NextResponse.json( | ||
| { error: error.message || error }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
| return NextResponse.json({ error: String(error) }, { status: 500 }); | ||
| } | ||
| }; | ||
| } | ||
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
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
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
55 changes: 50 additions & 5 deletions
55
apps/insights/src/components/PythProDemoPriceChart/index.module.scss
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.