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
5bc65589
Commit
5bc65589
authored
Dec 16, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter categroy is_show true
parent
2bd6be0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
index.ts
supabase/functions/update-app-recommend/index.ts
+8
-4
index.ts
supabase/functions/update-app/index.ts
+9
-3
No files found.
supabase/functions/update-app-recommend/index.ts
View file @
5bc65589
...
@@ -14,7 +14,7 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
...
@@ -14,7 +14,7 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
while
(
true
)
{
while
(
true
)
{
const
{
data
,
error
}
=
await
supabase
const
{
data
,
error
}
=
await
supabase
.
from
(
table
)
.
from
(
table
)
.
select
(
'
id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show,recommend
'
)
// 可以根据需要调整字段
.
select
(
'
id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show,recommend
,category(is_show)
'
)
// 可以根据需要调整字段
.
gt
(
'
is_show
'
,
0
)
.
gt
(
'
is_show
'
,
0
)
.
gt
(
'
recommend
'
,
0
)
.
gt
(
'
recommend
'
,
0
)
// .eq('is_show', 1)
// .eq('is_show', 1)
...
@@ -27,9 +27,13 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
...
@@ -27,9 +27,13 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
console
.
error
(
`Error fetching data from
${
table
}
:`
,
error
);
console
.
error
(
`Error fetching data from
${
table
}
:`
,
error
);
throw
error
;
throw
error
;
}
}
let
newdata
=
data
.
filter
((
data
)
=>
{
if
(
data
&&
data
.
length
>
0
)
{
if
(
data
.
category
&&
data
.
category
.
is_show
)
{
allData
=
allData
.
concat
(
data
);
// 合并当前页数据
return
data
.
category
.
is_show
==
true
;
}
});
if
(
newdata
&&
newdata
.
length
>
0
)
{
allData
=
allData
.
concat
(
newdata
);
// 合并当前页数据
offset
+=
pageSize
;
// 移动到下一页
offset
+=
pageSize
;
// 移动到下一页
}
else
{
}
else
{
break
;
// 如果没有更多数据,则退出循环
break
;
// 如果没有更多数据,则退出循环
...
...
supabase/functions/update-app/index.ts
View file @
5bc65589
...
@@ -14,7 +14,7 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
...
@@ -14,7 +14,7 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
while
(
true
)
{
while
(
true
)
{
const
{
data
,
error
}
=
await
supabase
const
{
data
,
error
}
=
await
supabase
.
from
(
table
)
.
from
(
table
)
.
select
(
'
id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show
'
)
// 可以根据需要调整字段
.
select
(
'
id,name,icon,description,points,category_id,link,images,appPlatforms,caption,is_forward,is_show
,category(is_show)
'
)
// 可以根据需要调整字段
.
gt
(
'
is_show
'
,
0
)
.
gt
(
'
is_show
'
,
0
)
// .eq('is_show', 1)
// .eq('is_show', 1)
.
eq
(
"
category.is_show
"
,
true
)
.
eq
(
"
category.is_show
"
,
true
)
...
@@ -26,8 +26,14 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
...
@@ -26,8 +26,14 @@ async function fetchAllData(supabase, table: string, pageSize: number = 1000) {
throw
error
;
throw
error
;
}
}
if
(
data
&&
data
.
length
>
0
)
{
let
newdata
=
data
.
filter
((
data
)
=>
{
allData
=
allData
.
concat
(
data
);
// 合并当前页数据
if
(
data
.
category
&&
data
.
category
.
is_show
)
{
return
data
.
category
.
is_show
==
true
;
}
});
if
(
newdata
&&
newdata
.
length
>
0
)
{
allData
=
allData
.
concat
(
newdata
);
// 合并当前页数据
offset
+=
pageSize
;
// 移动到下一页
offset
+=
pageSize
;
// 移动到下一页
}
else
{
}
else
{
break
;
// 如果没有更多数据,则退出循环
break
;
// 如果没有更多数据,则退出循环
...
...
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