Skip to content

Commit 2cddf7b

Browse files
committed
Fix recipe obtaining ignoring tags
1 parent 1461fd6 commit 2cddf7b

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/service/content/ingestor_metadata.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace content {
1414

1515
Task<PreparationResult> MetadataSubIngestor::prepare() {
1616
const auto docsRoot = project_.getRootDirectory();
17-
const auto workbenchesFile = docsRoot / ".data" / "workbenches.json";
17+
const auto workbenchesFile = project_.getFormat().getWorkbenchesPath();
1818

1919
if (exists(workbenchesFile)) {
2020
const ProjectFileIssueCallback fileIssues{issues_, workbenchesFile};

src/service/database/database.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,21 @@ namespace service {
360360
JOIN project_version ver ON pitem.version_id = ver.id \
361361
JOIN item ON pitem.item_id = item.id \
362362
LEFT JOIN project_item_page pip ON pitem.id = pip.item_id \
363-
WHERE NOT ri.input AND EXISTS ( \
364-
SELECT 1 FROM recipe_ingredient_item ri_sub \
365-
JOIN item i ON ri_sub.item_id = i.id \
366-
WHERE ri_sub.recipe_id = r.id AND i.loc = $1 AND ri_sub.input)";
363+
WHERE NOT ri.input AND ( \
364+
EXISTS ( \
365+
SELECT 1 FROM recipe_ingredient_item ri_sub \
366+
JOIN item i ON ri_sub.item_id = i.id \
367+
WHERE ri_sub.recipe_id = r.id AND i.loc = $1 AND ri_sub.input \
368+
) \
369+
OR EXISTS( \
370+
SELECT 1 FROM recipe_ingredient_tag rt_sub \
371+
JOIN project_tag pt ON pt.tag_id = rt_sub.tag_id \
372+
JOIN tag_item_flat flat ON flat.parent = pt.id \
373+
JOIN project_item pit on pit.id = flat.child \
374+
JOIN item i ON pit.item_id = i.id \
375+
WHERE rt_sub.recipe_id = r.id AND i.loc = $1 AND rt_sub.input \
376+
) \
377+
)";
367378

368379
const auto [res, err] = co_await handleDatabaseOperation<std::vector<ContentUsage>>(
369380
[item](const DbClientPtr &client) -> Task<std::vector<ContentUsage>> {

src/service/project/format.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define CONTENT_DIR_PATH ".content"
1010
#define FOLDER_META_FILE "_meta.json"
1111
#define PROPERTIES_PATH ".data/properties.json"
12+
#define WORKBENCHES_PATH ".data/workbenches.json"
1213
#define WIKI_META_FILE "sinytra-wiki.json"
1314

1415
namespace fs = std::filesystem;
@@ -67,6 +68,10 @@ namespace service {
6768
return getLocalizedFilePath(PROPERTIES_PATH);
6869
}
6970

71+
fs::path ProjectFormat::getWorkbenchesPath() const {
72+
return root_ / WORKBENCHES_PATH;
73+
}
74+
7075
fs::path ProjectFormat::getAssetPath(const ResourceLocation &location) const {
7176
const auto ext = location.path_.find('.') != std::string::npos ? "" : ".png";
7277
const auto path = ASSETS_DIR_PATH "/" + location.namespace_ + "/" + location.path_ + ext;

src/service/project/format.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace service {
2222
std::filesystem::path getLocalizedFilePath(const std::string &path) const;
2323
std::filesystem::path getFolderMetaFilePath(const std::filesystem::path &dir) const;
2424
std::filesystem::path getItemPropertiesPath() const;
25+
std::filesystem::path getWorkbenchesPath() const;
2526
std::filesystem::path getAssetPath(const ResourceLocation &location) const;
2627
std::filesystem::path getLanguageFilePath(const std::string &namespace_) const;
2728
private:

0 commit comments

Comments
 (0)