-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/dataset slug name map #124
Merged
Merged
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
bd53c91
get slug mapping from datasette on startup
GeorgeGoodall 751813d
linting
GeorgeGoodall f3f221c
update package-lock
GeorgeGoodall 8958b66
refactored a large amount of code to get tests working
GeorgeGoodall faff771
Revert "update package-lock"
GeorgeGoodall ea403a3
fixing webpack config as we need polyfills
GeorgeGoodall 2055b7d
linting
GeorgeGoodall 1431930
configuration
GeorgeGoodall fe84278
rewrite fetch local auth to use new datasette service
GeorgeGoodall 9eee879
added todo comments
GeorgeGoodall cc13343
Merge remote-tracking branch 'origin/main' into feat/datasetSlugNameMap
GeorgeGoodall 00fcf5c
Merge branch 'staging' into feat/datasetSlugNameMap
GeorgeGoodall 9644b06
update ports
GeorgeGoodall 8489812
linting
GeorgeGoodall 5e4a514
add tests for datasette
GeorgeGoodall 477e207
linting
GeorgeGoodall f65080f
updated tests for fetchLocalAuthorities
GeorgeGoodall 59eae2a
added unit tests for getDatasetSlugNameMapping
GeorgeGoodall 2b76c87
Merge remote-tracking branch 'origin/main' into feat/datasetSlugNameMap
GeorgeGoodall 3ad1f62
added tests for getFullServiceName
GeorgeGoodall 2e010a0
Merge remote-tracking branch 'origin/main' into feat/datasetSlugNameMap
GeorgeGoodall a589082
Merge branch 'staging' into feat/datasetSlugNameMap
GeorgeGoodall 5874721
update workflow
GeorgeGoodall 9a821e3
added unit tests for makeDatasetSlugToReadableNameFilter
GeorgeGoodall d7b20d7
added tests for the performanceDbApi
GeorgeGoodall fd5a0fd
Merge pull request #192 from digital-land/staging
GeorgeGoodall 1fe4b0f
fix bug
GeorgeGoodall d9d5d74
Merge pull request #196 from digital-land/fix/loggerWarning
GeorgeGoodall 5684274
Merge remote-tracking branch 'origin/main' into feat/datasetSlugNameMap
GeorgeGoodall 960f303
revert feature deploy change
GeorgeGoodall cc86b73
fix test
GeorgeGoodall f6b351d
change expect statement
GeorgeGoodall ef146a4
updated tests to remove unneeded condition from performancedbapi
GeorgeGoodall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import config from '../../config/index.js' | ||
|
||
export default (service) => { | ||
const serviceName = config.serviceName | ||
|
||
return serviceName.replace('Provide', service) | ||
const getFullServiceName = (service) => { | ||
if (!service || typeof service !== 'string') { | ||
throw new Error('Service name must be a non-empty string') | ||
} | ||
return config.serviceName.replace('Provide', service) | ||
} | ||
|
||
export default getFullServiceName | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import datasette from '../../services/datasette.js' | ||
|
||
export const getDatasetSlugNameMapping = async () => { | ||
const datasetSlugNameTable = await datasette.runQuery('select dataset, name from dataset') | ||
|
||
const datasetMapping = new Map() | ||
datasetSlugNameTable.rows.forEach(([slug, name]) => { | ||
datasetMapping.set(slug, name) | ||
}) | ||
return datasetMapping | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import datasette, { formatData } from '../../src/services/datasette.js' | ||
import axios from 'axios' | ||
import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest' | ||
|
||
describe('datasette', () => { | ||
beforeEach(() => { | ||
vi.spyOn(axios, 'get').mockResolvedValue({ | ||
data: { | ||
columns: ['column1', 'column2'], | ||
rows: [ | ||
['value1', 'value2'], | ||
['value3', 'value4'] | ||
] | ||
} | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
vi.mocked(axios.get).mockReset() | ||
}) | ||
|
||
it('runs a SQL query and returns the results', async () => { | ||
const query = 'SELECT * FROM table_name' | ||
const result = await datasette.runQuery(query) | ||
|
||
expect(result).toHaveProperty('columns') | ||
GeorgeGoodall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect(result).toHaveProperty('formattedData') | ||
expect(result).toHaveProperty('rows') | ||
expect(result.formattedData).toHaveLength(2) | ||
expect(result.formattedData[0]).toEqual({ column1: 'value1', column2: 'value2' }) | ||
expect(result.formattedData[1]).toEqual({ column1: 'value3', column2: 'value4' }) | ||
expect(result.columns).toEqual(['column1', 'column2']) | ||
expect(result.rows[0]).toEqual(['value1', 'value2']) | ||
expect(result.rows[1]).toEqual(['value3', 'value4']) | ||
}) | ||
|
||
it('throws an error if the query fails', async () => { | ||
vi.spyOn(axios, 'get').mockRejectedValue(new Error('Query failed')) | ||
|
||
await expect(datasette.runQuery('SELECT * FROM table_name')).rejects.toThrowError('Query failed') | ||
}) | ||
|
||
it('formats data correctly', () => { | ||
const columns = ['column1', 'column2'] | ||
const rows = [['value1', 'value2'], ['value3', 'value4']] | ||
const formattedData = formatData(columns, rows) | ||
|
||
expect(formattedData).toHaveLength(2) | ||
expect(formattedData[0]).toEqual({ column1: 'value1', column2: 'value2' }) | ||
expect(formattedData[1]).toEqual({ column1: 'value3', column2: 'value4' }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is so we can correctly name each of the sub services.
i.e.
provide planning and housing data
submit planning and housing data
manage ...
etc