MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / mod_usage_servers

Method mod_usage_servers

mserver/MasterService/src/service.rs:199–226  ·  view source on GitHub ↗
(&self, mod_id: &str)

Source from the content-addressed store, hash-verified

197 .collect::<Vec<_>>();
198
199 versions.sort_by(|lhs, rhs| {
200 (lhs.mod_id != current.mod_id)
201 .cmp(&(rhs.mod_id != current.mod_id))
202 .then_with(|| rhs.version.cmp(&lhs.version))
203 .then_with(|| lhs.mod_id.cmp(&rhs.mod_id))
204 });
205 Ok(versions)
206 }
207
208 pub async fn mod_usage_servers(&self, mod_id: &str) -> Result<Vec<ModUsageServer>> {
209 let mut servers = self
210 .directory
211 .list(&ListServersQuery::default(), now_unix_millis())
212 .await?
213 .into_iter()
214 .filter(|server| {
215 split_server_mods(&server.mod_list)
216 .iter()
217 .any(|candidate| candidate == mod_id)
218 })
219 .map(|server| ModUsageServer {
220 server_id: server.server_id,
221 hostname: server.hostname,
222 gametype: server.gametype,
223 players: server.numplayers,
224 max_players: server.maxplayers,
225 password: server.password,
226 })
227 .collect::<Vec<_>>();
228
229 servers.sort_by(|lhs, rhs| {

Callers 1

list_mod_serversFunction · 0.80

Calls 3

now_unix_millisFunction · 0.85
split_server_modsFunction · 0.85
listMethod · 0.45

Tested by

no test coverage detected