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
e93da218
Commit
e93da218
authored
Jun 27, 2025
by
Lin Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: avoid empty tables
parent
fef17669
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
sendDiffToGoogleSheets.ts
...detect_section_selector_masters/sendDiffToGoogleSheets.ts
+19
-11
No files found.
src/detect_section_selector_masters/sendDiffToGoogleSheets.ts
View file @
e93da218
...
...
@@ -42,6 +42,21 @@ async function uploadAllToSheets() {
.
filter
(
f
=>
f
.
endsWith
(
'.json'
))
.
map
(
f
=>
({
subdir
,
file
:
f
,
path
:
join
(
d
,
f
)
}));
});
// Filter out empty JSON files
const
uploadFiles
:
Array
<
{
subdir
:
string
;
file
:
string
;
path
:
string
;
data
:
any
[]}
>
=
[];
for
(
const
fObj
of
files
)
{
const
raw
=
readFileSync
(
fObj
.
path
,
'utf-8'
);
const
data
=
JSON
.
parse
(
raw
);
if
(
Array
.
isArray
(
data
)
&&
data
.
length
===
0
)
{
console
.
log
(
`🚫 Skipping empty file
${
fObj
.
file
}
`
);
}
else
{
uploadFiles
.
push
({
...
fObj
,
data
});
}
}
if
(
!
uploadFiles
.
length
)
{
console
.
log
(
'No non-empty JSON files to upload'
);
return
;
}
// Fetch existing sheet names
const
{
data
:
spreadsheet
}
=
await
sheets
.
spreadsheets
.
get
({
spreadsheetId
});
...
...
@@ -55,9 +70,9 @@ async function uploadAllToSheets() {
// 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
(
f
iles
.
length
>
0
)
{
const
firstName
=
f
iles
[
0
].
file
.
replace
(
/
\.
json$/
,
''
);
// Rename the remaining sheet to match the first
non-empty file
if
(
uploadF
iles
.
length
>
0
)
{
const
firstName
=
uploadF
iles
[
0
].
file
.
replace
(
/
\.
json$/
,
''
);
const
firstSheetId
=
sheetsArr
[
0
].
properties
?.
sheetId
!
;
if
(
existing
[
0
]
!==
firstName
)
{
await
sheets
.
spreadsheets
.
batchUpdate
({
...
...
@@ -70,14 +85,7 @@ async function uploadAllToSheets() {
existing
[
0
]
=
firstName
;
}
for
(
const
{
subdir
,
file
,
path
}
of
files
)
{
// Read and skip empty JSON
const
fileRaw
=
readFileSync
(
path
,
'utf-8'
);
const
fileData
=
JSON
.
parse
(
fileRaw
);
if
(
Array
.
isArray
(
fileData
)
&&
fileData
.
length
===
0
)
{
console
.
log
(
`🚫 Skipping empty file
${
file
}
`
);
continue
;
}
for
(
const
{
subdir
,
file
,
path
,
data
:
fileData
}
of
uploadFiles
)
{
// Use file name (without extension) as sheetName
const
sheetName
=
file
.
replace
(
/
\.
json$/
,
''
);
if
(
!
existing
.
includes
(
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