@@ -48,6 +48,7 @@ impl InstanceProvider {
48
48
instance_type : & InstanceType ,
49
49
template_option : Option < & str > ,
50
50
state_option : Option < & EpsilonState > ,
51
+ get_all : bool ,
51
52
) -> EResult < Vec < Instance > > {
52
53
let mut labels = vec ! [ Label :: get_instance_type_label( instance_type) ] ;
53
54
@@ -61,10 +62,12 @@ impl InstanceProvider {
61
62
62
63
match state_option {
63
64
Some ( state) => Ok ( map
64
- . filter ( |instance| instance. get_state ( ) . eq ( state) )
65
+ . filter ( |instance| instance. get_state ( ) == * state)
65
66
. collect ( ) ) ,
66
67
67
- None => Ok ( map. collect ( ) ) ,
68
+ None => Ok ( map
69
+ . filter ( |instance| get_all || !instance. is_failed ( ) )
70
+ . collect ( ) ) ,
68
71
}
69
72
}
70
73
@@ -167,7 +170,7 @@ pub async fn in_game(instance: &str, instance_provider: &State<Arc<InstanceProvi
167
170
#[ rocket:: get( "/get/<template>" ) ]
168
171
pub async fn get ( template : & str , instance_provider : & State < Arc < InstanceProvider > > ) -> String {
169
172
let instances = instance_provider
170
- . get_instances ( & InstanceType :: Server , Some ( template) , None )
173
+ . get_instances ( & InstanceType :: Server , Some ( template) , None , false )
171
174
. await
172
175
. map_err ( |_| {
173
176
EpsilonError :: ApiServerError ( format ! (
@@ -190,7 +193,7 @@ pub async fn get(template: &str, instance_provider: &State<Arc<InstanceProvider>
190
193
#[ rocket:: get( "/get_all" ) ]
191
194
pub async fn get_all ( instance_provider : & State < Arc < InstanceProvider > > ) -> String {
192
195
let instances = instance_provider
193
- . get_instances ( & InstanceType :: Server , None , None )
196
+ . get_instances ( & InstanceType :: Server , None , None , false )
194
197
. await
195
198
. map_err ( |_| EpsilonError :: ApiServerError ( "Failed to get every instance" . to_string ( ) ) )
196
199
. unwrap ( )
0 commit comments