Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
makamekm committed Jun 16, 2020
1 parent b86d463 commit e33dcf5
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/app/Dashboard/Components/TrackerCompares.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { HeaderSection } from "~/components/Blocks/HeaderSection";
import { Dropdown } from "~/components/Dropdown/Dropdown";
import { TopPanel } from "./TopPanel";
import { ActiveStatsPanel } from "./ActiveStatsPanel";
import { LineActivities } from "~/components/Plots/LineActivities";

export const TrackerCompares = observer(() => {
const stateDashboard = React.useContext(DashboardService);
Expand Down Expand Up @@ -38,6 +39,23 @@ export const TrackerCompares = observer(() => {
limit={stateDashboard.limit}
/>
</div>
<div className="no-print-break border bg-white rounded-lg shadow-md text-gray-700 dark-mode:text-gray-300 dark-mode:bg-gray-900 dark-mode:border dark-mode:border-gray-800 dark-mode:shadow-inner">
<div className="flex items-center text-base w-full px-6 py-4">
<span>
User activities
<span className="text-xs ml-2 text-gray-400">#user</span>
</span>
</div>
<div className="p-4">
<LineActivities
maxValue={stateDashboard.maxValueDelay}
names={stateFavourite.groupped.user.map(({ name }) => name)}
height={250}
limit={stateDashboard.limit}
data={stateFavourite.userCompareStats || []}
/>
</div>
</div>
</>
)}

Expand Down Expand Up @@ -105,6 +123,23 @@ export const TrackerCompares = observer(() => {
limit={stateDashboard.limit}
/>
</div>
<div className="no-print-break border bg-white rounded-lg shadow-md text-gray-700 dark-mode:text-gray-300 dark-mode:bg-gray-900 dark-mode:border dark-mode:border-gray-800 dark-mode:shadow-inner">
<div className="flex items-center text-base w-full px-6 py-4">
<span>
Team activities
<span className="text-xs ml-2 text-gray-400">#team</span>
</span>
</div>
<div className="p-4">
<LineActivities
maxValue={stateDashboard.maxValueDelay}
names={stateFavourite.groupped.team.map(({ name }) => name)}
height={250}
limit={stateDashboard.limit}
data={stateFavourite.teamCompareStats || []}
/>
</div>
</div>
</>
)}

Expand Down Expand Up @@ -172,6 +207,25 @@ export const TrackerCompares = observer(() => {
limit={stateDashboard.limit}
/>
</div>
<div className="no-print-break border bg-white rounded-lg shadow-md text-gray-700 dark-mode:text-gray-300 dark-mode:bg-gray-900 dark-mode:border dark-mode:border-gray-800 dark-mode:shadow-inner">
<div className="flex items-center text-base w-full px-6 py-4">
<span>
Repository activities
<span className="text-xs ml-2 text-gray-400">#repository</span>
</span>
</div>
<div className="p-4">
<LineActivities
maxValue={stateDashboard.maxValueDelay}
names={stateFavourite.groupped.repository.map(
({ name }) => name
)}
height={250}
limit={stateDashboard.limit}
data={stateFavourite.repositoryCompareStats || []}
/>
</div>
</div>
</>
)}

Expand Down
6 changes: 6 additions & 0 deletions src/app/Dashboard/DashboardService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ export const DashboardService = createService<DashboardState>(
data = state.teamStats[state.name];
} else if (state.mode === "user") {
data = state.userStats[state.name];
} else {
data = [
...Object.values(state.repositoriesStats).flatMap((s) => s),
...Object.values(state.teamStats).flatMap((s) => s),
...Object.values(state.userStats).flatMap((s) => s),
];
}
let max = 0;
let total = 0;
Expand Down
84 changes: 84 additions & 0 deletions src/app/Dashboard/FavouriteService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ export interface FavouriteState {
name: string;
}[];
};
teamCompareStats: ({
day: string;
} & {
[name: string]: number;
})[];
userCompareStats: ({
day: string;
} & {
[name: string]: number;
})[];
repositoryCompareStats: ({
day: string;
} & {
[name: string]: number;
})[];
}

export const FavouriteService = createService<FavouriteState>(
Expand All @@ -73,6 +88,75 @@ export const FavouriteService = createService<FavouriteState>(
get groupped() {
return state.trackers ? groupBy(state.trackers, "type") : {};
},
get repositoryCompareStats() {
const result: {
[day: string]: {
day: string;
} & any;
} = {};
state.groupped.repository.forEach(({ name }) => {
const date = state.service.repositoriesStats[name];
if (date) {
date.forEach((data) => {
if (!result[data.day]) {
result[data.day] = {
day: data.day,
[name]: data.value,
};
} else {
result[data.day][name] = data.value;
}
});
}
});
return Object.values(result);
},
get userCompareStats() {
const result: {
[day: string]: {
day: string;
} & any;
} = {};
state.groupped.user.forEach(({ name }) => {
const date = state.service.userStats[name];
if (date) {
date.forEach((data) => {
if (!result[data.day]) {
result[data.day] = {
day: data.day,
[name]: data.value,
};
} else {
result[data.day][name] = data.value;
}
});
}
});
return Object.values(result);
},
get teamCompareStats() {
const result: {
[day: string]: {
day: string;
} & any;
} = {};
state.groupped.team.forEach(({ name }) => {
const date = state.service.teamStats[name];
if (date) {
date.forEach((data) => {
if (!result[data.day]) {
result[data.day] = {
day: data.day,
[name]: data.value,
};
} else {
result[data.day][name] = data.value;
}
});
}
});
return Object.values(result);
},
get activeUsers() {
return (
state.groupped.user?.reduce((a, { name }) => {
Expand Down
1 change: 1 addition & 0 deletions src/app/Dashboard/RepositoryDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export const RepositoryDashboard = observer(() => {
<List height={"250px"} />
) : (
<LineActivities
maxValue={state.maxValueDelay}
names={state.teams}
height={250}
limit={state.limit}
Expand Down
1 change: 1 addition & 0 deletions src/app/Dashboard/TeamDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export const TeamDashboard = observer(() => {
<List height={"250px"} />
) : (
<LineActivities
maxValue={state.maxValueDelay}
names={state.repositories}
height={250}
limit={state.limit}
Expand Down

0 comments on commit e33dcf5

Please sign in to comment.