<commit_before>//   Copyright 2017 MSolution.IO
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package diff

import (
	"context"
	"fmt"
	"net/http"
	"strconv"
	"time"

	"github.com/trackit/jsonlog"
	"github.com/trackit/trackit2/db"
	"github.com/trackit/trackit2/es"
	"github.com/trackit/trackit2/routes"
	"github.com/trackit/trackit2/users"

	"gopkg.in/olivere/elastic.v5"
)

type usageType = map[string]interface{}

// validAggregationPeriodMap is a map that defines the aggregation period
// accepted by the diff route
var validAggregationPeriodMap = map[string]struct{}{
	"month": struct{}{},
	"week":  struct{}{},
}

// esQueryParams will store the parsed query params
type esQueryParams struct {
	dateBegin         time.Time
	dateEnd           time.Time
	accountList       []string
	aggregationPeriod string
}

// diffQueryArgs allows to get required queryArgs params
var diffQueryArgs = []routes.QueryArg{
	routes.QueryArg{
		Name:        "aas",
		Description: "List of comma separated AWS accounts ids",
		Type:        routes.QueryArgStringSlice{},
		Optional:    true,
	},
	routes.QueryArg{
		Name:        "begin",
		Description: "Begining of date interval. Format is ISO8601",
		Type:        routes.QueryArgDate{},
		Optional:    false,
	},
	routes.QueryArg{
		Name:        "end",
		Description: "End of date interval. Format is ISO8601",
		Type:        routes.QueryArgDate{},
		Optional:    false,
	},<commit_msg>diff: reuse aws.AwsAccountsOptionalQueryArg instead of redefining it<commit_after>//   Copyright 2017 MSolution.IO
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package diff

import (
	"context"
	"fmt"
	"net/http"
	"strconv"
	"time"

	"github.com/trackit/jsonlog"
	"github.com/trackit/trackit2/aws"
	"github.com/trackit/trackit2/db"
	"github.com/trackit/trackit2/es"
	"github.com/trackit/trackit2/routes"
	"github.com/trackit/trackit2/users"

	"gopkg.in/olivere/elastic.v5"
)

type usageType = map[string]interface{}

// validAggregationPeriodMap is a map that defines the aggregation period
// accepted by the diff route
var validAggregationPeriodMap = map[string]struct{}{
	"month": struct{}{},
	"week":  struct{}{},
}

// esQueryParams will store the parsed query params
type esQueryParams struct {
	dateBegin         time.Time
	dateEnd           time.Time
	accountList       []string
	aggregationPeriod string
}

// diffQueryArgs allows to get required queryArgs params
var diffQueryArgs = []routes.QueryArg{
	aws.AwsAccountsOptionalQueryArg,
	routes.QueryArg{
		Name:        "begin",
		Description: "Begining of date interval. Format is ISO8601",
		Type:        routes.QueryArgDate{},
		Optional:    false,
	},
	routes.QueryArg{
		Name:        "end",
		Description: "End of date interval. Format is ISO8601",
		Type:        routes.QueryArgDate{},
		Optional:    false,
	},
{'fraction_non_alphanumeric': 0.10541310541310542, 'fraction_numerical': 0.011137011137011137, 'mean_word_length': 3.3687782805429864, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4771693', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1191, 'n_words': 379}