{"size": 896, "ext": "js", "max_stars_repo_path": "list_host_services_by_service_regex.js", "max_stars_repo_name": "amroot/browser-scripts", "max_stars_repo_stars_event_min_datetime": "2016-04-12T19:46:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-27T18:18:22.000Z", "max_issues_repo_path": "list_host_services_by_service_regex.js", "max_issues_repo_name": "amroot/browser-scripts", "max_issues_repo_issues_event_min_datetime": "2015-03-20T04:32:36.000Z", "max_issues_repo_issues_event_max_datetime": "2016-12-25T08:34:37.000Z", "max_forks_repo_path": "list_host_services_by_service_regex.js", "max_forks_repo_name": "amroot/browser-scripts", "max_forks_repo_forks_event_min_datetime": "2015-03-24T17:13:27.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-01T17:45:38.000Z"}
{"max_stars_count": 14, "max_issues_count": 3, "max_forks_count": 24, "avg_line_length": 27.1515151515, "max_line_length": 100, "alphanum_fraction": 0.6729910714}
/* eslint-disable no-unused-vars */
/* globals Session Hosts Services Meteor */

function listHostServicesByServiceRegex (serviceRegex) {
  // Logs a list of all services by service regex per host
  //
  // Created by Isaiah Sarju
  // Based on listHostServicesByColor by Matt Burch & changeServicesToSpecifiedColor by Dan Kottmann
  // Usage: listHostServicesByServiceRegex(/.*sql.*/)

  var REGEX = serviceRegex
  var projectId = Session.get('projectId')
  var serviceServices = Services.find({
    'projectId': projectId,
    'service': {
      '$regex': REGEX
    }
  }).fetch()

  if (serviceServices.length < 1) {
    console.log('No services found')
    return
  }

  serviceServices.forEach(function (service) {
    var host = Hosts.findOne({
      'projectId': projectId,
      '_id': service.hostId
    })
    console.log(host.ipv4 + ':' + service.port + '/' + service.protocol)
  })
}
