{"size": 926, "ext": "js", "max_stars_repo_path": "app/sections/table-trend/config/Controller.js", "max_stars_repo_name": "codaxy/wb-data-reports", "max_stars_repo_stars_event_min_datetime": "2017-04-11T17:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-02T23:28:22.000Z", "max_issues_repo_path": "app/sections/table-trend/config/Controller.js", "max_issues_repo_name": "codaxy/wb-data-reports", "max_issues_repo_issues_event_min_datetime": "2017-09-13T16:24:35.000Z", "max_issues_repo_issues_event_max_datetime": "2017-09-18T11:06:24.000Z", "max_forks_repo_path": "app/sections/table-trend/config/Controller.js", "max_forks_repo_name": "codaxy/wb-data-reports", "max_forks_repo_forks_event_min_datetime": "2017-09-23T00:46:06.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-21T17:43:22.000Z"}
{"max_stars_count": 13, "max_issues_count": 2, "max_forks_count": 4, "avg_line_length": 19.2916666667, "max_line_length": 75, "alphanum_fraction": 0.5971922246}
import { Controller } from "cx/ui";
import { queryTopics, queryTopicIndicators, queryRegions } from "api/data";

export default class extends Controller {
	onInit() {
		this.store.init({
			fromYear: 2005,
			toYear: 2015
		});

		this.addTrigger(
			"fromYear",
			["fromYear"],
			fy => {
				let ty = this.store.get("toYear");
				if (fy + 10 < ty) this.store.set("toYear", fy + 10);
				if (ty < fy) this.store.set("toYear", fy);
			},
			true
		);

		this.addTrigger(
			"toYear",
			["toYear"],
			ty => {
				let fy = this.store.get("fromYear");
				if (fy + 10 < ty) this.store.set("fromYear", ty - 10);
				if (ty < fy) this.store.set("fromYear", ty);
			},
			true
		);
	}

	queryTopics(q) {
		return queryTopics(q);
	}

	queryRegions(q) {
		return queryRegions(q);
	}

	queryTopicIndicators(q) {
		let topicId = this.store.get("topic.id");
		if (!topicId) return [];
		return queryTopicIndicators(topicId, q);
	}
}
