Skip to content

Commit 8df580b

Browse files
committed
update encode username (part 2)
1 parent 44d86a3 commit 8df580b

3 files changed

Lines changed: 17 additions & 20 deletions

File tree

connectedScatterPlot/src/js/simulation.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Simulation {
44
interval=1000;
55
integrate=1.5*60*1000;
66
index=0;
7-
#currentTime;
7+
currentTime;
88
isRealTime; userDict={}; userReverseDict={};
99
query;
1010
callbackStop = ()=>{};
@@ -16,26 +16,23 @@ class Simulation {
1616
constructor(url) {
1717
this.isRealTime = !url;
1818
if (!this.isRealTime) {
19-
console.time('load data')
2019
let updatePromise=(_.isString(url)?d3.json(url):url).then((data) => {
2120
data.time_stamp = data.time_stamp.map(d=>new Date(d/1000000));
22-
d3.keys(data.jobs_info).forEach(jID=>{
23-
// if (!this.userDict[data.jobs_info[jID].user_name])
24-
// this.userDict[data.jobs_info[jID].user_name] = 'user'+d3.keys(this.userDict).length;
25-
// data.jobs_info[jID].user_name = this.userDict[data.jobs_info[jID].user_name];
26-
data.jobs_info[jID].node_list_obj = {};
27-
data.jobs_info[jID].node_list = data.jobs_info[jID].node_list.map(c=>{
28-
let split = c.split('-');
29-
data.jobs_info[jID].node_list_obj[split[0]] = +split[1];
30-
return split[0];
31-
});
21+
d3.keys(data.jobs_info).forEach(jID=>{if (!this.userDict[data.jobs_info[jID].user_name] && !this.userReverseDict[data.jobs_info[jID].user_name]){
22+
const encoded = 'user'+d3.keys(this.userDict).length;
23+
this.userDict[data.jobs_info[jID].user_name] = encoded;
24+
this.userReverseDict[encoded] = data.jobs_info[jID].user_name;
25+
data.jobs_info[jID].user_name = this.userDict[data.jobs_info[jID].user_name];
26+
}else if (!this.userReverseDict[data.jobs_info[jID].user_name]){
27+
data.jobs_info[jID].user_name = this.userDict[data.jobs_info[jID].user_name];
28+
}
29+
data.jobs_info[jID].node_list = data.jobs_info[jID].node_list.map(c=>c.split('-')[0]);
3230
if(data.jobs_info[jID].start_time>9999999999999)
3331
{data.jobs_info[jID].start_time = data.jobs_info[jID].start_time/1000000
3432
data.jobs_info[jID].submit_time = data.jobs_info[jID].submit_time/1000000
3533
if (data.jobs_info[jID].finish_time && data.jobs_info[jID].finish_time>9999999999999)
3634
data.jobs_info[jID].finish_time = data.jobs_info[jID].finish_time/1000000}
3735
});
38-
console.timeEnd('load data')
3936
this.data = data;
4037
this.onTimeChange.forEach(function(listener) {
4138
listener(d3.extent(data.time_stamp));
@@ -72,7 +69,7 @@ class Simulation {
7269
updatePromise = updatePromise.then(listener);
7370
});
7471
this.onUpdateTime.forEach(function (listener) {
75-
updatePromise = updatePromise.then(() => listener(self.#currentTime));
72+
updatePromise = updatePromise.then(() => listener(self.currentTime));
7673
});
7774
}else{
7875
this.stop()
@@ -97,8 +94,8 @@ class Simulation {
9794
}
9895
requestFromData(index){
9996
const self = this;
100-
return new Promise((resolve,refuse)=>{
101-
let timer;
97+
return new Promise((resolve,refuse)=>{
98+
let timer;
10299
if (!this.data){
103100
timer = d3.interval(update,100);
104101
}
@@ -122,20 +119,20 @@ class Simulation {
122119
})
123120
});
124121
const time_stamp = [currentTime];
125-
self.#currentTime = currentTime;
122+
self.currentTime = currentTime;
126123
self.index ++;
127124
resolve({jobs_info, nodes_info, time_stamp,currentTime})
128125

129126
}
130127
}
131-
});
128+
});
132129
}
133130
getRunningJob(currentTime){
134131
return {}
135132
}
136133
requestFromURL(start,end){
137134
const self = this;
138-
// todo need method to cancle
135+
// todo need method to cancle
139136
console.time('request time: ')
140137
const _end = end??new Date(); //'2020-02-14T12:00:00-05:00'
141138
let _start = start??new Date(_end - self.interval); //'2020-02-14T18:00:00-05:
@@ -158,7 +155,7 @@ class Simulation {
158155
data.jobs_info[jID].finish_time = data.jobs_info[jID].finish_time/1000000}
159156
})
160157
data.currentTime = _.last(data.time_stamp);
161-
self.#currentTime = data.currentTime;
158+
self.currentTime = data.currentTime;
162159
self.data = data;
163160
console.timeEnd('request time: ')
164161
return data;

src/image/ConnectedScatterplot.png

132 KB
Loading

src/image/JobPCA.PNG

93.2 KB
Loading

0 commit comments

Comments
 (0)