1 |
60959
|
konstantin
|
//version compatibility: 1.0.0-SNAPSHOT
|
2 |
|
|
print("here");
|
3 |
|
|
|
4 |
|
|
function setUserTokenCreationDate(){
|
5 |
|
|
print("\n\n setUserTokenCreationDate \n\n");
|
6 |
|
|
|
7 |
|
|
works = db.work.aggregate(
|
8 |
|
|
[
|
9 |
|
|
{ $sort: { orcid: 1, creationDate: 1 } },
|
10 |
|
|
{
|
11 |
|
|
$group:
|
12 |
|
|
{
|
13 |
|
|
_id: "$orcid",
|
14 |
|
|
creationDate: { $first: "$creationDate" }
|
15 |
|
|
}
|
16 |
|
|
}
|
17 |
|
|
]
|
18 |
|
|
);
|
19 |
|
|
|
20 |
|
|
while (works.hasNext()) {
|
21 |
|
|
var work = works.next();
|
22 |
|
|
print("\n\n");
|
23 |
|
|
print("DATE OF FIRST WORK FOR ORCID: ",tojson(work));
|
24 |
|
|
userTokens = db.userTokens.find({"orcid": work['_id']}).map(function (userToken) { return userToken; });
|
25 |
|
|
|
26 |
|
|
for(var i=0; i<userTokens.length; i++) {
|
27 |
|
|
var userToken = userTokens[i];
|
28 |
|
|
// print("OLD userToken: ",tojson(userToken));
|
29 |
|
|
|
30 |
|
|
userToken['creationDate'] = work['creationDate'];
|
31 |
|
|
|
32 |
|
|
print(tojson(userToken));
|
33 |
|
|
db.userTokens.save(userToken);
|
34 |
|
|
}
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
function setDashboardInWorks() {
|
40 |
|
|
print("\n\n setDashboardInWorks \n\n");
|
41 |
|
|
var works = db.work.find().map(function (work) { return work; });
|
42 |
|
|
|
43 |
|
|
for(var i=0; i<works.length; i++) {
|
44 |
|
|
var current_work = works[i];
|
45 |
|
|
current_work['dashboard'] = "production_explore";
|
46 |
|
|
db.work.save(current_work);
|
47 |
|
|
}
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
use openaire_orcid;
|
51 |
|
|
|
52 |
|
|
// 29-03-2021 - 20-04-2021
|
53 |
|
|
// setUserTokenCreationDate();
|
54 |
|
|
// setDashboardInWorks();
|