Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Fetch value lists from EDDI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AU - Web og Digital
Fetch value lists from EDDI
Commits
e964d2bd
Commit
e964d2bd
authored
8 years ago
by
Daniel Svane
Browse files
Options
Downloads
Patches
Plain Diff
Using upsert instead of dropping database
parent
bb654c40
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
getvaluefromEDDI.js
+7
-20
7 additions, 20 deletions
getvaluefromEDDI.js
updatefilters.js
+41
-0
41 additions, 0 deletions
updatefilters.js
with
48 additions
and
20 deletions
getvaluefromEDDI.js
+
7
−
20
View file @
e964d2bd
...
@@ -3,32 +3,24 @@ var request = require("request");
...
@@ -3,32 +3,24 @@ var request = require("request");
var
mongo
=
require
(
"
mongodb
"
).
MongoClient
;
var
mongo
=
require
(
"
mongodb
"
).
MongoClient
;
var
ObjectID
=
require
(
"
mongodb
"
).
ObjectID
;
var
ObjectID
=
require
(
"
mongodb
"
).
ObjectID
;
var
mongoUrl
=
"
mongodb://localhost:
27
01
7
/meteor
-kursuskatalog
"
;
var
mongoUrl
=
"
mongodb://localhost:
30
01/meteor
"
;
var
params
=
[
"
programme
"
,
"
period
"
,
"
year
"
,
"
ects
"
,
"
location
"
,
"
department
"
,
"
faculty
"
,
"
instructionLanguage
"
,
"
courseType
"
];
var
params
=
[
"
programme
"
,
"
period
"
,
"
year
"
,
"
ects
"
,
"
location
"
,
"
department
"
,
"
faculty
"
,
"
instructionLanguage
"
,
"
courseType
"
];
var
lang
=
[
"
da
"
,
"
en
"
];
var
lang
=
[
"
da
"
,
"
en
"
];
mongo
.
connect
(
mongoUrl
,
function
(
err
,
db
)
{
db
.
collection
(
"
filters
"
).
drop
();
db
.
close
();
});
var
sortCounter
=
0
;
var
sortCounter
=
0
;
var
getData
=
function
(
lang
,
param
,
sortCounter
)
{
var
getData
=
function
(
lang
,
param
,
sortCounter
)
{
var
url
=
"
https://eddiprod.au.dk/EDDI/webservices/CourseCatalogService2.cfc?method=getValueList&list=
"
+
param
+
"
&lang=
"
+
lang
;
var
url
=
"
https://eddiprod.au.dk/EDDI/webservices/CourseCatalogService2.cfc?method=getValueList&list=
"
+
param
+
"
&lang=
"
+
lang
;
// console.log("Getting data for '"+param+"' with language '"+lang+"'");
// console.log("url"+url);
console
.
log
(
"
start req
"
+
url
);
request
({
url
:
url
,
json
:
true
},
function
(
e
,
res
,
json
)
{
request
({
url
:
url
,
json
:
true
},
function
(
e
,
res
,
json
)
{
var
obj
=
{};
var
obj
=
{};
var
arr
=
[];
var
arr
=
[];
if
(
e
){
throw
e
;
}
console
.
log
(
"
the json
"
+
json
);
if
(
e
){
throw
e
;
}
json
.
listItems
.
forEach
(
function
(
item
)
{
json
.
listItems
.
forEach
(
function
(
item
)
{
arr
.
push
({
id
:
item
.
id
,
name
:
item
[
json
.
listName
]});
arr
.
push
({
id
:
item
.
id
,
name
:
item
[
json
.
listName
]});
...
@@ -43,23 +35,18 @@ var getData = function (lang, param, sortCounter) {
...
@@ -43,23 +35,18 @@ var getData = function (lang, param, sortCounter) {
if
(
json
.
listName
==
"
year
"
)
obj
[
"
default
"
]
=
[
2016
,
2017
];
if
(
json
.
listName
==
"
year
"
)
obj
[
"
default
"
]
=
[
2016
,
2017
];
else
obj
[
"
default
"
]
=
[];
else
obj
[
"
default
"
]
=
[];
console
.
log
(
"
before mongo connect
"
);
mongo
.
connect
(
mongoUrl
,
function
(
err
,
db
)
{
// db.collection("filters").drop();
db
.
collection
(
"
filters
"
).
insert
(
obj
,
function
(
err
,
docs
)
{
mongo
.
connect
(
mongoUrl
,
function
(
err
,
db
)
{
db
.
collection
(
"
filters
"
).
updateOne
({
name
:
obj
.
name
,
lang
:
obj
.
lang
},
obj
,
{
upsert
:
true
},
function
(
err
,
res
){
db
.
close
();
db
.
close
();
});
});
});
});
});
});
};
};
lang
.
forEach
(
function
(
lang
)
{
lang
.
forEach
(
function
(
lang
)
{
params
.
forEach
(
function
(
param
)
{
params
.
forEach
(
function
(
param
)
{
getData
(
lang
,
param
,
sortCounter
);
getData
(
lang
,
param
,
sortCounter
);
sortCounter
=
sortCounter
+
10
;
sortCounter
=
sortCounter
+
10
;
// console.log(param, sortCounter, lang);
});
});
});
});
This diff is collapsed.
Click to expand it.
updatefilters.js
0 → 100644
+
41
−
0
View file @
e964d2bd
var
request
=
require
(
"
request
"
);
var
mongo
=
require
(
"
mongodb
"
).
MongoClient
;
var
ObjectID
=
require
(
"
mongodb
"
).
ObjectID
;
var
mongoUrl
=
"
mongodb://localhost:3001/meteor
"
;
// Params and languages to use in filters
var
params
=
[
"
programme
"
,
"
period
"
,
"
year
"
,
"
ects
"
,
"
location
"
,
"
department
"
,
"
faculty
"
,
"
instructionLanguage
"
,
"
courseType
"
];
var
lang
=
[
"
da
"
,
"
en
"
];
// Database connection
var
db
=
null
;
getParams
(
"
da
"
);
// Gets list of params available from EDDI
function
getParams
(
lang
){
var
url
=
"
https://eddiprod.au.dk/EDDI/webservices/CourseCatalogService2.cfc?method=getValueList&list=&lang=
"
+
lang
;
request
({
url
:
url
,
json
:
true
},
function
(
e
,
res
,
json
)
{
console
.
log
(
params
);
console
.
log
(
json
.
listOfPossibleListNames
.
split
(
"
,
"
));
connectDB
();
});
}
function
connectDB
(){
mongo
.
connect
(
mongoUrl
,
function
(
err
,
database
)
{
db
=
database
;
getLocalList
();
});
};
function
getLocalList
(){
db
.
collection
(
"
filters
"
).
find
({
lang
:
"
en
"
}).
toArray
(
function
(
err
,
docs
){
docs
.
forEach
(
function
(
lol
,
foo
){
console
.
log
(
lol
.
name
);
});
});
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment