Skip to content

Commit 0b975f3

Browse files
committed
Revert "PLU-469: add fix for excel get table row implementation (#960)"
This reverts commit b908cc5.
1 parent b908cc5 commit 0b975f3

File tree

1 file changed

+0
-63
lines changed

1 file changed

+0
-63
lines changed

packages/backend/src/apps/m365-excel/actions/get-table-row/implementation/get-top-n-table-rows.ts

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -16,76 +16,13 @@ const msGraphResponseSchema = z
1616
headerSheetRowIndex: response.rowIndex,
1717
}))
1818

19-
// Can get more info e.g. formulas, numberFormat, text for possible date manipulation but too complex for now
20-
const msGraphRangeResponseSchema = z
21-
.object({
22-
rowCount: z.number(),
23-
rowIndex: z.number(),
24-
values: z.array(z.array(z.coerce.string())), // first row is the header
25-
})
26-
.transform((response) => ({
27-
rowCount: response.rowCount,
28-
headerSheetRowIndex: response.rowIndex,
29-
headerRowValues: response.values[0],
30-
rowValues: response.values.slice(1),
31-
}))
32-
3319
interface GetTopNTableRowsResult {
3420
columns: string[]
3521
rows: string[][]
3622
headerSheetRowIndex: number
3723
}
3824

39-
/**
40-
* Using range endpoint to get both the header row and data rows
41-
* instead of headerRowRange and rows to avoid extra API call
42-
* Also, rows endpoint uses pagination so the query takes longer for large tables
43-
*
44-
* Considered using columns API but there is no headerSheetRowIndex returned so
45-
* an extra API call has to be made to retrieve it
46-
* Reference: https://learn.microsoft.com/en-us/graph/api/table-range?view=graph-rest-1.0&tabs=http
47-
*/
4825
export default async function getTopNTableRows(
49-
$: IGlobalVariable,
50-
session: WorkbookSession,
51-
tableId: string,
52-
n: number,
53-
): Promise<GetTopNTableRowsResult> {
54-
const rangeParseResult = msGraphRangeResponseSchema.safeParse(
55-
(await session.request(`/tables/${tableId}/range`, 'get')).data,
56-
)
57-
58-
if (rangeParseResult.success === false) {
59-
throw new StepError(
60-
'Invalid table range',
61-
'Check your Excel file and try again',
62-
$.step.position,
63-
$.app.name,
64-
)
65-
}
66-
67-
const { rowCount, headerSheetRowIndex, headerRowValues, rowValues } =
68-
rangeParseResult.data
69-
70-
// rowCount includes the header row
71-
if (rowCount > n) {
72-
throw new StepError(
73-
`Your Excel table has more than ${n.toLocaleString()} rows.`,
74-
`Reduce the number of rows and try again.`,
75-
$.step.position,
76-
$.app.name,
77-
)
78-
}
79-
80-
return {
81-
columns: headerRowValues,
82-
rows: rowValues,
83-
headerSheetRowIndex,
84-
}
85-
}
86-
87-
// Old method in case we need to rollback fast
88-
export async function getTopNTableRowsOld(
8926
// Typically, we should avoid making $ viral though the codebase, but this is
9027
// an exception because getTopNTableRows is not a common helper function.
9128
$: IGlobalVariable,

0 commit comments

Comments
 (0)