Skip to content

Commit

Permalink
feat: Field adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
liukaiming-alipay committed Jan 9, 2025
1 parent 354fca1 commit a887aa3
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 93 deletions.
2 changes: 1 addition & 1 deletion osgraph-web/src/components/extend-params/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ExtendParams: React.FC<Props> = ({
required={false}
rules={[{ required: true, message: "请输入" }]}
>
<InputNumber style={{width: 'auto'}} min={0} />
<InputNumber style={{ width: "auto" }} min={3} max={50} />
</Item>
);
case "date":
Expand Down
2 changes: 1 addition & 1 deletion osgraph-web/src/components/project-search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const ProjectSearch: React.FC<{
});
}
setState((draft) => {
draft.querySource = item.data.querySource;
draft.querySource = `github_${item.data.input_types}`;
draft.templateParameterList = item.data.templateParameterList;
draft.templateId = item.data.id;
draft.projectValue = value;
Expand Down
56 changes: 28 additions & 28 deletions osgraph-web/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,34 +205,34 @@ export const GRAPH_EXTEND_PARAMS_MAP = {
"start-time",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_CONTRIBUTE] + "end"]:
"end-time",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_CONTRIBUTE] + "contrib-limit"]:
"contribution-limit",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_CONTRIBUTE] + "repo-limit"]:
"repo-limit",

/** REPO_ECOLOGY */
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_ECOLOGY] + "repo-limit"]:
"topn",
"repo-limit",

/** REPO_COMMUNITY */
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_COMMUNITY] + "country-limit"]:
"country-topn",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_COMMUNITY] + "org-limit"]:
"company-topn",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_COMMUNITY] + "contrib-limit"]:
"developer-topn",
"country-limit",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_COMMUNITY] + "company-limit"]:
"company-limit",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.REPO_COMMUNITY] + "user-limit"]:
"user-limit",

/** ACCT_ACTIVITY */
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.ACCT_ACTIVITY] + "repo-limit"]:
"topn",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.ACCT_ACTIVITY] + "user-limit"]:
"user-limit",

/** ACCT_PARTNER */
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.ACCT_PARTNER] + "partner-limit"]:
"topn",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.ACCT_PARTNER] + "user-limit"]:
"user-limit",

/** ACCT_INTEREST */
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.ACCT_INTEREST] + "repo-limit"]:
"githubrepo-topn",
"repo-limit",
[GRAPH_SHARE_LINK_MAP[GRAPH_TEMPLATE_ENUM.ACCT_INTEREST] + "topic-limit"]:
"topic-topn",
"topic-limit",
};

