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,
className,
}: 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) {
return (
@ -67,7 +68,7 @@ function LineChart({
}
LineChart.defaultProps = {
value: 0,
value: undefined,
details: undefined,
className: '',
};

View file

@ -1,5 +1,8 @@
import ICommit from 'ts/interfaces/Commit';
import IHashMap from 'ts/interfaces/HashMap';
import { ONE_DAY } from 'ts/helpers/formatter';
import settingsStore from 'ts/store/Settings';
import userSettings from 'ts/store/UserSettings';
@ -139,7 +142,7 @@ export default class DataGripByAuthor {
const HOLIDAYS = 118 + 22; // праздники + выходные + отпуск
const WORK_AND_HOLIDAYS = (HOLIDAYS / (365 - HOLIDAYS));
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 = {
staff: [],
@ -154,7 +157,7 @@ export default class DataGripByAuthor {
const to = dot.lastCommit.milliseconds;
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 middleSalaryInMonth = userSettings.getMiddleSalaryInMonth(dot.author, from, to);

View file

@ -1,12 +1,12 @@
import { COMMIT_TYPE, ISystemCommit } from 'ts/interfaces/Commit';
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) {
const to = toObject.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;
}

View file

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

View file

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

View file

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

View file

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

View file

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