Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appbase-edge-function
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanjinfei
appbase-edge-function
Commits
ebdd694e
Commit
ebdd694e
authored
Nov 21, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function
parent
05a6a997
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
index.ts
supabase/functions/update-app/index.ts
+3
-2
index.ts
supabase/functions/update-rank/index.ts
+2
-1
No files found.
supabase/functions/update-app/index.ts
View file @
ebdd694e
...
@@ -53,7 +53,8 @@ Deno.serve(async (req) => {
...
@@ -53,7 +53,8 @@ Deno.serve(async (req) => {
// 上传所有 app 数据到 storage
// 上传所有 app 数据到 storage
const
allAppsJson
=
JSON
.
stringify
(
allApps
);
const
allAppsJson
=
JSON
.
stringify
(
allApps
);
const
allAppsFileName
=
`app_all_
${
timestamp
}
.json`
;
const
directory
=
`app-category/
${
timestamp
}
`
;
const
allAppsFileName
=
`
${
directory
}
/app_all.json`
;
const
bucketName
=
'
cache
'
;
// 替换为存储桶名称
const
bucketName
=
'
cache
'
;
// 替换为存储桶名称
const
{
error
:
allAppsUploadError
}
=
await
supabase
.
storage
const
{
error
:
allAppsUploadError
}
=
await
supabase
.
storage
...
@@ -83,7 +84,7 @@ Deno.serve(async (req) => {
...
@@ -83,7 +84,7 @@ Deno.serve(async (req) => {
// 上传每个 category_id 的数据
// 上传每个 category_id 的数据
for
(
const
[
categoryId
,
apps
]
of
Object
.
entries
(
groupedData
))
{
for
(
const
[
categoryId
,
apps
]
of
Object
.
entries
(
groupedData
))
{
const
categoryJson
=
JSON
.
stringify
(
apps
);
const
categoryJson
=
JSON
.
stringify
(
apps
);
const
categoryFileName
=
`
app_category_
${
categoryId
}
_
${
timestamp
}
.json`
;
const
categoryFileName
=
`
${
directory
}
/
${
categoryId
}
.json`
;
const
{
error
:
categoryUploadError
}
=
await
supabase
.
storage
const
{
error
:
categoryUploadError
}
=
await
supabase
.
storage
.
from
(
bucketName
)
.
from
(
bucketName
)
...
...
supabase/functions/update-rank/index.ts
View file @
ebdd694e
...
@@ -30,7 +30,8 @@ Deno.serve(async (req) => {
...
@@ -30,7 +30,8 @@ Deno.serve(async (req) => {
// 3. 生成文件名
// 3. 生成文件名
const
timestamp
=
Math
.
floor
(
Date
.
now
()
/
3600000
)
*
3600
;
// 计算整点的时间戳
const
timestamp
=
Math
.
floor
(
Date
.
now
()
/
3600000
)
*
3600
;
// 计算整点的时间戳
const
fileName
=
`user_top_100_
${
timestamp
}
.json`
;
const
directory
=
`user-rank/
${
timestamp
}
`
;
const
fileName
=
`
${
directory
}
/user_top_100.json`
;
const
bucketName
=
'
cache
'
;
// 替换为你的存储桶名称
const
bucketName
=
'
cache
'
;
// 替换为你的存储桶名称
const
{
error
:
uploadError
}
=
await
supabase
.
storage
const
{
error
:
uploadError
}
=
await
supabase
.
storage
...
...
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