diff --git a/contexts/chart-context.tsx b/contexts/chart-context.tsx index c5ce8a9..15787cd 100644 --- a/contexts/chart-context.tsx +++ b/contexts/chart-context.tsx @@ -42,7 +42,6 @@ export const ChartProvider: FC = ({ children }) => { metricConfigs?.views[0].view || 'random' ); - // Cycle through views every X seconds useEffect(() => { if (!metricConfigs) return; const id = setInterval(() => { @@ -57,19 +56,17 @@ export const ChartProvider: FC = ({ children }) => { return () => clearInterval(id); }, [displayType, metricConfigs]); - // Effect to remove objects from 'changed' after 5 seconds useEffect(() => { const intervalId = setInterval(() => { const now = Date.now(); setChanged((prevChanged) => prevChanged.filter((item) => now - item.timestamp < 3000) ); - }, 1000); // Check every second + }, 1000); return () => clearInterval(intervalId); }, []); - // Example function to add a change const addChange = (id: string, cause?: string) => { setChanged((prevChanged) => [ ...prevChanged, diff --git a/server/github/syncs.ts b/server/github/syncs.ts index 26c7449..22b22d6 100644 --- a/server/github/syncs.ts +++ b/server/github/syncs.ts @@ -16,7 +16,7 @@ export const validateGithubProjectInputs = (project: Repository) => { export const projectSync = async (project: Repository) => { const db = admin.database(); const userRef = db.ref( - `data/team-projects/sensors/github/values/${project.id}` + `data/team-projects/sensors/github/value/${project.id}` ); const snapshot = await userRef.once('value'); diff --git a/types/firebase.ts b/types/firebase.ts index 42c9638..b8e5be3 100644 --- a/types/firebase.ts +++ b/types/firebase.ts @@ -47,7 +47,7 @@ export interface DisplayDataBase { title: string; description: string; sensors: { - [key: `sensor-${number}`]: { + [key: string]: { title: string; value: T; }; diff --git a/utils/general.ts b/utils/general.ts index 3201910..5c5fdf6 100644 --- a/utils/general.ts +++ b/utils/general.ts @@ -14,11 +14,11 @@ export const formatRTDBData = >( displayType: DisplayType ): T | null => { if (!data) return null; - + console.log('raw Data', data); const typedData = data as DisplayDataMapping; const formattedSensors = Object.keys(typedData.sensors).map((sensorKey) => { - const sensor = typedData.sensors[sensorKey as `sensor-${number}`]; + const sensor = typedData.sensors[sensorKey as string]; const value = typeof sensor.value === 'object' && !Array.isArray(sensor.value) @@ -31,7 +31,7 @@ export const formatRTDBData = >( : sensor.value; return { - id: sensorKey, // use the sensor key as the id + id: sensorKey, title: sensor.title, value, }; @@ -43,6 +43,8 @@ export const formatRTDBData = >( sensors: formattedSensors, } as T; + console.log('Formatted Data', formattedData); + return formattedData; }; @@ -120,7 +122,7 @@ export const viewTeamPositions = ({ const diagLength = space - margin * 2; - const outerOffset = 50; + const outerOffset = 50; const half = Math.ceil(members.length / 2); const positiveDiagonalMembers = members.slice(0, half);