-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automatically software data from HAL optionally, enabling by env config resolve #160
- Loading branch information
1 parent
3895422
commit e89dd00
Showing
12 changed files
with
159 additions
and
16 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
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,7 @@ | ||
import { fetchHalSoftwares } from "./getHalSoftware"; | ||
|
||
export const halAPIGateway = { | ||
software: { | ||
getAll: fetchHalSoftwares | ||
} | ||
}; |
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,37 @@ | ||
import { DbApiV2 } from "../ports/DbApiV2"; | ||
import { halAPIGateway } from "../adapters/hal"; | ||
import { halRawSoftwareToSoftwareForm } from "../adapters/hal/halRawSoftware"; | ||
|
||
export const importFromHALSource: (dbApi: DbApiV2) => (agentEmail: string) => Promise<Promise<number | undefined>[]> = ( | ||
dbApi: DbApiV2 | ||
) => { | ||
return async (agentEmail: string) => { | ||
const agent = await dbApi.agent.getByEmail(agentEmail); | ||
const agentId = agent | ||
? agent.id | ||
: await dbApi.agent.add({ | ||
email: agentEmail, | ||
"isPublic": false, | ||
organization: "", | ||
about: "This is an bot user created to import data." | ||
}); | ||
|
||
const softwares = await halAPIGateway.software.getAll(); | ||
const dbSoftwares = await dbApi.software.getAll(); | ||
const dbSoftwaresNames = dbSoftwares.map(software => { | ||
return software.softwareName; | ||
}); | ||
|
||
return softwares.map(async software => { | ||
const newSoft = halRawSoftwareToSoftwareForm(software); | ||
const index = dbSoftwaresNames.indexOf(newSoft.softwareName); | ||
|
||
if (index != -1) { | ||
return dbSoftwares[index].softwareId; | ||
} else { | ||
console.log("Importing HAL : ", software.docid); | ||
return dbApi.software.create({ formData: newSoft, externalDataOrigin: "HAL", agentId: agentId }); | ||
} | ||
}); | ||
}; | ||
}; |
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 |
---|---|---|
|
@@ -31,7 +31,9 @@ export const createTestCaller = async ({ user }: TestCallerConfig = { user: defa | |
"githubPersonalAccessTokenForApiRateLimit": "fake-token", | ||
"doPerPerformPeriodicalCompilation": false, | ||
"doPerformCacheInitialization": false, | ||
"externalSoftwareDataOrigin": externalSoftwareDataOrigin | ||
"externalSoftwareDataOrigin": externalSoftwareDataOrigin, | ||
"botAgentEmail": "[email protected]", | ||
"initializeSoftwareFromSource": false | ||
}); | ||
|
||
const jwtClaimByUserKey = { | ||
|
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 |
---|---|---|
|
@@ -12,6 +12,8 @@ SILL_GITHUB_TOKEN=xxxxx | |
SILL_API_PORT=3084 | ||
SILL_IS_DEV_ENVIRONNEMENT=true | ||
SILL_EXTERNAL_SOFTWARE_DATA_ORIGIN=wikidata | ||
INIT_SOFT_FROM_SOURCE=false | ||
BOT_AGENT_EMAIL=[email protected] | ||
|
||
DATABASE_URL=postgresql://sill:pg_password@localhost:5432/sill | ||
POSTGRES_DB=sill | ||
|