diff --git a/repair/assets/issue-label.png b/repair/assets/issue-label.png new file mode 100644 index 0000000..2548902 Binary files /dev/null and b/repair/assets/issue-label.png differ diff --git a/repair/weekend.md b/repair/weekend.md index 8bbba62..9e12f63 100644 --- a/repair/weekend.md +++ b/repair/weekend.md @@ -102,17 +102,27 @@ sequenceDiagram ``` -目前,新的维修事件会同步到 [Github Issue](https://github.com/nbtca/repair-tickets/issues) 中。成员可以在Github Issue中处理维修事件 +目前,新的维修事件会同步到 [Github Issue](https://github.com/nbtca/repair-tickets/issues) 中。成员可以在Github Issue中处理维修事件。 + +### 为什么要使用Github Issue来管理维修? + +- **成熟的工单系统**:Github Issue是一个成熟的工单系统,功能强大,易于使用。 +- **可追溯性**:所有的维修事件都可以在Github上查看,方便后续的查询和统计。 +- **协作**:Github Issue提供了良好的协作工具,成员可以在上面讨论和交流。 +- **自动化**:通过Github的Webhook,可以自动化处理一些事件,比如创建事件、更新事件等。 +- **社区参与**:Github是一个开放的平台,任何人都可以参与到维修事件中来,增加了社区的参与度。 +- **版本控制**:所有的事件都有版本记录,可以随时查看历史记录,方便追踪和审计。 +- **标签管理**:可以通过标签来管理事件的状态和类型,方便后续的查询和统计。 ### 前提条件 -在开始之前,你需要先关联你的Github账户。你可以前往 [MyId](https://myid.app.nbtca.space/account/connections) 关联你的Github账户 +在开始之前,你需要先关联你的Github账户。你可以前往 [MyId](https://myid.app.nbtca.space/account/connections) 关联你的Github账户。 ![link-github](./assets/link-github.png) ### 处理事件 -在Github Issue中,你可以通过在回复中包含以下命令来处理事件: +在Github Issue中,可以通过在回复中包含以下命令来处理事件: - `@nbtca-bot accept` will accept this ticket - `@nbtca-bot drop` will drop your previous accept @@ -121,3 +131,100 @@ sequenceDiagram - `@nbtca-bot close` will close this ticket as completed ![issue-reply](./assets/issue-reply-example.png) + +### 记录事件工作量 + +![issue-label](./assets/issue-label.png) + +在Github Issue中,可以通过添加标签来记录工作量。标签的命名规则为 `size:xs`、`size:s`、`size:m`、`size:l`、`size:xl`,分别对应不同的工作量。工作量代表的是维修事件的复杂程度和所需时间。具体的工作量和对应的标签如下: + +| 标签名 | 对应时长 | 示例维修任务(仅供参考) | 场景说明 | +| --------- | -------- | ----------------------------------------------- | ------------------------------------------------ | +| `size:xs` | 0.5 小时 | 重启系统、插拔键鼠、调整BIOS启动项 | 无需工具,仅简单排查或软件层级操作 | +| `size:s` | 1 小时 | 更换键盘、电源适配器、内存条 | 简单拆装部件,操作快,风险低 | +| `size:m` | 2 小时 | 拆机清灰、重新安装操作系统、驱动修复 | 需基本工具、一定技术判断,时间较长 | +| `size:l` | 4 小时 | 主板故障检测与更换、电源模块更换 | 较复杂的拆装和测试流程,需熟练技能、多人协作可能 | +| `size:xl` | 8 小时 | 批量电脑检修(5 台以上)、全室网卡/主板统一更换 | 工作量极大,涉及多个设备,需团队作业和详细记录 | + +### 志愿者时长统计 + +我们可以通过记录的工作量来统计志愿者时长。 + +```typescript +const BASE_TIME = 2 // hours +const MAX_TIME = 8 // hours + +// Mapping from tag to time in hours +const tagTimeMap: Record = { + 'size:s': 1, + 'size:m': 2, + 'size:l': 4, + 'size:xl': 8, +} + +// Compute total time for a given student and event +function calculateTime(records: { + studentId: string + eventId: string + tag: string // e.g., "size:s" +}[], studentId: string): number { + const relevantRecords = records.filter( + r => r.studentId === studentId + ) + + let totalTime = BASE_TIME + + for (const record of relevantRecords) { + const time = tagTimeMap[record.tag] || 0 + totalTime += time + } + + return Math.min(MAX_TIME, totalTime) +} + +const records: Record[] = [ + { studentId: '2333333333', eventId: '123456', tag: 'size:s' }, + { studentId: '2333333333', eventId: '123456', tag: 'size:m' }, +] +const time = calculateTime(records, '2333333333') +console.log('Calculated time:', time) // Output: 5 +``` + +| Key | Value | Description | +| -------------- | --------- | ------------------------ | +| 基础时长 | 2 | 每个志愿者的基础时长 | +| 最高时长 | 8 | 每个志愿者的最高申报时长 | +| 上一次统计日期 | 2025.4.21 | 上一次统计时长的日期 | + +统计时长时,获取自从上一次统计日期以来的维修记录,统计完成后将上一次统计日期更新为当前日期。 +时长计算参考以上代码中的 `calculateTime` 函数。 + +#### 例子 + +| 学号 | 事件ID | size | +| ---------- | ------ | ------ | +| 2333333333 | 123456 | size:s | +| 2333333333 | 123456 | size:m | + +计算后时长为 min(8, 2 + 1 + 2) = 5。 + +#### 使用Saturday API导出时长为excel + +| 字段名 | 描述 | +| ------------ | -------------------- | +| start_time | 开始时间 | +| end_time | 结束时间 | +| bearer_token | token,需要admin权限 | + +```http +GET https://repair.nbtca.space/api/events/xlsx?start_time={{start_time}}&end_time={{end_time}} +Authorization: {{bearer_token}} +``` + +##### 示例 + +```bash +curl -X GET "http://repair.nbtca.space/api/events/xlsx?start_time=2025-01-01&end_time=2025-05-31" \ + -H "Authorization: {{bearer_token}}" \ + -OJ +```