in analytics-example-widget/scripts/widget/AnalyticsViewActionCreator.ts [44:78]
public requestData(): IPromise<QueryViewState> {
let context = VSS.getWebContext();
this.results.isLoading = true;
if (!areSettingsValid(this.configuration)) {
return this.packErrorMessage("This widget is not properly configured yet.");
}
let now : number = Date.now();
let endDate : Date = new Date(now);
let startDate : Date = new Date(now - (this.rollingPeriodLength * 1000 * 60 * 60 * 24)); // Rolling 60 day period from the current timestamp.
let querySettings = {
projectId: this.configuration.projectId,
teamId: this.configuration.teamId,
workItemType: this.configuration.workItemType,
fields: this.configuration.fields,
startDate: startDate,
endDate: endDate,
aggregation: this.configuration.aggregation
} as BurndownQueryOptions;
return getService(CacheableQueryService).getCacheableQueryResult(new DatesQuery()).then(dates => {
return getService(CacheableQueryService).getCacheableQueryResult(new BurndownResultsQuery(querySettings)).then(groupedWorkItemAggregation => {
if (groupedWorkItemAggregation.length > 0) {
this.results.chartState = new ChartOptionFactory().generateChart(this.size, groupedWorkItemAggregation, dates, this.suppressAnimation)
} else {
this.results.statusMessage = "0 results were found for this query.";
this.results.messageType = WidgetMessageType.Warning;
}
this.results.isLoading = false;
return this.results;
});
});
}