Examples of ProblemStatistics


Examples of cn.edu.zju.acm.onlinejudge.util.ProblemStatistics

        String orderBy = context.getRequest().getParameter("orderBy");
        if (!"date".equals(orderBy) && !"memory".equals(orderBy)) {
            orderBy = "time";
        }
        if (problem != null) {
            ProblemStatistics statistics =
                    StatisticsManager.getInstance().getProblemStatistics(problem.getId(), orderBy, 20);
            context.setAttribute("ProblemStatistics", statistics);

        }
View Full Code Here

Examples of cn.edu.zju.acm.onlinejudge.util.ProblemStatistics

    }

    public ProblemStatistics getProblemStatistics(long problemId, String orderBy, int count) throws PersistenceException {
        Connection conn = null;
        String ob = null;
        ProblemStatistics ret = null;

        if ("time".equals(orderBy)) {
            ob = "s.time_consumption ASC,memory_consumption ASC,s.submission_date ASC";
            ret = new ProblemStatistics(problemId, "time");
        } else if ("memory".equals(orderBy)) {
            ob = "s.memory_consumption ASC,s.time_consumption ASC,submission_date ASC";
            ret = new ProblemStatistics(problemId, "memory");
        } else {
            ob = "s.submission_date ASC,s.time_consumption ASC,memory_consumption ASC";
            ret = new ProblemStatistics(problemId, "date");
        }

        Map<Long, Language> languageMap = PersistenceManager.getInstance().getLanguagePersistence().getLanguageMap();
        try {
            conn = Database.createConnection();
            PreparedStatement ps = null;
            try {
                ps =
                        conn
                            .prepareStatement("SELECT judge_reply_id, count(*) FROM submission WHERE problem_id=? GROUP BY judge_reply_id");

                ps.setLong(1, problemId);
                ResultSet rs = ps.executeQuery();

                while (rs.next()) {
                    long jid = rs.getLong(1);
                    int c = rs.getInt(2);
                    ret.setCount(jid, c);
                }
            } finally {
                Database.dispose(ps);
            }
            String sql =
                    SubmissionPersistenceImpl.GET_SUBMISSIONS + " AND s.problem_id=? AND s.judge_reply_id=? ORDER BY " +
                        ob + " LIMIT " + count;
            sql = sql.replace("FORCE_INDEX", "USE INDEX (index_submission_problem_reply)");
            try {
                ps = conn.prepareStatement(sql);
                ps.setLong(1, problemId);
                ps.setLong(2, JudgeReply.ACCEPTED.getId());
                ResultSet rs = ps.executeQuery();
                List<Submission> submissions = new ArrayList<Submission>();
                while (rs.next()) {
                    Submission submission = this.populateSubmission(rs, false, languageMap);
                    submissions.add(submission);
                }
                ret.setBestRuns(submissions);
                return ret;
            } finally {
                Database.dispose(ps);
            }
        } catch (SQLException e) {
View Full Code Here

Examples of com.dianping.cat.report.page.problem.ProblemStatistics

  public Map<Object, Object> getRenderResult() {
    return m_result;
  }

  public void visitProblemReport(ProblemReport report) {
    ProblemStatistics problemStatistics = new ProblemStatistics();
    problemStatistics.setAllIp(true);

    problemStatistics.visitProblemReport(report);

    Collection<TypeStatistics> status = problemStatistics.getStatus().values();
    for (TypeStatistics statistic : status) {
      String type = statistic.getType();
      int count = statistic.getCount();
      String graphUrl = buildGraphUrl(type);
      Type temp = new Type();
View Full Code Here

Examples of com.dianping.cat.report.page.problem.ProblemStatistics

    }
  }

  private void buildProblemReportResult(ProblemReport problemReport, String ip, String type, String name,
        Map<String, String> data) {
    ProblemStatistics problemStatistics = new ProblemStatistics();

    if (ip.equalsIgnoreCase(Payload.ALL)) {
      problemStatistics.setAllIp(true);
    } else {
      problemStatistics.setIp(ip);
    }
    problemStatistics.visitProblemReport(problemReport);

    if (StringUtils.isEmpty(name) && StringUtils.isEmpty(type)) {
      Map<String, TypeStatistics> status = problemStatistics.getStatus();

      for (Entry<String, TypeStatistics> temp : status.entrySet()) {
        String key = temp.getKey();
        TypeStatistics value = temp.getValue();
        data.put(key + COUNT, String.valueOf(value.getCount()));
      }
    } else if (StringUtils.isEmpty(name) && !StringUtils.isEmpty(type)) {
      Map<String, TypeStatistics> status = problemStatistics.getStatus();
      TypeStatistics value = status.get(type);

      if (value != null) {
        data.put(COUNT, String.valueOf(value.getCount()));
        for (Entry<String, StatusStatistics> temp : value.getStatus().entrySet()) {
          data.put(temp.getKey() + COUNT, String.valueOf(temp.getValue().getCount()));
        }
      }
    } else if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(type)) {
      Map<String, TypeStatistics> status = problemStatistics.getStatus();
      TypeStatistics value = status.get(type);

      if (value != null) {
        StatusStatistics nameValue = value.getStatus().get(name);
        if (nameValue != null) {
View Full Code Here

Examples of com.dianping.cat.report.page.problem.ProblemStatistics

    }
    resultMap.put("distributeMap", distributes);
  }

  private void addFailureInfo(Map<Object, Object> resultMap, ProblemReport report) {
    ProblemStatistics problemStatistics = new ProblemStatistics();
    problemStatistics.setAllIp(true);
    problemStatistics.visitProblemReport(report);
    TypeStatistics failureStatus = problemStatistics.getStatus().get("error");

    if (failureStatus != null) {
      Map<Object, Object> statusMap = new HashMap<Object, Object>();

      for (StatusStatistics status : failureStatus.getStatus().values()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.