Skip to content

Commit

Permalink
fix: invalid imports after merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Dec 4, 2024
1 parent 0c0dde4 commit 61eec3f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 10 deletions.
87 changes: 85 additions & 2 deletions frontend/src2/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { watchDebounced } from '@vueuse/core'
import domtoimage from 'dom-to-image'
import { Socket } from 'socket.io-client'
import { ComputedRef, inject, onBeforeUnmount, Ref, watch } from 'vue'
import session from '../session'
import {
Expand All @@ -9,7 +10,7 @@ import {
QueryResultColumn,
} from '../types/query.types'
import { FIELDTYPES } from './constants'
import { Socket } from 'socket.io-client'
import { createToast } from './toasts'

export function getUniqueId(length = 8) {
return (+new Date() * Math.random()).toString(36).substring(0, length)
Expand Down Expand Up @@ -312,11 +313,93 @@ export function isString(data_type: ColumnDataType) {
return FIELDTYPES.TEXT.includes(data_type)
}


export function attachRealtimeListener(event: string, callback: (...args: any[]) => void) {
const $socket = inject<Socket>('$socket')!
$socket.on(event, callback)
onBeforeUnmount(() => {
$socket.off(event)
})
}

export function createHeaders(columns: QueryResultColumn[]) {
const nestedColumns = columns.filter((column) => column.name.includes('___'))
if (!nestedColumns.length) {
return [
columns.map((column) => {
return {
label: column.name,
level: 0,
isLast: true,
column: column,
colspan: 1,
}
}),
]
}

const levels = nestedColumns[0].name.split('___').length || 1

const _columns = columns.map((column) => {
return {
...column,
isNested: column.name.includes('___'),
// ibis returns nested columns as value1___column1, value2___column1, value3___column1
// using the columns as it is will show the value1 on the top and column1, column2, column3 as nested columns
// so we reverse the parts to show column1 on the top and value1, value2, value3 as nested columns
parts: column.name.split('___').reverse(),
}
})

const headers = []

for (let level = 0; level < levels; level++) {
const headerRow = []

for (let column of _columns) {
const isNested = column.isNested
const isLast = level === levels - 1

headerRow.push({
label: isNested ? column.parts[level] : isLast ? column.name : '',
level,
isLast,
column: column,
})
}

headers.push(headerRow)
}

const groupedHeaders = []

for (let headerRow of headers) {
const groupedHeaderRow = []

let currentHeader = headerRow[0]
let currentColspan = 1

for (let i = 1; i < headerRow.length; i++) {
const header = headerRow[i]

if (header.label === currentHeader.label) {
currentColspan++
} else {
groupedHeaderRow.push({
...currentHeader,
colspan: currentColspan,
})
currentHeader = header
currentColspan = 1
}
}

groupedHeaderRow.push({
...currentHeader,
colspan: currentColspan,
})

groupedHeaders.push(groupedHeaderRow)
}

return groupedHeaders
}
1 change: 0 additions & 1 deletion frontend/src2/query/components/QueryOperations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ const CustomOperationInfo = (props: any) => {
<component
:is="op.meta.icon"
class="h-4 w-4 text-gray-600"
class="h-4 w-4 text-gray-600"
stroke-width="1.5"
/>
</div>
Expand Down
7 changes: 0 additions & 7 deletions frontend/src2/query/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Indent,
Repeat,
ScrollText,
ScrollText,
TextCursorInput,
XSquareIcon,
} from 'lucide-vue-next'
Expand All @@ -25,8 +24,6 @@ import {
CastArgs,
Code,
CodeArgs,
Code,
CodeArgs,
Column,
CustomOperation,
CustomOperationArgs,
Expand Down Expand Up @@ -65,8 +62,6 @@ import {
SourceArgs,
SQL,
SQLArgs,
SQL,
SQLArgs,
Summarize,
SummarizeArgs,
Table,
Expand Down Expand Up @@ -411,5 +406,3 @@ export const limit = query_operation_types.limit.init
export const custom_operation = query_operation_types.custom_operation.init
export const sql = query_operation_types.sql.init
export const code = query_operation_types.code.init
export const sql = query_operation_types.sql.init
export const code = query_operation_types.code.init

0 comments on commit 61eec3f

Please sign in to comment.