Skip to content

Commit

Permalink
Merge branch 'main' into debug-1
Browse files Browse the repository at this point in the history
  • Loading branch information
d4x1 authored Sep 19, 2024
2 parents c6b75d6 + b363355 commit 4c158be
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 37 deletions.
7 changes: 6 additions & 1 deletion backend/helpers/pluginhelper/api/graphql_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/json"
"net/http"
"reflect"
"strings"
"time"

"github.com/apache/incubator-devlake/core/dal"
Expand Down Expand Up @@ -276,7 +277,11 @@ func (collector *GraphqlCollector) fetchAsync(reqData *GraphqlRequestData, handl
if len(dataErrors) > 0 {
if !collector.args.IgnoreQueryErrors {
for _, dataError := range dataErrors {
collector.checkError(errors.Default.Wrap(dataError, `graphql query got error`))
if strings.Contains(dataError.Error(), "Could not resolve to an Issue") {
collector.args.Ctx.GetLogger().Warn(nil, "Issue may have been transferred.")
} else {
collector.checkError(errors.Default.Wrap(dataError, `graphql query got error`))
}
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion config-ui/src/api/blueprint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const remove = (id: ID) => request(`/blueprints/${id}`, { method: 'delete

export const update = (id: ID, data: Partial<IBlueprint>) => request(`/blueprints/${id}`, { method: 'patch', data });

export const pipelines = (id: ID) => request(`/blueprints/${id}/pipelines`);
export const pipelines = (id: ID, data?: Pagination) => request(`/blueprints/${id}/pipelines`, { data });

type TriggerQuery = {
skipCollectors?: boolean;
Expand Down
5 changes: 1 addition & 4 deletions config-ui/src/api/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@ export const remove = (name: string) =>
export const update = (name: string, data: Pick<IProject, 'name' | 'description' | 'metrics'>) =>
request(`/projects/${encodeURIComponent(name)}`, {
method: 'patch',
data: {
...data,
name: encodeURIComponent(data.name),
},
data,
});
42 changes: 18 additions & 24 deletions config-ui/src/routes/blueprint/detail/status-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import { Card, Modal, Switch, Button, Tooltip, Dropdown, Flex, Space } from 'ant
import API from '@/api';
import { Message } from '@/components';
import { getCron } from '@/config';
import { useAutoRefresh } from '@/hooks';
import { useRefreshData } from '@/hooks';
import { PipelineInfo, PipelineTasks, PipelineTable } from '@/routes/pipeline';
import { IBlueprint, IPipeline, IPipelineStatus } from '@/types';
import { IBlueprint } from '@/types';
import { formatTime, operator } from '@/utils';

import { FromEnum } from '../types';
Expand All @@ -40,32 +40,17 @@ interface Props {

export const StatusPanel = ({ from, blueprint, pipelineId, onRefresh }: Props) => {
const [type, setType] = useState<'delete' | 'fullSync'>();
const [page, setPage] = useState(1);
const [pageSize] = useState(10);
const [operating, setOperating] = useState(false);

const navigate = useNavigate();

const cron = useMemo(() => getCron(blueprint.isManual, blueprint.cronConfig), [blueprint]);

const { loading, data } = useAutoRefresh<IPipeline[]>(
async () => {
const res = await API.blueprint.pipelines(blueprint.id);
return res.pipelines;
},
[],
{
cancel: (data) =>
!!(
data &&
data.every((it) =>
[
IPipelineStatus.COMPLETED,
IPipelineStatus.PARTIAL,
IPipelineStatus.CANCELLED,
IPipelineStatus.FAILED,
].includes(it.status),
)
),
},
const { ready, data } = useRefreshData(
() => API.blueprint.pipelines(blueprint.id, { page, pageSize }),
[blueprint.id, page, pageSize],
);

const handleResetType = () => {
Expand Down Expand Up @@ -209,10 +194,19 @@ export const StatusPanel = ({ from, blueprint, pipelineId, onRefresh }: Props) =

<h3>Historical Pipelines</h3>

{!data?.length ? (
{!data?.count ? (
<Card>There are no historical runs associated with this blueprint.</Card>
) : (
<PipelineTable loading={loading} dataSource={data} />
<PipelineTable
loading={!ready}
dataSource={data.pipelines}
pagination={{
current: page,
pageSize,
total: data.count,
onChange: setPage,
}}
/>
)}
</Space>

Expand Down
26 changes: 24 additions & 2 deletions config-ui/src/routes/pipeline/components/duration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ import dayjs from 'dayjs';

import { IPipelineStatus } from '@/types';

const duration = (minute: number) => {
if (minute < 1) {
return '1m';
}

if (minute < 60) {
return `${Math.ceil(minute / 60)}m`;
}

if (minute < 60 * 24) {
const hours = Math.floor(minute / 60);
const minutes = minute - hours * 60;
return `${hours}h${minutes}m`;
}

const days = Math.floor(minute / (60 * 24));
const hours = Math.floor((minute - days * 60 * 24) / 60);
const minutes = minute - days * 60 * 24 - hours * 60;

return `${days}d${hours}h${minutes}m`;
};

interface Props {
status: IPipelineStatus;
beganAt: string | null;
Expand All @@ -36,12 +58,12 @@ export const PipelineDuration = ({ status, beganAt, finishedAt }: Props) => {
status,
)
) {
return <span>{dayjs(beganAt).toNow(true)}</span>;
return <span>{duration(dayjs(beganAt).diff(dayjs(), 'm'))}</span>;
}

if (!finishedAt) {
return <span>-</span>;
}

return <span>{dayjs(beganAt).from(finishedAt, true)}</span>;
return <span>{duration(dayjs(beganAt).diff(dayjs(finishedAt), 'm'))}</span>;
};
2 changes: 1 addition & 1 deletion config-ui/src/routes/pipeline/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Props {
dataSource: IPipeline[];
pagination?: {
total: number;
page: number;
current: number;
pageSize: number;
onChange: (page: number) => void;
};
Expand Down
4 changes: 2 additions & 2 deletions config-ui/src/routes/pipeline/pipelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const Pipelines = () => {
loading={!ready}
dataSource={dataSource}
pagination={{
total,
page,
current: page,
pageSize,
total,
onChange: setPage,
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion config-ui/src/routes/project/additional-settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const ProjectAdditionalSettings = () => {

if (success) {
setVersion((v) => v + 1);
navigate(`/projects/${encodeURIComponent(pname)}`, {
navigate(`/projects/${encodeURIComponent(name)}`, {
state: {
tabId: 'settings',
},
Expand Down
2 changes: 1 addition & 1 deletion config-ui/src/routes/project/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const ProjectLayout = () => {
<p>
{breadcrumbs(paths).map((b, i) => (
<span key={b.path}>
{i !== paths.length - 2 ? <Link to={b.path}>{b.name}</Link> : <span>{b.name}</span>}
{i !== paths.length - 2 ? <Link to={b.path}>{b.name}</Link> : <span>{decodeURIComponent(b.name)}</span>}
<span> / </span>
</span>
))}
Expand Down

0 comments on commit 4c158be

Please sign in to comment.