-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edit the IUCN Classification section in the Project View page (#173)
* wip * editing of iucn * fix
- Loading branch information
1 parent
023768c
commit 76371a0
Showing
11 changed files
with
202 additions
and
40 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect } from 'chai'; | ||
import { describe } from 'mocha'; | ||
import { deleteIUCNSQL } from './project-delete-queries'; | ||
|
||
describe('deleteIUCNSQL', () => { | ||
it('returns null response when null projectId provided', () => { | ||
const response = deleteIUCNSQL((null as unknown) as number); | ||
|
||
expect(response).to.be.null; | ||
}); | ||
|
||
it('returns non null response when valid projectId provided', () => { | ||
const response = deleteIUCNSQL(1); | ||
|
||
expect(response).to.not.be.null; | ||
}); | ||
}); |
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,40 @@ | ||
import { SQL, SQLStatement } from 'sql-template-strings'; | ||
import { getLogger } from '../../utils/logger'; | ||
|
||
const defaultLog = getLogger('queries/project/project-delete-queries'); | ||
|
||
/** | ||
* SQL query to delete project IUCN rows. | ||
* | ||
* @param {projectId} projectId | ||
* @returns {SQLStatement} sql query object | ||
*/ | ||
export const deleteIUCNSQL = (projectId: number): SQLStatement | null => { | ||
defaultLog.debug({ | ||
label: 'deleteIUCNSQL', | ||
message: 'params', | ||
projectId | ||
}); | ||
|
||
if (!projectId) { | ||
return null; | ||
} | ||
|
||
const sqlStatement: SQLStatement = SQL` | ||
DELETE | ||
from project_iucn_action_classification | ||
WHERE | ||
p_id = ${projectId} | ||
RETURNING | ||
*; | ||
`; | ||
|
||
defaultLog.debug({ | ||
label: 'deleteProjectSQL', | ||
message: 'sql', | ||
'sqlStatement.text': sqlStatement.text, | ||
'sqlStatement.values': sqlStatement.values | ||
}); | ||
|
||
return sqlStatement; | ||
}; |
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
Oops, something went wrong.