This commit is contained in:
Бахирев 2024-05-24 12:35:47 +03:00
parent 5383c0dd6d
commit 721e3f2e09
9 changed files with 49411 additions and 12326 deletions

File diff suppressed because it is too large Load diff

View file

@ -21,9 +21,10 @@ function LineChart({
details, details,
className, className,
}: ILineChartProps): React.ReactElement | null { }: ILineChartProps): React.ReactElement | null {
if (!value) return null; if (value === 0) return null;
let width = Math.round((value ?? 100) * (100 / options.max)); let width = Math.round((value || 100) * (100 / options.max));
if (width < 1) return null;
if (!details) { if (!details) {
return ( return (
@ -67,7 +68,7 @@ function LineChart({
} }
LineChart.defaultProps = { LineChart.defaultProps = {
value: 0, value: undefined,
details: undefined, details: undefined,
className: '', className: '',
}; };

View file

@ -1,5 +1,8 @@
import ICommit from 'ts/interfaces/Commit'; import ICommit from 'ts/interfaces/Commit';
import IHashMap from 'ts/interfaces/HashMap'; import IHashMap from 'ts/interfaces/HashMap';
import { ONE_DAY } from 'ts/helpers/formatter';
import settingsStore from 'ts/store/Settings'; import settingsStore from 'ts/store/Settings';
import userSettings from 'ts/store/UserSettings'; import userSettings from 'ts/store/UserSettings';
@ -139,7 +142,7 @@ export default class DataGripByAuthor {
const HOLIDAYS = 118 + 22; // праздники + выходные + отпуск const HOLIDAYS = 118 + 22; // праздники + выходные + отпуск
const WORK_AND_HOLIDAYS = (HOLIDAYS / (365 - HOLIDAYS)); const WORK_AND_HOLIDAYS = (HOLIDAYS / (365 - HOLIDAYS));
const lastCommit = settingsStore.commits[settingsStore.commits.length - 1]; const lastCommit = settingsStore.commits[settingsStore.commits.length - 1];
const dismissedLimit = lastCommit?.milliseconds - (settingsStore.ONE_DAY * 32); const dismissedLimit = lastCommit?.milliseconds - 32 * ONE_DAY;
this.employment = { this.employment = {
staff: [], staff: [],
@ -154,7 +157,7 @@ export default class DataGripByAuthor {
const to = dot.lastCommit.milliseconds; const to = dot.lastCommit.milliseconds;
const workDays = Object.keys(dot.days).length; const workDays = Object.keys(dot.days).length;
const allDaysInProject = Math.ceil((to - from) / settingsStore.ONE_DAY); const allDaysInProject = Math.ceil((to - from) / ONE_DAY);
const lazyDays = Math.floor((allDaysInProject * WORK_AND_HOLIDAYS) - workDays) + 1; const lazyDays = Math.floor((allDaysInProject * WORK_AND_HOLIDAYS) - workDays) + 1;
const middleSalaryInMonth = userSettings.getMiddleSalaryInMonth(dot.author, from, to); const middleSalaryInMonth = userSettings.getMiddleSalaryInMonth(dot.author, from, to);

View file

@ -1,12 +1,12 @@
import { COMMIT_TYPE, ISystemCommit } from 'ts/interfaces/Commit'; import { COMMIT_TYPE, ISystemCommit } from 'ts/interfaces/Commit';
import IHashMap from 'ts/interfaces/HashMap'; import IHashMap from 'ts/interfaces/HashMap';
import settingsStore from 'ts/store/Settings'; import { ONE_DAY } from 'ts/helpers/formatter';
function getRangeInDay(fromObject: any, toObject: any, gap?: number) { function getRangeInDay(fromObject: any, toObject: any, gap?: number) {
const to = toObject.milliseconds; const to = toObject.milliseconds;
const from = fromObject.milliseconds; const from = fromObject.milliseconds;
const delay = ((to - from) / settingsStore.ONE_DAY) - (gap || 0); const delay = ((to - from) / ONE_DAY) - (gap || 0);
return to !== from && delay > 0 ? delay : 0; return to !== from && delay > 0 ? delay : 0;
} }

View file

@ -1,6 +1,7 @@
import ICommit from 'ts/interfaces/Commit'; import ICommit from 'ts/interfaces/Commit';
import IHashMap from 'ts/interfaces/HashMap'; import IHashMap from 'ts/interfaces/HashMap';
import settingsStore from 'ts/store/Settings';
import { ONE_DAY } from 'ts/helpers/formatter';
export default class DataGripByTasks { export default class DataGripByTasks {
commits: IHashMap<ICommit[]> = {}; commits: IHashMap<ICommit[]> = {};
@ -69,7 +70,7 @@ export default class DataGripByTasks {
const comments = Array.from(messages).join(', '); const comments = Array.from(messages).join(', ');
const to = lastCommit.milliseconds; const to = lastCommit.milliseconds;
const daysInWork = Math.ceil((to - from) / settingsStore.ONE_DAY) + 1; const daysInWork = Math.ceil((to - from) / ONE_DAY) + 1;
const longTaskByAuthor = this.longTaskByAuthor[shortInfo.author]; const longTaskByAuthor = this.longTaskByAuthor[shortInfo.author];
if (!longTaskByAuthor || longTaskByAuthor < daysInWork) { if (!longTaskByAuthor || longTaskByAuthor < daysInWork) {

View file

@ -1,6 +1,7 @@
import ICommit, { IFileChange, ISystemCommit } from 'ts/interfaces/Commit'; import ICommit, { IFileChange, ISystemCommit } from 'ts/interfaces/Commit';
import IHashMap from 'ts/interfaces/HashMap'; import IHashMap from 'ts/interfaces/HashMap';
import { ONE_DAY, ONE_WEEK } from 'ts/helpers/formatter';
import getCommitInfo from './getCommitInfo'; import getCommitInfo from './getCommitInfo';
import { getInfoFromPath, getNumStatInfo, getRawInfo } from './getFileChanges'; import { getInfoFromPath, getNumStatInfo, getRawInfo } from './getFileChanges';
@ -12,6 +13,8 @@ export default function Parser(report: string[]) {
let files: IHashMap<IFileChange> = {}; let files: IHashMap<IFileChange> = {};
let fileChanges: IFileChange | null = null; let fileChanges: IFileChange | null = null;
let firstMonday = 0;
for (let i = 0, l = report.length; i < l; i += 1) { for (let i = 0, l = report.length; i < l; i += 1) {
const message = report[i]; const message = report[i];
if (!message) continue; if (!message) continue;
@ -39,7 +42,14 @@ export default function Parser(report: string[]) {
if (commit) commit.fileChanges = Object.values(files); if (commit) commit.fileChanges = Object.values(files);
files = {}; files = {};
commit = getCommitInfo(message); commit = getCommitInfo(message);
commit.week = 1;
const monday = commit.milliseconds - commit.day * ONE_DAY;
if (firstMonday) {
commit.week = Math.floor((firstMonday - monday) / ONE_WEEK);
} else {
firstMonday = monday;
}
commits.push(commit); commits.push(commit);
} }
} }

View file

@ -1,5 +1,9 @@
import userSettings from 'ts/store/UserSettings'; import userSettings from 'ts/store/UserSettings';
export const ONE_DAY = 24 * 60 * 60 * 1000;
export const ONE_WEEK = 7 * ONE_DAY;
export function getLangPrefix() { export function getLangPrefix() {
// @ts-ignore // @ts-ignore
const code = window?.localization?.language || 'ru'; const code = window?.localization?.language || 'ru';
@ -15,7 +19,6 @@ export function getLangPrefix() {
}[code] || 'ru-RU'; }[code] || 'ru-RU';
} }
const ONE_DAY = 24 * 60 * 60 * 1000;
const TIMESTAMP = [ const TIMESTAMP = [
ONE_DAY * 4, ONE_DAY * 4,
ONE_DAY * 5, ONE_DAY * 5,
@ -25,7 +28,6 @@ const TIMESTAMP = [
ONE_DAY * 2, ONE_DAY * 2,
ONE_DAY * 3, ONE_DAY * 3,
]; ];
export function getDayName(index:number, weekday: 'long' | 'short') { export function getDayName(index:number, weekday: 'long' | 'short') {
const date = new Date(TIMESTAMP[index]); const date = new Date(TIMESTAMP[index]);
return date.toLocaleString(getLangPrefix(), { weekday: weekday || 'long' }); return date.toLocaleString(getLangPrefix(), { weekday: weekday || 'long' });

View file

@ -79,6 +79,8 @@ const Top = observer((): React.ReactElement => {
<> <>
<Title title="Скорость закрытия задач"/> <Title title="Скорость закрытия задач"/>
<Races tracks={tracks} /> <Races tracks={tracks} />
{'City builder - тепловая карта'}
{'Небоскребы вверх ввиде графика'}
<Title title="Максимальная длинна подписи коммита"/> <Title title="Максимальная длинна подписи коммита"/>
<PageWrapper template="table"> <PageWrapper template="table">

View file

@ -1,4 +1,6 @@
import { makeObservable, observable, action } from 'mobx'; import { makeObservable, observable, action } from 'mobx';
import { ONE_DAY } from 'ts/helpers/formatter';
import ICommit from '../interfaces/Commit'; import ICommit from '../interfaces/Commit';
import dataGripStore from './DataGrip'; import dataGripStore from './DataGrip';
@ -7,7 +9,6 @@ interface ISettingsStore {
defaultFrom: string; defaultFrom: string;
defaultTo: string; defaultTo: string;
TODAY: Date; TODAY: Date;
ONE_DAY: number;
from: string; from: string;
to: string; to: string;
minCommits: number; minCommits: number;
@ -33,8 +34,6 @@ class SettingsStore implements ISettingsStore {
TODAY: Date = new Date(); TODAY: Date = new Date();
ONE_DAY: number = 24 * 60 * 60 * 1000;
from: string = ''; from: string = '';
to: string = ''; to: string = '';
@ -61,7 +60,6 @@ class SettingsStore implements ISettingsStore {
defaultFrom: observable, defaultFrom: observable,
defaultTo: observable, defaultTo: observable,
TODAY: observable, TODAY: observable,
ONE_DAY: observable,
from: observable, from: observable,
to: observable, to: observable,
minCommits: observable, minCommits: observable,
@ -117,7 +115,7 @@ class SettingsStore implements ISettingsStore {
}[type]; }[type];
this.from = count this.from = count
? (new Date(this.TODAY.getTime() - this.ONE_DAY * count)).toISOString().split('T')[0] ? (new Date(this.TODAY.getTime() - ONE_DAY * count)).toISOString().split('T')[0]
: this.defaultFrom; : this.defaultFrom;
this.to = this.defaultTo; this.to = this.defaultTo;