> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Collection Project History Labels

`projectHistoryLabels` lưu các nhãn mà người dùng gắn cho phiên bản trong chế độ xem History, mỗi nhãn một tài liệu. project-history sở hữu nó và ghi nó trong `services/project-history/app/js/LabelsManager.js`; không có schema Mongoose. Web chỉ truy cập nó qua API của project-history.

#### Các trường

| Trường | Kiểu | Ý nghĩa | Nguồn |
| - | - | - | - |
| `_id` | ObjectId | Id của nhãn. | `LabelsManager.js:81-85` |
| `project_id` | ObjectId | Dự án. | `LabelsManager.js:73` |
| `comment` | String | Văn bản của nhãn. | `LabelsManager.js:74` |
| `version` | Number | Phiên bản lịch sử dự án mà nhãn trỏ tới. | `LabelsManager.js:75` |
| `created_at` | Date | Thời điểm tạo nhãn; request có thể truyền thời gian riêng, nếu không thì là hiện tại. | `LabelsManager.js:70`, `76` |
| `user_id` | ObjectId | Người tạo nhãn. Bị bỏ qua khi request không có người dùng. | `LabelsManager.js:78-80` |

#### Ai ghi

| Mã | Chức năng |
| - | - |
| `services/project-history/app/js/LabelsManager.js:44-90` | `createLabel`: chèn một nhãn, cho project-history `POST /project/:project_id/labels` (`services/project-history/app/js/HttpController.js:1134-1171`). Web gọi nó khi người dùng thêm nhãn, kèm id của người dùng (`services/web/app/src/Features/History/HistoryController.mjs:529-546`). |
| `LabelsManager.js:113-126` | `deleteLabel`: xóa một nhãn của dự án, cho `DELETE /project/:project_id/labels/:label_id`. Web dùng nó khi chủ dự án xóa nhãn (`HistoryController.mjs:649-670`). |
| `LabelsManager.js:92-111` | `deleteLabelForUser`: chỉ xóa nhãn nếu chính người dùng đó tạo ra, cho `DELETE /project/:project_id/user/:user_id/labels/:label_id`. Web dùng nó cho mọi người khác. |
| `LabelsManager.js:128-143` | `transferLabels`: chuyển mọi nhãn của một người dùng sang người khác, cho `POST /user/:from_user/labels/transfer/:to_user` (`services/project-history/app/js/Router.js:52-55`). Không có gì trong web gọi route này. |
| `LabelsManager.js:7-25` | `cloneLabels`: sao chép nhãn của một dự án sang dự án khác, cho project-history `POST /project/:project_id/clone` (`HttpController.js:113`), route mà không có gì trong web gọi. |

#### Ai đọc

| Mã | Chức năng |
| - | - |
| `LabelsManager.js:27-42` | `getLabels`: mọi nhãn của một dự án, trả về dạng `{ id, comment, version, user_id, created_at }` (`LabelsManager.js:163-171`). Được dùng bởi `GET /project/:project_id/labels` (`HttpController.js:1076-1100`), mà web gọi cho chế độ xem History và điền tên người dùng (`HistoryController.mjs:488-499`). |
| `services/project-history/app/js/SummarizedUpdatesManager.js:57` | Thêm các nhãn vào danh sách cập nhật lịch sử. |

#### Chỉ mục

| Tên | Khóa | Tùy chọn | Migration |
| - | - | - | - |
| `project_id_1` | `{ project_id: 1 }` | | `tools/migrations/20190912145019_create_projectHistoryLabels_indexes.mjs` |
| `user_id_1` | `{ user_id: 1 }` | | `tools/migrations/20190912145019_create_projectHistoryLabels_indexes.mjs` |

#### Ghi chú

* Trước khi chèn nhãn, project-history xử lý các cập nhật đang xếp hàng của dự án và kiểm tra history-v1 có chunk cho phiên bản đó, trừ khi request gửi `validate_exists: false` (`LabelsManager.js:53-59`, `173-195`; `HttpController.js:1109-1115`).
* Không có mã nào xóa nhãn của dự án khi dự án bị xóa: project-history `DELETE /project/:project_id` chỉ xóa trạng thái đồng bộ và bản ghi lỗi (`HttpController.js:1363-1396`), và không dịch vụ nào khác chạm vào collection này.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.