Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
chore(utils:processing): add function to generate data for recharts
Browse files Browse the repository at this point in the history
… radar chart

  ## what
  - add function to generate data for `recharts` radar chart

  ## how
  - loop through the object
    - add object to array
      - property `language`: string version of the language ID
      - property `count`: number of submissions of that language ID

  ## why
  - this will be used to generate the data needed for `recharts` radar
    chart to render

  ## where
  - ./src/utils/dataProcessing.ts

  ## usage
  • Loading branch information
Clumsy-Coder committed Jan 9, 2024
1 parent 5b236f7 commit 5809cea
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/utils/dataProcessing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Problem, ProblemVerdictMap, ProblemVerdictType } from "@/types";
import { Language, Problem, ProblemVerdictMap, ProblemVerdictType } from "@/types";
import {getResponseType as submissionLangType} from '@/app/api/submissions/language/[problemNum]/route'

export type processedProblemVerdictBarChartType = {
/**
Expand Down Expand Up @@ -44,3 +45,25 @@ export const processProblemNumBarChartData = (data: Problem) => {

return processedData
}

//////////////////////////////////////////////////////////////////////////////////////////////////

export type processedSubmissionLangType = {
language: string;
count: number;
}

export const processSubmissionLanguageRadarChart = (
data: submissionLangType,
): processedSubmissionLangType[] => {
const processedData: processedSubmissionLangType[] = [];

Object.entries(data).forEach(([key, value]) => {
processedData.push({
language: Language[key],
count: value,
});
});

return processedData;
};

0 comments on commit 5809cea

Please sign in to comment.