def generatePageloadEventQuery_OS_segments()

in lib/telemetry.py [0:0]


  def generatePageloadEventQuery_OS_segments(self, metric):
    t = get_template("experiment/glean/pageload_events_os_segments.sql")

    print(self.config['pageload_event_metrics'][metric])

    metricMin = self.config['pageload_event_metrics'][metric]['min']
    metricMax = self.config['pageload_event_metrics'][metric]['max']

    isp_blacklist = []
    if 'isp_blacklist' in self.config:
      with open(self.config['isp_blacklist'], 'r') as file:
        isp_blacklist = [line.strip() for line in file]

    context = {
        "include_non_enrolled_branch": self.config['include_non_enrolled_branch'],
        "minVal": metricMin,
        "maxVal": metricMax,
        "slug": self.config['slug'],
        "channel": self.config['channel'],
        "startDate": self.config['startDate'],
        "endDate": self.config['endDate'],
        "metric": metric,
        "blacklist": isp_blacklist
    }
    query = t.render(context)
    # Remove empty lines before returning
    query = "".join([s for s in query.strip().splitlines(True) if s.strip()])
    self.queries.append({
      "name": f"Pageload event: {metric}",
      "query": query
    })
    return query