Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
Falcon
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
Walter Huang
Falcon
Commits
9ae6ee9e
Commit
9ae6ee9e
authored
Jun 27, 2025
by
Lin Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:clean up sheets
parent
90a9aa12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
sendDiffToGoogleSheets.ts
...detect_section_selector_masters/sendDiffToGoogleSheets.ts
+24
-1
No files found.
src/detect_section_selector_masters/sendDiffToGoogleSheets.ts
View file @
9ae6ee9e
...
@@ -45,7 +45,30 @@ async function uploadAllToSheets() {
...
@@ -45,7 +45,30 @@ async function uploadAllToSheets() {
// Fetch existing sheet names
// Fetch existing sheet names
const
{
data
:
spreadsheet
}
=
await
sheets
.
spreadsheets
.
get
({
spreadsheetId
});
const
{
data
:
spreadsheet
}
=
await
sheets
.
spreadsheets
.
get
({
spreadsheetId
});
const
existing
=
spreadsheet
.
sheets
?.
map
((
s
:
any
)
=>
s
.
properties
?.
title
||
''
)
||
[];
// Prepare and clean up sheets: delete all but the first to avoid empty spreadsheet
const
sheetsArr
=
spreadsheet
.
sheets
||
[];
// Delete extra sheets (keep index 0)
if
(
sheetsArr
.
length
>
1
)
{
const
deleteRequests
=
sheetsArr
.
slice
(
1
).
map
(
s
=>
({
deleteSheet
:
{
sheetId
:
s
.
properties
?.
sheetId
}
}));
await
sheets
.
spreadsheets
.
batchUpdate
({
spreadsheetId
,
requestBody
:
{
requests
:
deleteRequests
}
});
}
// Track existing titles (only first sheet remains)
const
existing
:
string
[]
=
[
sheetsArr
[
0
]?.
properties
?.
title
||
''
];
// Rename the remaining sheet to match the first file (if any)
if
(
files
.
length
>
0
)
{
const
firstName
=
files
[
0
].
file
.
replace
(
/
\.
json$/
,
''
);
const
firstSheetId
=
sheetsArr
[
0
].
properties
?.
sheetId
!
;
if
(
existing
[
0
]
!==
firstName
)
{
await
sheets
.
spreadsheets
.
batchUpdate
({
spreadsheetId
,
requestBody
:
{
requests
:
[
{
updateSheetProperties
:
{
properties
:
{
sheetId
:
firstSheetId
,
title
:
firstName
},
fields
:
'title'
}
}
]
}
});
}
existing
[
0
]
=
firstName
;
}
for
(
const
{
subdir
,
file
,
path
}
of
files
)
{
for
(
const
{
subdir
,
file
,
path
}
of
files
)
{
// Use file name (without extension) as sheetName
// Use file name (without extension) as sheetName
...
...
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