-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from FUB-HCC/34-simulate-wtas
34 simulate wtas
- Loading branch information
Showing
37 changed files
with
2,942 additions
and
2,401 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
File renamed without changes.
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
File renamed without changes.
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,4 +1,4 @@ | ||
FROM node:9 | ||
FROM node:latest | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
This file was deleted.
Oops, something went wrong.
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,81 @@ | ||
const MWC = require('nodemw'); | ||
const Promise = require('bluebird'); | ||
|
||
const ikoncode = Promise.promisifyAll(new MWC(process.env.IKONCODE)); | ||
ikoncode.api = Promise.promisifyAll(ikoncode.api, { multiArgs: true }); | ||
|
||
// connect to IKON CODE | ||
exports.wikiLogin = () => { | ||
try { | ||
return (ikoncode.logInAsync()); | ||
} catch (e) { | ||
console.log(e); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
const fetchAllProjects = async (login) => { | ||
try { | ||
await login; | ||
} catch (e) { | ||
console.log(e); | ||
process.exit(1); | ||
} | ||
|
||
let projects = []; | ||
|
||
try { | ||
const params1 = { | ||
action: 'ask', | ||
query: '[[Category:Drittmittelprojekt]][[RedaktionelleBeschreibung::+]][[Status::Freigegeben]]|?Identifier|limit=100000', | ||
}; | ||
projects = await ikoncode.api.callAsync(params1); | ||
console.log(Object.keys(projects[2].query.results)); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
|
||
const results = []; | ||
for (const key of Object.keys(projects[2].query.results)) { | ||
try { | ||
const params2 = { | ||
action: 'browsebysubject', | ||
subject: key, | ||
}; | ||
results.push(ikoncode.api.callAsync(params2)); | ||
} catch (e) { | ||
console.log(params2, e); | ||
} | ||
} | ||
// for some reason this is necessary | ||
await Promise.all(results); | ||
return Promise.all(results); | ||
}; | ||
|
||
const getNameMapping = (name) => { | ||
const mapping = { | ||
Projektbeginn: 'funding_start_year', | ||
Projektende: 'funding_end_year', | ||
Zusammenfassung: 'project_summary', | ||
subject: 'id', | ||
RedaktionelleBeschreibung: 'description', | ||
HatFach: 'participating_subject_area', | ||
TitelProjekt: 'title', | ||
HatOrganisationseinheit: 'organisational_unit', | ||
Akronym: 'acronym', | ||
|
||
}; | ||
|
||
return (Object.keys(mapping).includes(name)) ? mapping[name] : name; | ||
}; | ||
|
||
exports.getAllProjects = async (loginPromise) => { | ||
return (await fetchAllProjects(loginPromise)).map(([a, b, { query: { subject, data } }]) => data.reduce((dict, { property, dataitem }) => { | ||
dict[getNameMapping(property)] = dataitem.map(({ item }) => item); | ||
return dict; | ||
}, { subject })); | ||
} | ||
|
||
exports.parseMediaWikiResponse = (response) => { | ||
|
||
} |
Oops, something went wrong.