-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,099 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- dev | ||
- main | ||
- hotfix | ||
- new_card | ||
- recent_save | ||
|
||
jobs: | ||
deploy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Hono } from 'hono' | ||
import type { HonoTypeUserInformation } from '~/constants/binding' | ||
import { getHomeChartData } from '~/model/data' | ||
import result from '~/utils/result' | ||
|
||
const app = new Hono<HonoTypeUserInformation>() | ||
|
||
app.get('/page_chart_data', async (c) => { | ||
const data = await getHomeChartData(c.env.DB) | ||
|
||
return c.json(result.success(data)) | ||
}) | ||
|
||
app.get('/r2_usage', async (c) => { | ||
const res = await c.env.BUCKET.list() | ||
return c.json(result.success({ | ||
size: res.objects.reduce((acc, obj) => acc + obj.size, 0), | ||
count: res.objects.length, | ||
})) | ||
}) | ||
|
||
export default app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { D1Database } from '@cloudflare/workers-types/experimental' | ||
import { selectAllPageCount, selectPageTotalCount } from './page' | ||
import { selectAllFolders } from './folder' | ||
|
||
async function getHomeChartData(DB: D1Database) { | ||
const folderList = await selectAllFolders(DB) | ||
const folderPageCountList = await Promise.all(folderList.map(async (folder) => { | ||
const pageCount = await selectPageTotalCount(DB, { folderId: folder.id }) | ||
return { | ||
id: folder.id, | ||
name: folder.name, | ||
pageCount: pageCount as number, | ||
} | ||
})) | ||
|
||
const sortedFolderPageCountList = folderPageCountList | ||
.sort((a, b) => b.pageCount - a.pageCount) | ||
.slice(0, 5) | ||
|
||
const allPageCount = await selectAllPageCount(DB) | ||
return { | ||
folders: sortedFolderPageCountList, | ||
all: allPageCount, | ||
} | ||
} | ||
|
||
export { | ||
getHomeChartData, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.