export const GRAPH_EXTEND_PARAMS_FORM = {
Expand All @@ -249,67 +249,67 @@ export const GRAPH_EXTEND_PARAMS_FORM = {
},
{
type: "inputNumber",
key: "contrib-limit",
key: "repo-limit",
label: "params.contrib",
defaultValue: 50,
defaultValue: 10,
},
],
[GRAPH_TEMPLATE_ENUM.REPO_ECOLOGY]: [
{
type: "inputNumber",
key: "repo-limit",
label: "params.repo",
defaultValue: 50,
defaultValue: 10,
},
],
[GRAPH_TEMPLATE_ENUM.REPO_COMMUNITY]: [
{
type: "inputNumber",
key: "country-limit",
label: "params.country",
defaultValue: 50,
defaultValue: 3,
},
{
type: "inputNumber",
key: "org-limit",
key: "company-limit",
label: "params.org",
defaultValue: 50,
defaultValue: 3,
},
{
type: "inputNumber",
key: "contrib-limit",
key: "user-limit",
label: "params.contrib",
defaultValue: 50,
defaultValue: 10,
},
],
[GRAPH_TEMPLATE_ENUM.ACCT_ACTIVITY]: [
{
type: "inputNumber",
key: "repo-limit",
key: "user-limit",
label: "params.repo",
defaultValue: 50,
defaultValue: 10,
},
],
[GRAPH_TEMPLATE_ENUM.ACCT_PARTNER]: [
{
type: "inputNumber",
key: "partner-limit",
key: "user-limit",
label: "params.partner",
defaultValue: 50,
defaultValue: 10,
},
],
[GRAPH_TEMPLATE_ENUM.ACCT_INTEREST]: [
{
type: "inputNumber",
key: "repo-limit",
label: "params.repo",
defaultValue: 50,
defaultValue: 10,
},
{
type: "inputNumber",
key: "topic-limit",
label: "params.topic",
defaultValue: 50,
defaultValue: 10,
},
],
};
Expand Down
54 changes: 23 additions & 31 deletions osgraph-web/src/result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,66 +146,58 @@ export default () => {
const generateShareLink = (shareInfo: Record<string, any>) => {
setState((draft) => {
draft.locationState = shareInfo;
const { templateId, warehouseName, querySource } = shareInfo;
const { templateId, warehouseName } = shareInfo;
const projectValueFormat = GRAPH_SHARE_LINK_MAP[templateId];
const searchPath = window.location.search
? window.location.search + "&"
: "?";
const host = window.location.origin;

/** repo contribute */
if (templateId === GRAPH_TEMPLATE_ENUM.REPO_CONTRIBUTE) {
const search = `contribution-limit=${shareInfo?.["contribution-limit"]}&start-time=${shareInfo["start-time"]}&end-time=${shareInfo["end-time"]}`;
draft.shareLink = `${
window.location.origin
}/graphs/${projectValueFormat}/github/${warehouseName}${
const search = `repo-limit=${shareInfo?.["repo-limit"]}&start-time=${shareInfo["start-time"]}&end-time=${shareInfo["end-time"]}`;
draft.shareLink = `${host}/graphs/${projectValueFormat}/github/${warehouseName}${
searchPath + search
}`;
draft.pngShareLink = `${window.location.origin}/png/graphs/${
draft.pngShareLink = `${host}/png/graphs/${
GRAPH_TEMPLATE_TYPE_MAP[GRAPH_SHARE_LINK_MAP[templateId]]
}/${GRAPH_QUERY_SOURCE_MAP[querySource]}/${warehouseName}?${search}`;
}/github/${warehouseName}?${search}`;
} else if (templateId === GRAPH_TEMPLATE_ENUM.REPO_ECOLOGY) {
/** repo ecology */
const { topn } = shareInfo;
draft.shareLink = `${window.location.origin}/graphs/${projectValueFormat}/github/${warehouseName}${searchPath}topn=${topn}`;
draft.pngShareLink = `${window.location.origin}/png/graphs/${
draft.shareLink = `${host}/graphs/${projectValueFormat}/github/${warehouseName}${searchPath}repo-limit=${shareInfo?.["repo-limit"]}`;
draft.pngShareLink = `${host}/png/graphs/${
GRAPH_TEMPLATE_TYPE_MAP[GRAPH_SHARE_LINK_MAP[templateId]]
}/${GRAPH_QUERY_SOURCE_MAP[querySource]}/${warehouseName}?topn=${topn}`;
}/github/${warehouseName}?repo-limit=${shareInfo?.["repo-limit"]}`;
} else if (templateId === GRAPH_TEMPLATE_ENUM.REPO_COMMUNITY) {
const search = `country-topn=${shareInfo["country-topn"]}&company-topn=${shareInfo["company-topn"]}&developer-topn=${shareInfo["developer-topn"]}`;
const search = `country-limit=${shareInfo["country-limit"]}&company-limit=${shareInfo["company-limit"]}&user-limit=${shareInfo["user-limit"]}`;
/** repo community */
draft.shareLink = `${
window.location.origin
}/graphs/${projectValueFormat}/github/${warehouseName}${
draft.shareLink = `${host}/graphs/${projectValueFormat}/github/${warehouseName}${
searchPath + search
}`;
draft.pngShareLink = `${window.location.origin}/png/graphs/${
draft.pngShareLink = `${host}/png/graphs/${
GRAPH_TEMPLATE_TYPE_MAP[GRAPH_SHARE_LINK_MAP[templateId]]
}/${GRAPH_QUERY_SOURCE_MAP[querySource]}/${warehouseName}?${search}`;
}/github/${warehouseName}?${search}`;
} else if (templateId === GRAPH_TEMPLATE_ENUM.ACCT_ACTIVITY) {
/** acct activity */
const { topn } = shareInfo;
draft.shareLink = `${window.location.origin}/graphs/${projectValueFormat}/github/${warehouseName}${searchPath}topn=${topn}`;
draft.pngShareLink = `${window.location.origin}/png/graphs/${
draft.shareLink = `${host}/graphs/${projectValueFormat}/github/${warehouseName}${searchPath}user-limit=${shareInfo?.["user-limit"]}`;
draft.pngShareLink = `${host}/png/graphs/${
GRAPH_TEMPLATE_TYPE_MAP[GRAPH_SHARE_LINK_MAP[templateId]]
}/${GRAPH_QUERY_SOURCE_MAP[querySource]}/${warehouseName}?topn=${topn}`;
}/github/${warehouseName}?user-limit=${shareInfo?.["user-limit"]}`;
} else if (templateId === GRAPH_TEMPLATE_ENUM.ACCT_PARTNER) {
/** acct partner */
const { topn } = shareInfo;
draft.shareLink = `${window.location.origin}/graphs/${projectValueFormat}/github/${warehouseName}${searchPath}topn=${topn}`;
draft.pngShareLink = `${window.location.origin}/png/graphs/${
draft.shareLink = `${host}/graphs/${projectValueFormat}/github/${warehouseName}${searchPath}user-limit=${shareInfo?.["user-limit"]}`;
draft.pngShareLink = `${host}/png/graphs/${
GRAPH_TEMPLATE_TYPE_MAP[GRAPH_SHARE_LINK_MAP[templateId]]
}/${GRAPH_QUERY_SOURCE_MAP[querySource]}/${warehouseName}?topn=${topn}`;
}/github/${warehouseName}?user-limit=${shareInfo?.["user-limit"]}`;
} else if (templateId === GRAPH_TEMPLATE_ENUM.ACCT_INTEREST) {
const search = `githubrepo-topn=${shareInfo["githubrepo-topn"]}&topic-topn=${shareInfo["topic-topn"]}`;
const search = `repo-limit=${shareInfo["repo-limit"]}&topic-limit=${shareInfo["topic-limit"]}`;
/** acct interest */
draft.shareLink = `${
window.location.origin
}/graphs/${projectValueFormat}/github/${warehouseName}${
draft.shareLink = `${host}/graphs/${projectValueFormat}/github/${warehouseName}${
searchPath + search
}`;
draft.pngShareLink = `${window.location.origin}/png/graphs/${
draft.pngShareLink = `${host}/png/graphs/${
GRAPH_TEMPLATE_TYPE_MAP[GRAPH_SHARE_LINK_MAP[templateId]]
}/${GRAPH_QUERY_SOURCE_MAP[querySource]}/${warehouseName}?${search}`;
}/github/${warehouseName}?${search}`;
}
});
};
Expand Down
40 changes: 14 additions & 26 deletions osgraph-web/src/services/homePage_new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function parseStringToObjects(inputStr: string) {
}

export const getListQueryTemplate = async () => {
const response = await request(`/api/graph/list`, {
const response = await request(`/api/graphs/list`, {
method: "get",
});

Expand Down Expand Up @@ -97,7 +97,7 @@ export const getExecuteFullTextQuery = async (params: {
keyword: string;
indexName: string;
}) => {
const response = await request(`/api/graph/fulltext-search`, {
const response = await request(`/api/graphs/fulltext-search`, {
method: "get",
params: params,
});
Expand Down Expand Up @@ -132,59 +132,47 @@ export const getExecuteQueryTemplate = async (params: {
+params.templateId as keyof typeof GRAPH_TEMPLATE_ID_MAP
];
if (templateName === "项目贡献") {
url = "/api/graph/project-contribution";
args = {
GitHubRepo: params.value,
};
url = `/api/graphs/project-contribution/github/${params.value}`;
args = {};
params.templateParameterList.forEach((item: any) => {
args[item.parameterName] = item.parameterValue;
});
}
if (templateName === "项目社区") {
url = "/api/graph/project-community";
args = {
GitHubRepo: params.value,
};
url = `/api/graphs/project-community/github/${params.value}`;
args = {};
params.templateParameterList.forEach((item: any) => {
args[item.parameterName] = item.parameterValue;
});
}

if (templateName === "项目生态") {
url = "/api/graph/project-ecology";
args = {
GitHubRepo: params.value,
};
url = `/api/graphs/project-ecology/github/${params.value}`;
args = {};
params.templateParameterList.forEach((item: any) => {
args[item.parameterName] = item.parameterValue;
});
}

if (templateName === "开发活动") {
url = "/api/graph/develop-activities";
args = {
GitHubUser: params.value,
};
url = `/api/graphs/develop-activities/github/${params.value}`;
args = {};
params.templateParameterList.forEach((item: any) => {
args[item.parameterName] = item.parameterValue;
});
}

if (templateName === "开源伙伴") {
url = "/api/graph/os-partner";
args = {
GitHubUser: params.value,
};
url = `/api/graphs/os-partner/github/${params.value}`;
args = {};
params.templateParameterList.forEach((item: any) => {
args[item.parameterName] = item.parameterValue;
});
}

if (templateName === "开源兴趣") {
url = "/api/graph/os-interest";
args = {
GitHubUser: params.value,
};
url = `/api/graphs/os-interest/github/${params.value}`;
args = {};
params.templateParameterList.forEach((item: any) => {
args[item.parameterName] = item.parameterValue;
});
Expand Down
6 changes: 1 addition & 5 deletions osgraph-web/src/services/result_new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ export const getExecuteShareLinkQuery = async (query: {
extendsStr: string;
}) => {
const { templateType, path, extendsStr } = query;
const key =
templateType?.split("-")[0] === "project" ? "GitHubRepo" : "GitHubUser";

const response = await request(
`/api/graph/${templateType}?${key}=${encodeURIComponent(
path
)}&${extendsStr}`,
`/api/graphs/${templateType}/github/${path}?${extendsStr}`,
{
method: "get",
}
Expand Down
2 changes: 1 addition & 1 deletion osgraph-web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default defineConfig({
server: {
host: "0.0.0.0",
proxy: {
"/api/graph": {
"/api/graphs": {
target: isDev ? "http://116.62.110.113:8000/" : "https://osgraph.com",
changeOrigin: isDev,
},
Expand Down

0 comments on commit a887aa3

Please sign in to comment.