This commit is contained in:
bakhirev 2024-08-20 00:25:07 +03:00
parent 02e110fbc0
commit 11f80e167e
6 changed files with 78 additions and 23 deletions
build/static
src/ts
helpers/DataGrip/components
pages/Settings
store

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -4,7 +4,7 @@ const PROPERTIES = [
{ property: 'daysWorked', sort: 1 },
{ property: 'daysLosses', sort: -1 },
{ property: 'commits', sort: 1 },
{ property: 'tasks', sort: 1 },
{ property: 'tasks', sort: 1, isNeedTasks: true },
{ property: 'moneyAll', sort: 1 },
{ property: 'moneyWorked', sort: 1 },
{ property: 'moneyLosses', sort: -1 },
@ -12,21 +12,25 @@ const PROPERTIES = [
{
property: 'daysForTask',
sort: -1,
formatter: (user: any) => user.daysForTask && user.tasks.length ? user.daysForTask : Infinity,
isNeedTasks: true,
formatter: (user: any) => user.daysForTask,
},
{
property: 'commitsForTask',
sort: 1,
formatter: (user: any) => user.tasks.length ? (user.commits / user.tasks.length) : Infinity,
isNeedTasks: true,
formatter: (user: any) => user.commits / user.tasks.length,
},
{
property: 'linesForTask',
sort: -1,
formatter: (user: any) => user.tasks.length ? user.changesForTask : Infinity,
isNeedTasks: true,
formatter: (user: any) => user.changesForTask,
},
{
property: 'speedMaxTasks',
sort: 1,
isNeedTasks: true,
formatter: (user: any, timestamp: any) => timestamp.tasksByTimestampCounter.max,
},
{
@ -37,6 +41,7 @@ const PROPERTIES = [
{
property: 'moneyForTask',
sort: 1,
isNeedTasks: true,
formatter: (user: any) => user.moneyWorked / user.tasks.length,
},
{
@ -46,19 +51,23 @@ const PROPERTIES = [
},
];
function getValue(config: any, user: any, dataGripByTimestamp: any) {
const timestamp = dataGripByTimestamp.statisticByAuthor[user.author];
if (config.formatter) {
return config.formatter(user, timestamp);
}
function getValues(config: any, dataGripByTimestamp: any) {
return (user: any) => {
const timestamp = dataGripByTimestamp.statisticByAuthor[user.author];
if (config.isNeedTasks && !user.tasks.length) return NaN;
const value = user[config.property]
|| timestamp[config.property]
|| 0;
if (config.formatter) {
return config.formatter(user, timestamp);
}
return Array.isArray(value)
? value?.length
: value;
const value = user[config.property]
|| timestamp[config.property]
|| 0;
return Array.isArray(value)
? value?.length
: value;
};
}
export default class DataGripByScoring {
@ -83,7 +92,10 @@ export default class DataGripByScoring {
});
PROPERTIES.forEach((config: any) => {
const values = list.map((user: any) => getValue(config, user, dataGripByTimestamp));
const getValue = getValues(config, dataGripByTimestamp);
const values = list
.map(getValue)
.filter((value: number) => !isNaN(value));
const uniqValues = Array.from(new Set(values));
const places = uniqValues

View file

@ -0,0 +1,36 @@
import React from 'react';
import { observer } from 'mobx-react-lite';
import InputString from 'ts/components/UiKit/components/InputString';
import PageBox from 'ts/components/Page/Box';
import Title from 'ts/components/Title';
import formStore from '../store/Form';
const CommitFilters = observer((): React.ReactElement | null => {
return (
<>
<Title title="page.settings.commitFilters.title"/>
<PageBox>
<InputString
title="page.settings.commitFilters.author"
value={formStore.state?.commitFilters?.author}
placeholder=""
onChange={(value: string) => {
formStore.updateState('commitFilters.author', value);
}}
/>
<InputString
title="page.settings.commitFilters.message"
value={formStore.state?.commitFilters?.message}
placeholder=""
onChange={(value: string) => {
formStore.updateState('commitFilters.message', value);
}}
/>
</PageBox>
</>
);
});
export default CommitFilters;

View file

@ -63,6 +63,10 @@ export default function getEmptySettings(): IUserSetting {
pr: 'https://bitbucket.com/projects/assayo/repos/frontend/pull-requests/',
// https://gitlab.com/___/___/-/merge_requests/100500
},
// commitFilters: {
// author: '',
// message: '',
// },
employees: [],
};
}

View file

@ -13,6 +13,7 @@ import splashScreenStore from 'ts/components/SplashScreen/store';
import { applicationHasCustom } from 'ts/helpers/RPC';
import Depersonalized from 'ts/helpers/Depersonalized';
import userSettingsStore from './UserSettings';
import filtersInHeaderStore from './FiltersInHeader';
import viewNameStore, { ViewNameEnum } from './ViewName';
@ -105,13 +106,15 @@ class DataGripStore {
dataGrip.clear();
fileGrip.clear();
// const message = userSettingsStore.settings?.commitFilters?.message || '';
// const messageCheck = message ? new RegExp(message) : null;
const depersonalized = new Depersonalized();
this.commits.forEach((commit: ICommit | ISystemCommit) => {
if (commit.timestamp < filtersInHeaderStore.from
|| commit.timestamp > filtersInHeaderStore.to) return;
// if ((commit.message || '').indexOf('Deploying') !== -1) return;
// if ((commit.message || '').indexOf('Deployed') !== -1) return;
// if (messageCheck && messageCheck.test(commit.message || '')) return;
const localCommit = this.isDepersonalized
? depersonalized.getCommit(commit)