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

demo: Linde demo #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NOTEHUB_PROJECT_ID=app:[NOTEHUB_PROJECT_ID]
NOTEHUB_PROJECT_ID=[NOTEHUB_PROJECT_ID]
NOTEHUB_TOKEN=[NOTEHUB_TOKEN]
10 changes: 4 additions & 6 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useEffect, useMemo, useState } from "react";
import Head from "next/head";
import dynamic from "next/dynamic";
import { GetStaticProps } from "next";
import { GetServerSideProps } from "next";
import dayjs from "dayjs";
import { fetchNotecardData } from "../src/lib/notecardData";
import TempChart from "../src/components/TempChart";
Expand Down Expand Up @@ -205,7 +205,7 @@ export default function Home({ data }: { data: dataProps[] }) {
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<h1 className={styles.title}>React Blues Wireless Asset Tracker</h1>
<h1 className={styles.title}>Blues Wireless Asset Tracker Demo</h1>
<div className={styles.grid}>
<TempChart tempData={tempData} />
</div>
Expand All @@ -230,9 +230,7 @@ export default function Home({ data }: { data: dataProps[] }) {
}

export const getStaticProps: GetStaticProps = async () => {
/* we're able to use Nextjs's ISR (incremental static regneration)
revalidate functionality to re-fetch updated map coords and re-render one a regular interval */
const data = await fetchNotecardData();
const data = await fetchNotecardData(1647097837);

return { props: { data }, revalidate: 120 };
return { props: { data } };
};
11 changes: 9 additions & 2 deletions src/lib/notecardData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ export async function fetchNotecardData(startDate?: number) {
});
const eventData = await res.json();
eventArray = eventData.events;
// console.log(eventData);

while (eventData.has_more) {
while (
eventData.has_more
// && eventData.events[0].captured < "2021-12-20T02:23:09Z"
) {
const res = await fetch(`${baseUrl}?since=${eventData.through}`, {
headers: headers,
});
Expand All @@ -38,7 +42,10 @@ export async function fetchNotecardData(startDate?: number) {
}

const filteredEvents = eventArray.filter(
(event: dataProps) => event.file === "_track.qo"
(event: dataProps) =>
// hardcoding an end date to limit amount of data displaying
event.file === "_track.qo"
// && event.captured < "2021-12-20T02:23:09Z"
);

return filteredEvents;
Expand Down