---
  name: sqmsummary
  decscription: Shows range of MPSAS values for each location
  # No input parametrs
  out_parameters:
    - location
      type: string
    - mmin
      type: float
    - mmean 
      type: float
    - mmax
      type: float
  
  dataservice:
    type: service
    name: RunPostgresQuery
    sql: "SELECT l.name as location, min(value) as mmin, avg(value) as mmean, max(value) as mmax from (
SELECT location, mpsas_1 as value from clearsky.mobilesqmreading
union all
SELECT location, mpsas_2 as value from clearsky.mobilesqmreading
union all
SELECT location, mpsas_3 as value from clearsky.mobilesqmreading
union all
SELECT location, mpsas_4 as value from clearsky.mobilesqmreading
union all
SELECT location, mpsas_5 as value from clearsky.mobilesqmreading) s right outer join
clearsky.location l on s.location = l.lid
group by l.name, l.lid 
order by l.lid"

  renderservice:
    type: embedded
    html: "<div class="container">
  <div>
    <canvas id="myChart"></canvas>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  <script>
    const ctx = document.getElementById('myChart');
  
    new Chart(ctx, {
      type: 'line',
      data: {
        labels: ['Pink', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
        datasets: [{
          label: '# of Votes',
          data: [12, 19, 3, 15, 2, 3],
          borderWidth: 1
        }]
      },
      options: {
        scales: {
          y: {
            beginAtZero: true
          }
        }
      }
    });
  </script>  
</div>"