You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: range_to_instant.go
    path of file: ./repos/grafana/pkg/services/ngalert/store
    
    the code of the file until where you have to start completion: package store

import (
	"encoding/json"
	"fmt"

	"github.com/grafana/grafana/pkg/expr"
	"github.com/grafana/grafana/pkg/services/datasources"
	"github.com/grafana/grafana/pkg/services/ngalert/models"
)

const (
	grafanaCloudProm  = "grafanacloud-prom"
	grafanaCloudUsage = "grafanacloud-usage"
)

// OptimizeAlertQueries was added to mitigate the high load that could be created by loki range queries.
// In previous versions of Grafana, Loki datasources would default to range queries
// instead of instant queries, sometimes creating unnecessary load. This is only
// done for Grafana Cloud.
func OptimizeAlertQuer
    
func migrateToInstant(queries []models.AlertQuery, optimizations []Optimization) error {
	for _, opti := range optimizations {
		modelRaw := make(map[string]any)
		if err := json.Unmarshal(queries[opti.i].Model, &modelRaw); err != nil {
			return err
		}
		switch opti.t {
		case datasources.DS_PROMETHEUS:
			modelRaw["instant"] = true
			modelRaw["range"] = false
			model, err := json.Marshal(modelRaw)
			if err != nil {
				return err
			}
			queries[opti.i].Model = model
		case datasources.DS_LOKI:
			modelRaw["queryType"] = "instant"
			model, err := json.Marshal(modelRaw)
			if err != nil {
				return err
			}
			queries[opti.i].Model = model
			queries[opti.i].QueryType = "instant"
		default:
			return fmt.Errorf("optimization for datasource of type %s not possible", opti.t)
		}
	}
	return nil
}