Skip to content

Commit

Permalink
profile
Browse files Browse the repository at this point in the history
  • Loading branch information
zizdlp committed Sep 14, 2024
1 parent 343e0af commit d3ab5dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: BUILD_MAIN
on:
push:
branches:
- main
- profile
jobs:
build:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function fetchMarkdownContent({
}) {
const xforward = headers().get("x-forwarded-for") ?? "";
const agent = headers().get("User-Agent") ?? "";
const startTime = performance.now(); // 获取开始时间
const response = await fetchServerWithAuthWrapper({
endpoint: FetchServerWithAuthWrapperEndPoint.GET_MARKDOWN_CONTENT,
xforward,
Expand All @@ -33,7 +34,11 @@ async function fetchMarkdownContent({
lang: locale || "en",
},
});
const endTime = performance.now(); // 获取结束时间

const fetchDuration = endTime - startTime; // 计算 fetch 请求的时间
logger.warn(`Fetch wikipage start: ${startTime},${endTime}`);
logger.warn(`Fetch wikipage took ${fetchDuration.toFixed(2)} ms `);
if (response.error) {
throw new FetchError(response.message, response.status);
}
Expand Down
1 change: 1 addition & 0 deletions zbook_frontend/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
session: Session;
token: JWT;
}): Promise<Session> {
logger.info(`call session`, 200);
if (token.app_id) {
// oauth
session.app_id = token.app_id;
Expand Down
10 changes: 9 additions & 1 deletion zbook_frontend/src/components/sidebars/RepoSideBarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ export default async function RepoSideBarLayout({
}) {
const t = await getTranslations("SideBar");
try {
const startTime = performance.now(); // 获取开始时间
let authname = "";
const session = await auth();
if (session && session.username && session.role) {
authname = session.username;
}
const secstartTime = performance.now(); // 获取开始时间
// const delay = Math.floor(Math.random() * 4000) + 1400;
// await new Promise((resolve) => setTimeout(resolve, delay));
const xforward = headers().get("x-forwarded-for") ?? "";
Expand All @@ -40,7 +42,13 @@ export default async function RepoSideBarLayout({
lang: locale == "" ? "en" : locale,
},
});

const endTime = performance.now(); // 获取结束时间
const fetchsec = endTime - secstartTime; // 计算 fetch 请求的时间
const fetchDuration = endTime - startTime; // 计算 fetch 请求的时间
logger.warn(`Fetch GET_REPO_CONFIG start: ${startTime},${secstartTime}`);
logger.warn(
`Fetch GET_REPO_CONFIG took ${fetchDuration.toFixed(2)} ms ${fetchsec.toFixed(2)} ms`
);
if (data.error) {
throw new FetchError(data.message, data.status);
}
Expand Down

0 comments on commit d3ab5dd

Please sign in to comment.