提交 20b86754 编写于 作者: Y yong.you

fix bug report api

上级 29172b9e
......@@ -73,11 +73,6 @@ public class Handler implements PageHandler<Context> {
BugReportVisitor visitor = new BugReportVisitor();
visitor.visitBugReport(bugReport);
model.setBugReport(bugReport);
bugReport = queryBugReport(payload);
visitor = new BugReportVisitor();
visitor.visitBugReport(bugReport);
Map<String, ErrorStatis> errors = visitor.getErrors();
errors = sortErrorStatis(errors);
model.setErrorStatis(errors);
......@@ -231,7 +226,7 @@ public class Handler implements PageHandler<Context> {
private BugReport queryBugReport(Payload payload) {
Pair<Date, Date> pair = queryStartEndTime(payload);
return m_reportService.queryBugReport(CatString.CAT, pair.getKey(), pair.getValue());
}
......@@ -250,7 +245,9 @@ public class Handler implements PageHandler<Context> {
private Pair<Date, Date> queryStartEndTime(Payload payload) {
Date start = null;
Date end = null;
if (!payload.getAction().getName().startsWith("history")) {
Action action = payload.getAction();
String name = action.getName();
if ((!name.startsWith("history")) && (action != Action.BUG_HTTP_JSON)) {
if (payload.getPeriod().isCurrent()) {
start = new Date(payload.getDate() - TimeUtil.ONE_HOUR);
end = new Date(start.getTime() + TimeUtil.ONE_HOUR);
......@@ -373,12 +370,12 @@ public class Handler implements PageHandler<Context> {
temp.setBugs(MapUtils.sortMap(bugs, compator));
temp.setExceptions(MapUtils.sortMap(exceptions, compator));
}
return errors;
}
public class BugReportVisitor extends BaseVisitor {
private String m_domain;
private Domain m_currentDomain;
private Map<String, ErrorStatis> m_errors = new HashMap<String, ErrorStatis>();
......@@ -398,7 +395,7 @@ public class Handler implements PageHandler<Context> {
@Override
public void visitDomain(Domain domain) {
m_domain = domain.getId();
m_currentDomain= domain;
super.visitDomain(domain);
}
......@@ -406,7 +403,7 @@ public class Handler implements PageHandler<Context> {
public void visitExceptionItem(ExceptionItem exceptionItem) {
String exception = exceptionItem.getId();
int count = exceptionItem.getCount();
Project project = findProjectByDomain(m_domain);
Project project = findProjectByDomain(m_currentDomain.getId());
if (project != null) {
String productLine = project.getProjectLine();
......@@ -415,10 +412,12 @@ public class Handler implements PageHandler<Context> {
statis.setDepartment(department);
statis.setProductLine(productLine);
m_currentDomain.setDepartment(department);
m_currentDomain.setProductLine(productLine);
Map<String, ExceptionItem> items = null;
if (isBug(m_domain, exception)) {
if (isBug(m_currentDomain.getId(), exception)) {
items = statis.getBugs();
} else {
items = statis.getExceptions();
......
......@@ -28,11 +28,19 @@ public class BugReportBuilder implements ReportTaskBuilder {
@Inject
protected ReportService m_reportService;
private SimpleDateFormat m_sdf = new SimpleDateFormat("yyyyMMddHH");
private SimpleDateFormat m_hourly_formate = new SimpleDateFormat("yyyyMMddHH");
private SimpleDateFormat m_daily_formate = new SimpleDateFormat("yyyyMMdd");
@Override
public boolean buildDailyTask(String name, String domain, Date period) {
BugReport bugReport = queryHourlyReportsByDuration(name, domain, period, TaskHelper.tomorrowZero(period));
for (Domain d : bugReport.getDomains().values()) {
d.setProblemUrl(String.format("http://%s/cat/r/p?op=history&reportType=day&domain=%s&date=%s",
getDomainName(), d.getId(), m_daily_formate.format(period)));
}
DailyReport report = new DailyReport();
report.setContent(bugReport.toString());
......@@ -65,7 +73,7 @@ public class BugReportBuilder implements ReportTaskBuilder {
for (Domain d : bugReport.getDomains().values()) {
d.setProblemUrl(String.format("http://%s/cat/r/p?domain=%s&date=%s", getDomainName(), d.getId(),
m_sdf.format(start)));
m_hourly_formate.format(start)));
}
HourlyReport report = new HourlyReport();
......@@ -82,10 +90,10 @@ public class BugReportBuilder implements ReportTaskBuilder {
@Override
public boolean buildMonthlyTask(String name, String domain, Date period) {
BugReport bugReport = queryDailyReportsByDuration(domain, period, TaskHelper.nextMonthStart(period));
for(Domain d :bugReport.getDomains().values()){
d.setProblemUrl(String.format("http://%s/cat/r/p?op=history&reportType=month&domain=%s&date=%s", getDomainName(), d.getId(),
m_sdf.format(period)));
for (Domain d : bugReport.getDomains().values()) {
d.setProblemUrl(String.format("http://%s/cat/r/p?op=history&reportType=month&domain=%s&date=%s",
getDomainName(), d.getId(), m_daily_formate.format(period)));
}
MonthlyReport report = new MonthlyReport();
......@@ -103,9 +111,9 @@ public class BugReportBuilder implements ReportTaskBuilder {
public boolean buildWeeklyTask(String name, String domain, Date period) {
BugReport bugReport = queryDailyReportsByDuration(domain, period, new Date(period.getTime() + TimeUtil.ONE_WEEK));
for(Domain d :bugReport.getDomains().values()){
d.setProblemUrl(String.format("http://%s/cat/r/p?op=history&reportType=week&domain=%s&date=%s", getDomainName(), d.getId(),
m_sdf.format(period)));
for (Domain d : bugReport.getDomains().values()) {
d.setProblemUrl(String.format("http://%s/cat/r/p?op=history&reportType=week&domain=%s&date=%s",
getDomainName(), d.getId(), m_daily_formate.format(period)));
}
WeeklyReport report = new WeeklyReport();
String content = bugReport.toString();
......@@ -154,10 +162,6 @@ public class BugReportBuilder implements ReportTaskBuilder {
}
com.dianping.cat.home.bug.entity.BugReport bugReport = merger.getBugReport();
for(Domain d :bugReport.getDomains().values()){
d.setProblemUrl(String.format("http://%s/cat/r/p?op=history&reportType=day&domain=%s&date=%s", getDomainName(), d.getId(),
m_sdf.format(start)));
}
return bugReport;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册