kaspars/hunter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kaspars/hunter

Composer 安装命令:

composer require kaspars/hunter

包简介

Hunter is an easy to use uHunt wrapper to receive information from UVA servers.

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage

Introduction

Hunter is an easy to use uHunt wrapper to receive information from UVa's online judge.

Hunter is licensed under the MIT License - see the LICENSE file for details.

Basic Usage

use Hunter\Hunter;

require "vendor/autoload.php";

$hunter = new Hunter();

echo $hunter->getIdFromUsername("Kaspars");

Installing

With Composer

The easiest and recommended method to install Hunter is via composer.

Use the following command to install with composer.

$ composer require kaspars/hunter

If you wish you can create the following composer.json file and run composer install to install it.

{
   "require": {
      "kaspars/hunter": "~1.0"
   }
}

Direct Download

First of all, you really should use composer.. But if you insist, then just copy the content from src folder into your project

Data Format

All data is returned as an associated array.

Problem format

  • id Problem ID
  • number Problem number
  • title Problem title
  • dacu Number of distinct accepted users
  • bestRuntime Best runtime in milliseconds of an Accepted Submission
  • verdicts An array given verdicts
    • Hunter\Status::NO_VERDICT Number of No Verdict Given (can be ignored)
    • Hunter\Status::SUBMISSION_ERROR Number of Submission Error
    • Hunter\Status::CANT_BE_JUDGED Number of Can't be Judged
    • Hunter\Status::IN_QUEUE Number of In Queue
    • Hunter\Status::COMPILATION_ERROR Number of Compilation Error
    • Hunter\Status::RESTRICTED_FUNCTION Number of Restricted Function
    • Hunter\Status::RUNTIME_ERROR Number of Runtime Error
    • Hunter\Status::OUTPUT_LIMIT Number of Output Limit Exceeded
    • Hunter\Status::TIME_LIMIT Number of Time Limit Exceeded
    • Hunter\Status::MEMORY_LIMIT Number of Memory Limit Exceeded
    • Hunter\Status::WRONG_ANSWER Number of Wrong Answer
    • Hunter\Status::PRESENTATION_ERROR Number of Presentation Error
    • Hunter\Status::ACCEPTED Number of Accepted
  • limit Problem runtime limit in milliseconds
  • status Problem Status
    • Hunter\Status::UNAVAILABLE Unavailable
    • Hunter\Status::Normal Normal
    • Hunter\Status::SPECIAL_JUDGE A special judging program is used.
  • rejudged Last time (unix timestamp) the problem was rejudged, null if never.

Submission format

  • id Submission`s ID
  • user User ID
  • name User's full name
  • username User`s username
  • problem Problem's ID
  • verdict Given verdict
    • Hunter\Status::SUBMISSION_ERROR Submission Error
    • Hunter\Status::CANT_BE_JUDGED Can't be Judged
    • Hunter\Status::IN_QUEUE In Queue
    • Hunter\Status::COMPILATION_ERROR Compilation Error
    • Hunter\Status::RESTRICTED_FUNCTION Restricted Function
    • Hunter\Status::RUNTIME_ERROR Runtime Error
    • Hunter\Status::OUTPUT_LIMIT Output Limit Exceeded
    • Hunter\Status::TIME_LIMIT Time Limit Exceeded
    • Hunter\Status::MEMORY_LIMIT Memory Limit Exceeded
    • Hunter\Status::WRONG_ANSWER Wrong Answer
    • Hunter\Status::PRESENTATION_ERROR Presentation Error
    • Hunter\Status::ACCEPTED Accepted
  • language Language in which submission was written
    • Hunter\Language::ANSI_C Ansi C
    • Hunter\Language::Java Java
    • Hunter\Language::CPLUSPLUS C++
    • Hunter\Language::PASCAL Pascal
    • Hunter\Language::CPLUSPLUS11 C++11
    • Hunter\Language::PYTHON Python
  • runtime Runtime in milliseconds
  • rank Submission rank, compared to all
  • time Submission unix timestamp

