Skip to content

Commit

Permalink
code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomociti committed Nov 4, 2024
1 parent 71c8b5f commit cb9af9d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 300 deletions.
3 changes: 2 additions & 1 deletion apis/core/lib/domain/table/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as ColumnMapping from '@cube-creator/model/ColumnMapping'
import $rdf from 'rdf-ext'
import slug from 'slug'
import { Link } from '@cube-creator/model/lib/Link'
import { inferDatatype } from '@cube-creator/model/lib/datatypeInference'
import { ResourceStore } from '../../ResourceStore'
import * as id from '../identifiers'

Expand Down Expand Up @@ -92,7 +93,7 @@ export default function mixin<Base extends Constructor<Table>>(Resource: Base):
return this.addLiteralColumnMapping({
store,
sourceColumn: column,
datatype: column.defaultDatatype,
datatype: inferDatatype(column.samples),
targetProperty: $rdf.literal(slug(column.name)),
})
}
Expand Down
4 changes: 2 additions & 2 deletions apis/core/test/ResourceStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('ResourceStore', () => {
const actual = await store.get(ex.Foo)

// then
expect(actual.term).to.eq(expected.term)
expect(actual).to.eq(expected)
})

it('returns object previously created', async () => {
Expand All @@ -77,7 +77,7 @@ describe('ResourceStore', () => {
const actual = await store.get(ex.Foo)

// then
expect(actual.term).to.eq(expected.term)
expect(actual).to.eq(expected)
expect(client.query.construct).to.not.have.been.called
})

Expand Down
7 changes: 0 additions & 7 deletions packages/model/CsvColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import { Constructor, property, ResourceIdentifier } from '@tpluscode/rdfine'
import type { GraphPointer } from 'clownface'
import { csvw, dtype, schema } from '@tpluscode/rdf-ns-builders'
import { cc } from '@cube-creator/core/namespace'
import { NamedNode } from '@rdfjs/types'
import { initializer } from './lib/initializer'
import { inferDatatype } from './lib/datatypeInference'

export interface CsvColumn extends RdfResource {
name: string
order: number
samples: string[]
defaultDatatype: NamedNode
}

export function CsvColumnMixin<Base extends Constructor>(Resource: Base): Mixin {
Expand All @@ -25,10 +22,6 @@ export function CsvColumnMixin<Base extends Constructor>(Resource: Base): Mixin

@property.literal({ path: cc.csvColumnSample, values: 'array' })
samples!: string[]

get defaultDatatype(): NamedNode {
return inferDatatype(this.samples)
}
}

return Impl
Expand Down
2 changes: 1 addition & 1 deletion packages/model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"alcaeus": "^2",
"chai": "^4.3.4",
"mocha": "^10",
"mocha-chai-rdf": "^0.1.4"
"mocha-chai-rdf": "^0.1.5"
}
}
Loading

0 comments on commit cb9af9d

Please sign in to comment.