@@ -42,14 +42,12 @@ define(
42
42
* @param REMS_WS_URL The location of the REMS telemetry data.
43
43
* @constructor
44
44
*/
45
- function RemsTelemetryServerAdapter ( $q , $ http, $log , REMS_WS_URL ) {
45
+ function RemsTelemetryServerAdapter ( $http , $log , REMS_WS_URL ) {
46
46
this . localDataURI = module . uri . substring ( 0 , module . uri . lastIndexOf ( '/' ) + 1 ) + LOCAL_DATA ;
47
- this . deferreds = { } ;
48
47
this . REMS_WS_URL = REMS_WS_URL ;
49
- this . $q = $q ;
50
48
this . $http = $http ;
51
49
this . $log = $log ;
52
- this . cache = undefined ;
50
+ this . promise = undefined ;
53
51
}
54
52
55
53
/**
@@ -65,15 +63,10 @@ define(
65
63
*/
66
64
RemsTelemetryServerAdapter . prototype . requestHistory = function ( request ) {
67
65
var self = this ,
68
- id = request . key ,
69
- deferred = this . $q . defer ( ) ;
66
+ id = request . key ;
70
67
71
68
function processResponse ( response ) {
72
69
var data = [ ] ;
73
- /*
74
- * Currently all data is returned for entire history of the mission. Cache response to avoid unnecessary re-queries.
75
- */
76
- self . cache = response ;
77
70
/*
78
71
* History data is organised by Sol. Iterate over sols...
79
72
*/
@@ -110,17 +103,15 @@ define(
110
103
}
111
104
112
105
function packageAndResolve ( results ) {
113
- deferred . resolve ( { id : id , values : results } ) ;
106
+ return { id : id , values : results } ;
114
107
}
115
108
116
109
117
- this . $q . when ( this . cache || this . $http . get ( this . REMS_WS_URL ) )
110
+ return ( this . promise = this . promise || this . $http . get ( this . REMS_WS_URL ) )
118
111
. catch ( fallbackToLocal )
119
112
. then ( processResponse )
120
113
. then ( filterResults )
121
114
. then ( packageAndResolve ) ;
122
-
123
- return deferred . promise ;
124
115
} ;
125
116
126
117
/**
@@ -132,7 +123,6 @@ define(
132
123
* @returns {Promise | Array<RemsTelemetryValue> } that resolves with an Array of {@link RemsTelemetryValue} objects for the request data key.
133
124
*/
134
125
RemsTelemetryServerAdapter . prototype . history = function ( request ) {
135
- var id = request . key ;
136
126
return this . requestHistory ( request ) ;
137
127
} ;
138
128
0 commit comments