|
1 | | -#include "issues.h" |
| 1 | +#include "issue_callback.h" |
2 | 2 |
|
3 | | -#include <service/database/database.h> |
4 | | -#include <service/util.h> |
5 | | -#include "models/ProjectIssue.h" |
| 3 | +#include "issue_service.h" |
6 | 4 |
|
7 | 5 | using namespace drogon; |
8 | 6 |
|
9 | 7 | namespace service { |
10 | | - // clang-format off |
11 | | - ENUM_FROM_TO_STR(ProjectIssueLevel, |
12 | | - {ProjectIssueLevel::WARNING, "warning"}, |
13 | | - {ProjectIssueLevel::ERROR, "error"} |
14 | | - ) |
15 | | - |
16 | | - ENUM_FROM_TO_STR(ProjectIssueType, |
17 | | - {ProjectIssueType::META, "meta"}, |
18 | | - {ProjectIssueType::FILE, "file"}, |
19 | | - {ProjectIssueType::GIT_CLONE, "git_clone"}, |
20 | | - {ProjectIssueType::GIT_INFO, "git_info"}, |
21 | | - {ProjectIssueType::INGESTOR, "ingestor"}, |
22 | | - {ProjectIssueType::PAGE, "page"}, |
23 | | - {ProjectIssueType::INTERNAL, "internal"} |
24 | | - ) |
25 | | - |
26 | | - ENUM_FROM_TO_STR(ProjectError, |
27 | | - {ProjectError::OK, "ok"}, |
28 | | - {ProjectError::REQUIRES_AUTH, "requires_auth"}, |
29 | | - {ProjectError::NO_REPOSITORY, "no_repository"}, |
30 | | - {ProjectError::REPO_TOO_LARGE, "repo_too_large"}, |
31 | | - {ProjectError::NO_BRANCH, "no_branch"}, |
32 | | - {ProjectError::NO_PATH, "no_path"}, |
33 | | - {ProjectError::INVALID_META, "invalid_meta"}, |
34 | | - {ProjectError::PAGE_RENDER, "page_render"}, |
35 | | - {ProjectError::DUPLICATE_PAGE, "duplicate_page"}, |
36 | | - {ProjectError::UNKNOWN_RECIPE_TYPE, "unknown_recipe_type"}, |
37 | | - {ProjectError::INVALID_INGREDIENT, "invalid_ingredient"}, |
38 | | - {ProjectError::INVALID_FILE, "invalid_file"}, |
39 | | - {ProjectError::INVALID_FORMAT, "invalid_format"}, |
40 | | - {ProjectError::INVALID_RESLOC, "invalid_resloc"}, |
41 | | - {ProjectError::INVALID_VERSION_BRANCH, "invalid_version_branch"}, |
42 | | - {ProjectError::MISSING_PLATFORM_PROJECT, "missing_platform_project"}, |
43 | | - {ProjectError::NO_PAGE_TITLE, "no_page_title"}, |
44 | | - {ProjectError::INVALID_FRONTMATTER, "invalid_frontmatter"}, |
45 | | - {ProjectError::MISSING_REQUIRED_ATTRIBUTE, "missing_required_attribute"} |
46 | | - ) |
47 | | - // clang-format on |
48 | | - |
49 | 8 | ProjectIssueCallback::ProjectIssueCallback(const std::string &id, const std::shared_ptr<spdlog::logger> &log) : |
50 | 9 | deploymentId_(id), logger_(log), hasErrors_(false) {} |
51 | 10 |
|
52 | 11 | Task<> addIssueStatic(const ProjectIssueLevel level, const ProjectIssueType type, const ProjectError subject, const std::string details, |
53 | 12 | const std::string file, const std::string deploymentId, const std::shared_ptr<spdlog::logger> logger) { |
54 | 13 | if (!deploymentId.empty()) { |
55 | | - co_await addIssue(deploymentId, level, type, subject, details, file); |
| 14 | + co_await global::issues->addProjectIssueInternal(deploymentId, level, type, subject, details, file); |
56 | 15 | } |
57 | 16 |
|
58 | 17 | const auto logLevel = level == ProjectIssueLevel::ERROR ? spdlog::level::err : spdlog::level::warn; |
@@ -122,17 +81,4 @@ namespace service { |
122 | 81 |
|
123 | 82 | return json; |
124 | 83 | } |
125 | | - |
126 | | - Task<> addIssue(const std::string deploymentId, const ProjectIssueLevel level, const ProjectIssueType type, const ProjectError subject, |
127 | | - const std::string details, const std::string file) { |
128 | | - ProjectIssue issue; |
129 | | - issue.setDeploymentId(deploymentId); |
130 | | - issue.setLevel(enumToStr(level)); |
131 | | - issue.setType(enumToStr(type)); |
132 | | - issue.setSubject(enumToStr(subject)); |
133 | | - issue.setDetails(details); |
134 | | - issue.setFile(file); |
135 | | - |
136 | | - co_await global::database->addModel(issue); |
137 | | - } |
138 | 84 | } |
0 commit comments