Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
a4e2c651
authored
Jun 30, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: admin
parent
c411ca4b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
13 deletions
+107
-13
.github/workflows/admin-image.yml
+77
-0
.github/workflows/fastgpt-image.yml
+1
-1
admin/service/route/user.js
+11
-5
admin/src/Dashboard.tsx
+18
-7
No files found.
.github/workflows/admin-image.yml
0 → 100644
View file @
a4e2c651
name
:
Build fastgpt-admin images and copy image to docker hub
on
:
workflow_dispatch
:
push
:
branches
:
-
'
main'
tags
:
-
'
v*.*.*'
jobs
:
build-images
:
runs-on
:
ubuntu-20.04
steps
:
-
name
:
Checkout
uses
:
actions/checkout@v3
with
:
fetch-depth
:
1
-
name
:
Install Dependencies
run
:
|
sudo apt update && sudo apt install -y nodejs npm
-
name
:
Set up QEMU (optional)
uses
:
docker/setup-qemu-action@v2
-
name
:
Set up Docker Buildx
uses
:
docker/setup-buildx-action@v2
with
:
driver-opts
:
network=host
-
name
:
Login to GitHub Container Registry
uses
:
docker/login-action@v2
with
:
registry
:
ghcr.io
username
:
${{ github.repository_owner }}
password
:
${{ secrets.GH_PAT }}
-
name
:
Set DOCKER_REPO_TAGGED based on branch or tag
run
:
|
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-admin:latest" >> $GITHUB_ENV
else
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-admin:${{ github.ref_name }}" >> $GITHUB_ENV
fi
-
name
:
Build and publish image for main branch or tag push event
env
:
DOCKER_REPO_TAGGED
:
${{ env.DOCKER_REPO_TAGGED }}
run
:
|
cd client && \
docker buildx build \
--platform linux/amd64,linux/arm64 \
--label "org.opencontainers.image.source= https://github.com/ ${{ github.repository_owner }}/FastGPT" \
--label "org.opencontainers.image.description=fastgpt-admin image" \
--label "org.opencontainers.image.licenses=MIT" \
--push \
-t ${DOCKER_REPO_TAGGED} \
-f Dockerfile \
.
push-to-docker-hub
:
needs
:
build-images
runs-on
:
ubuntu-20.04
steps
:
-
name
:
Checkout code
uses
:
actions/checkout@v3
-
name
:
Login to Docker Hub
uses
:
docker/login-action@v2
with
:
username
:
${{ secrets.DOCKER_HUB_NAME }}
password
:
${{ secrets.DOCKER_HUB_PASSWORD }}
-
name
:
Set DOCKER_REPO_TAGGED based on branch or tag
run
:
|
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
-
name
:
Pull image from GitHub Container Registry
run
:
docker pull ghcr.io/${{ github.repository_owner }}/fastgpt-admin:${{env.IMAGE_TAG}}
-
name
:
Tag image with Docker Hub repository name and version tag
run
:
docker tag ghcr.io/${{ github.repository_owner }}/fastgpt-admin:${{env.IMAGE_TAG}} ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
-
name
:
Push image to Docker Hub
run
:
docker push ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
.github/workflows/image.yml
→
.github/workflows/
fastgpt-
image.yml
View file @
a4e2c651
name
:
Build
images and copy image to docker
name
:
Build
fastgpt images and copy image to docker hub
on
:
on
:
workflow_dispatch
:
workflow_dispatch
:
push
:
push
:
...
...
admin/service/route/user.js
View file @
a4e2c651
...
@@ -188,16 +188,21 @@ export const useUserRoute = (app) => {
...
@@ -188,16 +188,21 @@ export const useUserRoute = (app) => {
$match
:
{
$match
:
{
status
:
'SUCCESS'
,
status
:
'SUCCESS'
,
createTime
:
{
createTime
:
{
$gte
:
new
Date
(
Date
.
now
()
-
day
*
24
*
60
*
60
*
1000
)
$gte
:
new
Date
(
Date
.
now
()
-
day
*
24
*
60
*
60
*
1000
+
8
*
60
*
60
*
1000
)
// 补时差
}
}
}
}
},
},
{
{
$addFields
:
{
adjustedCreateTime
:
{
$add
:
[
'$createTime'
,
8
*
60
*
60
*
1000
]
}
}
},
{
$group
:
{
$group
:
{
_id
:
{
_id
:
{
year
:
{
$year
:
'$
c
reateTime'
},
year
:
{
$year
:
'$
adjustedC
reateTime'
},
month
:
{
$month
:
'$
c
reateTime'
},
month
:
{
$month
:
'$
adjustedC
reateTime'
},
day
:
{
$dayOfMonth
:
'$
c
reateTime'
}
day
:
{
$dayOfMonth
:
'$
adjustedC
reateTime'
}
},
},
count
:
{
$sum
:
'$price'
}
count
:
{
$sum
:
'$price'
}
}
}
...
@@ -216,7 +221,8 @@ export const useUserRoute = (app) => {
...
@@ -216,7 +221,8 @@ export const useUserRoute = (app) => {
startCount
+=
item
.
count
;
startCount
+=
item
.
count
;
return
{
return
{
date
:
item
.
date
,
date
:
item
.
date
,
count
:
startCount
total
:
startCount
,
count
:
item
.
count
};
};
});
});
...
...
admin/src/Dashboard.tsx
View file @
a4e2c651
...
@@ -16,13 +16,20 @@ import dayjs from 'dayjs';
...
@@ -16,13 +16,20 @@ import dayjs from 'dayjs';
const
authStorageKey
=
'tushan:auth'
;
const
authStorageKey
=
'tushan:auth'
;
const
PRICE_SCALE
=
100000
;
const
PRICE_SCALE
=
100000
;
type
fetchChatData
=
{
count
:
number
;
date
:
string
;
increase
?:
number
;
increaseRate
?:
string
};
type
fetchChatData
=
{
count
:
number
;
total
?:
number
;
date
:
string
;
increase
?:
number
;
increaseRate
?:
string
;
};
type
chatDataType
=
{
type
chatDataType
=
{
date
:
string
;
date
:
string
;
userCount
:
number
;
userCount
:
number
;
userIncrease
?:
number
;
userIncrease
?:
number
;
userIncreaseRate
?:
string
;
userIncreaseRate
?:
string
;
payTotal
:
number
;
payCount
:
number
;
payCount
:
number
;
};
};
...
@@ -84,7 +91,8 @@ export const Dashboard: React.FC = React.memo(() => {
...
@@ -84,7 +91,8 @@ export const Dashboard: React.FC = React.memo(() => {
userCount
:
item
.
count
,
userCount
:
item
.
count
,
userIncrease
:
item
.
increase
,
userIncrease
:
item
.
increase
,
userIncreaseRate
:
item
.
increaseRate
,
userIncreaseRate
:
item
.
increaseRate
,
payCount
:
pay
?
pay
.
count
/
PRICE_SCALE
:
0
payCount
:
pay
?
pay
.
count
/
PRICE_SCALE
:
0
,
payTotal
:
pay
?.
total
?
pay
.
total
/
PRICE_SCALE
:
0
};
};
});
});
setChatData
(
data
);
setChatData
(
data
);
...
@@ -208,10 +216,13 @@ const CustomTooltip = ({ active, payload }: any) => {
...
@@ -208,10 +216,13 @@ const CustomTooltip = ({ active, payload }: any) => {
用户总数:
<
strong
>
{
data
.
userCount
}
</
strong
>
用户总数:
<
strong
>
{
data
.
userCount
}
</
strong
>
</
p
>
</
p
>
<
p
className=
"label"
>
<
p
className=
"label"
>
用户进入增长数量:
<
strong
>
{
data
.
userIncrease
}
</
strong
>
用户今日增长数量:
<
strong
>
{
data
.
userIncrease
}
</
strong
>
</
p
>
<
p
className=
"label"
>
今日支付:
<
strong
>
{
data
.
payCount
}
</
strong
>
元
</
p
>
</
p
>
<
p
className=
"label"
>
<
p
className=
"label"
>
60天累计支付:
<
strong
>
{
data
.
pay
Count
}
</
strong
>
元
60天累计支付:
<
strong
>
{
data
.
pay
Total
}
</
strong
>
元
</
p
>
</
p
>
</
div
>
</
div
>
);
);
...
@@ -233,7 +244,7 @@ const UserChart = ({ data }: { data: chatDataType[] }) => {
...
@@ -233,7 +244,7 @@ const UserChart = ({ data }: { data: chatDataType[] }) => {
<
stop
offset=
"5%"
stopColor=
"#82ca9d"
stopOpacity=
{
0.8
}
/>
<
stop
offset=
"5%"
stopColor=
"#82ca9d"
stopOpacity=
{
0.8
}
/>
<
stop
offset=
"95%"
stopColor=
"#82ca9d"
stopOpacity=
{
0
}
/>
<
stop
offset=
"95%"
stopColor=
"#82ca9d"
stopOpacity=
{
0
}
/>
</
linearGradient
>
</
linearGradient
>
<
linearGradient
id=
"pay
Count
"
x1=
"0"
y1=
"0"
x2=
"0"
y2=
"1"
>
<
linearGradient
id=
"pay
Total
"
x1=
"0"
y1=
"0"
x2=
"0"
y2=
"1"
>
<
stop
offset=
"5%"
stopColor=
"#8884d8"
stopOpacity=
{
0.8
}
/>
<
stop
offset=
"5%"
stopColor=
"#8884d8"
stopOpacity=
{
0.8
}
/>
<
stop
offset=
"95%"
stopColor=
"#8884d8"
stopOpacity=
{
0
}
/>
<
stop
offset=
"95%"
stopColor=
"#8884d8"
stopOpacity=
{
0
}
/>
</
linearGradient
>
</
linearGradient
>
...
@@ -251,10 +262,10 @@ const UserChart = ({ data }: { data: chatDataType[] }) => {
...
@@ -251,10 +262,10 @@ const UserChart = ({ data }: { data: chatDataType[] }) => {
/>
/>
<
Area
<
Area
type=
"monotone"
type=
"monotone"
dataKey=
"pay
Count
"
dataKey=
"pay
Total
"
stroke=
"#8884d8"
stroke=
"#8884d8"
fillOpacity=
{
1
}
fillOpacity=
{
1
}
fill=
"url(#pay
Count
)"
fill=
"url(#pay
Total
)"
/>
/>
</
AreaChart
>
</
AreaChart
>
</
ResponsiveContainer
>
</
ResponsiveContainer
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment