Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/components/CodeFrequencyChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useRef } from 'react';
import * as d3 from 'd3';

interface TimeSeriesPoint {
weekStart: string;
date: string;
additions: number;
deletions: number;
commitCount: number;
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function CodeFrequencyChart({ data }: Props) {

const parsed = data.map((d) => ({
...d,
date: new Date(d.weekStart + 'T00:00:00Z'),
date: new Date(d.date + 'T00:00:00Z'),
}));

const maxVal = d3.max(parsed, (d) => Math.max(d.additions, d.deletions)) ?? 1;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/github-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export interface DirectoryStats {

export interface CodeFrequencyData {
timeSeries: Array<{
weekStart: string;
date: string;
additions: number;
deletions: number;
commitCount: number;
Expand Down Expand Up @@ -462,7 +462,7 @@ export const api = {
let timeSeries = (freqData ?? [])
.filter((w) => w[1] !== 0 || w[2] !== 0)
.map((w) => ({
weekStart: new Date(w[0]! * 1000).toISOString().slice(0, 10),
date: new Date(w[0]! * 1000).toISOString().slice(0, 10),
additions: w[1] ?? 0,
deletions: Math.abs(w[2] ?? 0),
commitCount: 0,
Expand All @@ -473,7 +473,7 @@ export const api = {
const since = options.since ? new Date(options.since) : null;
const until = options.until ? new Date(options.until) : null;
timeSeries = timeSeries.filter((p) => {
const d = new Date(p.weekStart);
const d = new Date(p.date);
if (since && d < since) return false;
if (until && d > until) return false;
return true;
Expand All @@ -498,8 +498,8 @@ export const api = {
);

const period = {
since: timeSeries[0]?.weekStart ?? '',
until: timeSeries[timeSeries.length - 1]?.weekStart ?? '',
since: timeSeries[0]?.date ?? '',
until: timeSeries[timeSeries.length - 1]?.date ?? '',
};

return {
Expand Down