Ranklist format

  • id User`s ID
  • name User`s name
  • username User`s username
  • rank User's rank
  • accepted The number of accepted problems
  • submissions The number of submissions
  • activity Array of user's activity
    • Hunter\Activity::DAYS Activity in the last 2 days
    • Hunter\Activity::WEEK Activity in the last 7 days
    • Hunter\Activity::MONTH Activity in the last 31 days
    • Hunter\Activity::QUARTER Activity in the last 3 months
    • Hunter\Activity::YEAR Activity in the last year

#API ##getIdFromUsername(string $username) Convert the given $username to a UVa ID.

Returns either the id, or null if not found

$hunter = new Hunter\Hunter();
echo $hunter->getIdFromUsername("Kaspars"); //343417
echo $hunter->getIdFromUsername("Foobar"); // null

Examples

problems(void)

Returns an array of available UVa problems

$hunter = new Hunter\Hunter();
var_dump($hunter->problems());

problem(int $id, string $type = "id")

Retrieved data of a specific problem

$hunter = new Hunter\Hunter();
var_dump($hunter->problem(36));
var_dump($hunter->problem(100, "num"));

problemSubmissions(array|int $problemIDS, int $start = 0, int $end = 2^31)

View submissions to specific problems on a given submission date range. $start and $end are unix timestamps

$hunter = new Hunter\Hunter();
var_dump($hunter->problemSubmissions(36));
var_dump($hunter->problemSubmissions(array(36,37)));

problemRanklist(int $problemID, int $rank = 1, int $count = 100)

Returns submissions to a problem ranked from $rank to $rank + $count - 1.

$hunter = new Hunter\Hunter();
var_dump($hunter->problemRanklist(36));

userProblemRanklist(int $problemID, int $userID, int $above = 10, int $below = 10)

Returns nearby submissions (by runtime) for a particular user submission to a problem.

$hunter = new Hunter\Hunter();
var_dump($hunter->userProblemRanklist(36, 343417));

userSubmissions(int $userID, int $min = null)

Returns all of the submissions of a particular user.

if $min is specified, only submissions with ID larger than $min will be returned.

$hunter = new Hunter\Hunter();
var_dump($hunter->userSubmissions(343417));

userLatestSubmissions(int $userID, int $count = 10)

Returns the last $count submissions of a particular user.

$hunter = new Hunter\Hunter();
var_dump($hunter->userLatestSubmissions(343417));

userProblemSubmissions(array|int $userIDs, array|int $problemIDs, int $min, string $type = "id")

Returns all the submissions of the users on specific problems.

Possible $type values are id and num. This changes whether you pass problem id's or problem num's as the second argument.

$hunter = new Hunter\Hunter();
var_dump($hunter->userProblemSubmissions(343417, 36);

userSolvedProblems(array|int $userIDs)

Get The Bit-Encoded-Problem IDs that Has Been Solved by Some Authors.

$hunter = new Hunter\Hunter();
var_dump($hunter->userSolvedProblems(343417));

userRanklist(int $userID, int $above = 10, int $below = 10)

Returns the user's ranklist and their closest neighbors.

$hunter = new Hunter\Hunter();
var_dump($hunter->userRanklist(343417, 10, 10));

ranklist(int $rank = 1, int $count = 10)

Global ranklist, starteing from $rank to $rank+$count

$hunter = new Hunter\Hunter();
var_dump($hunter->ranklist(1, 100));

setSource(string $source)

Change the source of API data. The default is http://uhunt.felix-halim.net/api/, another valid source is http://icpcarchive.ecs.baylor.edu/uhunt/api/. But you can switch to any source that has the same data format.

$hunter = new Hunter\Hunter();
var_dump($hunter->setSource('http://icpcarchive.ecs.baylor.edu/uhunt/api/'));

getSource()

Returns the current used API source.

$hunter = new Hunter\Hunter();
var_dump($hunter->getSource());

kaspars/hunter 适用场景与选型建议

kaspars/hunter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 71 次下载、GitHub Stars 达 8, 最近一次更新时间为 2015 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「online judge」 「uva」 「uhunt」 「competitive programming」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kaspars/hunter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kaspars/hunter 我们能提供哪些服务?
定制开发 / 二次开发

基于 kaspars/hunter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 71
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-19