Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
df09b16
feat (WIP): shopping list improvement
Makcal Jul 16, 2025
dc361c3
recipe view, storage addition and shopping list creation rework
s3rap1s Jul 16, 2025
ff0f2ed
refactor: new storage additiong, recipe view, shopping list creation
s3rap1s Jul 17, 2025
a7021ff
fix: connect ingred_avail.cpp in cmake
s3rap1s Jul 17, 2025
0cd296a
fix: merge
s3rap1s Jul 17, 2025
00d9870
Merge branch 'dev' into makcal/shopping_list
Makcal Jul 17, 2025
f2d1610
feat: shopping list multiselect + bug fixes
Makcal Jul 17, 2025
6ff3c14
refactor: replace insert with emplace in API
Makcal Jul 17, 2025
91b450a
Merge pull request #99 from Endpool/makcal/shopping_list
Makcal Jul 18, 2025
931e467
fix: search paginations
Ilyhadev Jul 18, 2025
99ca049
feat: finally done refactoring recipe view, storage addition in recip…
s3rap1s Jul 18, 2025
33a4d8c
feat: done refactoring recipe view, storage addition in recipe, shopp…
s3rap1s Jul 18, 2025
53a5ede
merge
s3rap1s Jul 18, 2025
f593ce7
style: format fixes
s3rap1s Jul 18, 2025
2ef78d5
Merge pull request #105 from Endpool/recipe-view-refactor
s3rap1s Jul 18, 2025
a997a00
feat: shopping list buy action
Makcal Jul 18, 2025
0aa0413
chore: add WEBHOOK_CERTIFICATE_PATH to .env.example
Makcal Jul 18, 2025
5fd0bba
Merge branch 'dev' into makcal/shopping_list
Makcal Jul 19, 2025
b78badb
refactor: state rename and other
Makcal Jul 19, 2025
76a09af
refactor: API client (remove redundant methods and refactor others)
Makcal Jul 19, 2025
9033b09
Merge pull request #107 from Endpool/makcal/shopping_list
Makcal Jul 19, 2025
baa887e
fix: buttons in shopping list creation and ui improvements
s3rap1s Jul 19, 2025
b26026f
feat: recipe publication history
Ilyhadev Jul 19, 2025
368792b
after merge files
Ilyhadev Jul 19, 2025
f385252
ci: fix wrong cache hit flag
Rash1d1 Jul 19, 2025
b0f727b
feat: function to convert status enum to string
Ilyhadev Jul 19, 2025
ace8006
feat: new format for publication request history
Ilyhadev Jul 19, 2025
a00fe6a
feat: ingredients moderation status (not done)
s3rap1s Jul 19, 2025
deff90d
feat: ui for request history updated
Ilyhadev Jul 19, 2025
54234b2
Merge remote-tracking branch 'origin' into ilyha-dev/recipe_publicati…
Ilyhadev Jul 19, 2025
c439dc2
feat: moder status for custom ingredients
s3rap1s Jul 19, 2025
8fd2c0d
refactor: states compression
Makcal Jul 19, 2025
fb62957
fix: shopping list creation bug
Ilyhadev Jul 19, 2025
de5f9d0
feat: new commands
s3rap1s Jul 19, 2025
f20748c
feat: new commands
s3rap1s Jul 19, 2025
2fcf697
feat: v1 all history render
Ilyhadev Jul 19, 2025
77aef62
merge enum from ilyha
s3rap1s Jul 19, 2025
5677c7d
Merge pull request #108 from Endpool/moder-info-ing
s3rap1s Jul 19, 2025
cf65d19
Merge branch 'dev' into keyboard-buttons-for-navigation
s3rap1s Jul 19, 2025
db39356
Merge pull request #111 from Endpool/keyboard-buttons-for-navigation
s3rap1s Jul 19, 2025
cb67010
feat: ingredient search for shopping list
Makcal Jul 20, 2025
35497d6
fix: cache in inline searches
Makcal Jul 20, 2025
e4ba950
Merge branch 'dev' into makcal/shopping_list
Makcal Jul 20, 2025
2848b86
chore: remove extra character
Makcal Jul 20, 2025
30d5adf
fix: button data in shopping_list/create.hpp
Makcal Jul 20, 2025
cba89eb
refactor: fix linter errors
Makcal Jul 20, 2025
2ef20b6
refactor: fix linter errors
Makcal Jul 20, 2025
1af2792
fix: took wrong class for request history
Ilyhadev Jul 20, 2025
66c4c91
feat: deletion menu for ingredients in storage
s3rap1s Jul 20, 2025
5ce3c4a
feat: now suggests to make custom ingredient if wasn't found
Ilyhadev Jul 20, 2025
233d097
revision of buttons, their position and user flow
s3rap1s Jul 20, 2025
b482615
fix: create button position in storage list
s3rap1s Jul 20, 2025
242678c
refactor: fix linter errors
Makcal Jul 20, 2025
8acefc9
refactor: move utils::to_string overloads to their files
Makcal Jul 20, 2025
6a33344
refactor: fix linter errors
Makcal Jul 20, 2025
e5bffb3
fix: for recipe history and search enhancement
Ilyhadev Jul 20, 2025
739d98a
Merge branch 'dev' into ilyha-dev/ingredient_search_enhancement
Ilyhadev Jul 20, 2025
d718eed
fix: after merge
Ilyhadev Jul 20, 2025
5b075b5
fix: nullopt creator in recipe details
Ilyhadev Jul 20, 2025
2aa7b71
refactor: remove redundant structure
Ilyhadev Jul 20, 2025
999012d
Merge branch 'dev' into ingredient-deletion-list
Makcal Jul 20, 2025
c7611e7
Merge pull request #112 from Endpool/makcal/shopping_list
Makcal Jul 20, 2025
bf98a48
refactor: move ingredient availability structures to states.hpp
Makcal Jul 20, 2025
3e728a8
refactor: remove API imports from commons
Makcal Jul 21, 2025
e8bb5d6
fix: only 2 ingredients shown in the storage
Makcal Jul 21, 2025
ad74013
Merge branch 'dev' into makcal/refactor
Makcal Jul 21, 2025
23c25a2
chore: turn off misc-include-cleaner tidy check
Makcal Jul 21, 2025
c31b576
Merge pull request #116 from Endpool/makcal/refactor
Makcal Jul 21, 2025
bc9080c
Merge branch 'dev' into ingredient-deletion-list
Makcal Jul 21, 2025
4f04ab7
fix: api refactor
Makcal Jul 21, 2025
99e26cd
fix: api refactor
Makcal Jul 21, 2025
5faa71b
fix: max down
Makcal Jul 21, 2025
9c1b103
fix: api refactor consequences
Makcal Jul 21, 2025
9912470
refactor: fix linter errors
Makcal Jul 21, 2025
d5f646f
style: format code
Makcal Jul 21, 2025
e9ce782
Merge pull request #113 from Endpool/ingredient-deletion-list
Makcal Jul 21, 2025
8b11bcb
Merge origin/dev into ilyha-dev/ingredient_search_enhancement
Makcal Jul 21, 2025
e7ab6de
Merge remote-tracking branch 'origin/dev' into ilyha-dev/ingredient_s…
Makcal Jul 21, 2025
5d2e290
refactor: fix linter errors
Makcal Jul 21, 2025
98c86dd
refactor: fix linting v1
Ilyhadev Jul 21, 2025
626c00e
fix: bug with state to string and linting v2
Ilyhadev Jul 21, 2025
8917771
refactor: linting v3
Ilyhadev Jul 21, 2025
5ceae80
fix: time synch with backend, lint v3
Ilyhadev Jul 21, 2025
1ed0c20
fix: now gets timezone of user, lint experiment
Ilyhadev Jul 21, 2025
b7432e0
refactor: moderation history render
Ilyhadev Jul 21, 2025
ca7e0ce
linting v4
Ilyhadev Jul 21, 2025
87a4cf9
fix: normal view of pending and no_req statuses
s3rap1s Jul 21, 2025
cf27905
fix: page size for suggested recipes
Makcal Jul 22, 2025
fa46f38
fix: shopping list command
Makcal Jul 22, 2025
7912d46
feat: make shopping list of two columns
Makcal Jul 22, 2025
6f8ced9
Merge remote-tracking branch 'origin/ilyha-dev/ingredient_search_enha…
Makcal Jul 22, 2025
6e218d6
refactor: move /recipe to /suggested_recipe
Makcal Jul 22, 2025
d620147
fix: custom recipe view didn't open
Makcal Jul 22, 2025
d51c339
fix: max down syntax error
Makcal Jul 22, 2025
3066a3e
feat: whole history of requests connected to backend
Ilyhadev Jul 22, 2025
0ec68b0
chore: resolved merge conflicts
Ilyhadev Jul 22, 2025
a7bbf49
Merge pull request #114 from Endpool/ilyha-dev/ingredient_search_enha…
Ilyhadev Jul 22, 2025
86a7f60
fix: new structure of customIngredient
s3rap1s Jul 22, 2025
9c9c407
refactor: button data in storage ingredients
Makcal Jul 22, 2025
74cdacb
fix: done with list of ingredients
s3rap1s Jul 22, 2025
3d3d8b0
refactor: move parseIsoTime to parsing.hpp
Makcal Jul 22, 2025
60ce6bd
feat: done with status of custom ingredients
s3rap1s Jul 22, 2025
2b0f13a
fix: rework of moderation history for new backend signature
Ilyhadev Jul 22, 2025
0dceacc
Merge branch 'dev' into ilyha-dev/ingredient_search_enhancement
Ilyhadev Jul 22, 2025
251d2a6
refactor: remove redundant function
Ilyhadev Jul 22, 2025
f9a28b5
Merge branch 'ilyha-dev/ingredient_search_enhancement' of https://git…
Ilyhadev Jul 22, 2025
0db3105
chore: update tgbotstater
Makcal Jul 22, 2025
ceebb0a
merge from dev
s3rap1s Jul 22, 2025
8a866d3
i forgot what i did
Ilyhadev Jul 22, 2025
a9dc17a
feat: add recipes search
Makcal Jul 22, 2025
57674e6
ci: add dev branch as a fallback to linter cache
Makcal Jul 22, 2025
3ea6a7a
format
s3rap1s Jul 22, 2025
3bbfe22
Merge pull request #117 from Endpool/moder-info-ing
s3rap1s Jul 22, 2025
5c7963a
refactor: rename Recipe to SuggestedRecipe
Makcal Jul 22, 2025
427362d
feat: add simple recipe view
Makcal Jul 22, 2025
00c7d49
feat: add recipe sharing
Makcal Jul 22, 2025
df2b055
Merge branch 'dev' into makcal/recipe_search
Makcal Jul 23, 2025
874d14f
ci: try to fix cache restor
Makcal Jul 23, 2025
3882b91
ci: try to fix cache restore
Makcal Jul 23, 2025
24b911b
ci: give up on fixing cache restore
Makcal Jul 23, 2025
f776ec1
Merge pull request #119 from Endpool/makcal/recipe_search
Makcal Jul 23, 2025
84a63c2
fix: recipe history for new backend
Ilyhadev Jul 23, 2025
6c3d33e
Merge branch 'dev' into ilyha-dev/ingredient_search_enhancement
Ilyhadev Jul 23, 2025
b1cf22f
refactor: rename SuggestedRecipe to CookingPlanning
Makcal Jul 23, 2025
fa36963
lint v1
Ilyhadev Jul 23, 2025
273ba97
refactor: move SelectableShoppingItem to helpers namespace
Makcal Jul 23, 2025
87d26fa
Merge pull request #118 from Endpool/ilyha-dev/ingredient_search_enha…
Ilyhadev Jul 23, 2025
5ebffe0
fix: paging in storage ingredients deletion and new inviteButton in m…
s3rap1s Jul 23, 2025
2d13800
fix: invite button
s3rap1s Jul 23, 2025
9f903b4
fix: new ingredient suggestion
Ilyhadev Jul 23, 2025
26a501f
fix: shopping list
Ilyhadev Jul 23, 2025
c69a381
Merge branch 'dev' of https://github.com/Endpool/CookCookhNya-fronten…
Ilyhadev Jul 23, 2025
6d03862
Update ci.yml
Rash1d1 Jul 23, 2025
6916843
Update main.cpp
Rash1d1 Jul 23, 2025
08126b6
Merge remote-tracking branch 'origin/dev' into makcal/done_cooking
Makcal Jul 23, 2025
f5a3769
refactor: rename RecipeStorageAddition to CookingPlanningStorageAddition
Makcal Jul 23, 2025
d3da7e7
fix: improve render of publication history
Makcal Jul 24, 2025
b40e717
feat: after cooking ingredients spending
Makcal Jul 24, 2025
c27ed7b
feat: share button for suggested recipes
Makcal Jul 24, 2025
ce179be
feat: cooking from global search
Makcal Jul 24, 2025
b77411f
Merge branch 'dev' into makcal/done_cooking
Makcal Jul 24, 2025
2dfe713
Merge pull request #121 from Endpool/makcal/done_cooking
Makcal Jul 24, 2025
36c712e
Merge branch 'main' into dev
Makcal Jul 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ Checks: "*,
-cppcoreguidelines-avoid-do-while,
-bugprone-easily-swappable-parameters,
-misc-non-private-member-variables-in-classes,
-llvm-header-guard,"
-llvm-header-guard,

-misc-include-cleaner"
CheckOptions:
cppcoreguidelines-pro-type-member-init.IgnoreArrays: true
readability-implicit-bool-conversion.AllowPointerConditions: true
readability-braces-around-statements.ShortStatementLines: 3
misc-include-cleaner.MissingIncludes: false
FormatStyle: none

1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ API_URL=localhost:8000
WEBHOOK_PORT=8443
WEBHOOK_HOST=https://mydomain.com
WEBHOOK_SECRET=secret
WEBHOOK_CERTIFICATE_PATH=cert.pem
6 changes: 3 additions & 3 deletions .github/actions/build_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
path: |
~/.conan2
/tmp/deps
key: ${{ runner.os }}-conan-cpp23-${{ hashFiles('Frontend/conanfile.txt') }}-tgbotstater-0.4.1
key: ${{ runner.os }}-conan-cpp23-${{ hashFiles('Frontend/conanfile.txt') }}-tgbotstater-0.4.2
restore-keys: |
${{ runner.os }}-conan-cpp23-

Expand Down Expand Up @@ -54,9 +54,9 @@ runs:
run: |
mkdir -p /tmp/deps
cd /tmp/deps
wget https://github.com/Makcal/TgBotStater/archive/refs/tags/v0.4.1.tar.gz -O tgbotstater.tar.gz
wget https://github.com/Makcal/TgBotStater/archive/refs/tags/v0.4.2.tar.gz -O tgbotstater.tar.gz
tar -xf tgbotstater.tar.gz
cd TgBotStater-0.4.1
cd TgBotStater-0.4.2
conan create . --build=missing

- name: Install project dependencies
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: ci pipeline for frontend

on:
Expand All @@ -23,7 +24,6 @@ jobs:
working-directory: .
run: |
make build-release

clang-format-check:
runs-on: ubuntu-latest
needs: build
Expand All @@ -40,7 +40,6 @@ jobs:
run: |
find src -type f \( -name '*.hpp' -or -name '*.cpp' \) \
-exec clang-format-19 --dry-run --Werror {} \+

clang-tidy-check:
runs-on: ubuntu-latest
needs: build
Expand All @@ -56,7 +55,7 @@ jobs:
sudo apt-get update
sudo apt-get install --no-install-recommends -y clang-tidy-19 parallel
echo "/usr/lib/llvm-19/bin" >> $GITHUB_PATH

- name: Restore clang-tidy cache
id: cache-restore
uses: actions/cache/restore@v4
Expand All @@ -65,8 +64,9 @@ jobs:
key: ${{ runner.os }}-clang-tidy-${{ github.ref }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-clang-tidy-${{ github.ref }}-
${{ runner.os }}-clang-tidy-refs/heads/main

${{ runner.os }}-clang-tidy-refs/heads/dev-
${{ runner.os }}-clang-tidy-refs/heads/main-

- name: Copy original cache file if exists
run: |
if [ -f .clang-tidy-cache.json ]; then
Expand Down Expand Up @@ -150,7 +150,6 @@ jobs:
- name: Run clang-tidy with caching
run: |
bash ./run-clang-tidy-cached.sh

- name: Check if cache file changed
id: cache-changed
run: |
Expand All @@ -166,7 +165,6 @@ jobs:
echo "No original cache file, assuming changed"
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Debug cache state
run: |
echo "Cache hit: ${{ steps.cache-restore.outputs.cache-hit }}"
Expand All @@ -177,7 +175,6 @@ jobs:
else
echo "No cache file found"
fi

- name: Save clang-tidy cache
if: always() && steps.cache-changed.outputs.changed == 'true'
uses: actions/cache/save@v4
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ include(src/handlers/CMakeLists.txt)
include(src/render/CMakeLists.txt)
include(src/utils/CMakeLists.txt)

# settings
target_compile_definitions(main PRIVATE
TGBOTSTATER_NOT_LOG_HANDLERS_CALLS)

# setup
target_include_directories(main PRIVATE
${CMAKE_SOURCE_DIR}/src
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ RUN conan profile detect \
RUN conan install --requires=boost/1.83.0 --build=missing

WORKDIR /deps
RUN wget https://github.com/Makcal/TgBotStater/archive/refs/tags/v0.4.1.tar.gz -O tgbotstater.tar.gz \
RUN wget https://github.com/Makcal/TgBotStater/archive/refs/tags/v0.4.2.tar.gz -O tgbotstater.tar.gz \
&& tar -xf tgbotstater.tar.gz \
&& rm tgbotstater.tar.gz \
&& cd TgBotStater-0.4.1 \
&& cd TgBotStater-0.4.2 \
&& conan create . --build=missing

WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build/Release/CMakeCache.txt: conanfile.txt
build-debug: build/Debug/CMakeCache.txt
cmake --build --preset=conan-debug
build-debug-j5: build/Release/CMakeCache.txt
cmake --build . --preset=conan-debug -- -j5
cmake --build . --preset=conan-debug -- -j2
build-release: build/Release/CMakeCache.txt
cmake --build --preset=conan-release

Expand Down
2 changes: 1 addition & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[requires]
tgbotstater/0.4.1
tgbotstater/0.4.2
cpp-httplib/0.19.0
boost/1.83.0

Expand Down
5 changes: 5 additions & 0 deletions src/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
target_sources(main PRIVATE
src/backend/api/base.cpp

src/backend/api/publicity_filter.cpp

src/backend/api/storages.cpp
src/backend/api/ingredients.cpp
src/backend/api/users.cpp
src/backend/api/recipes.cpp
src/backend/api/shopping_lists.cpp
src/backend/api/moderation.cpp

src/backend/models/storage.cpp
src/backend/models/ingredient.cpp
src/backend/models/user.cpp
src/backend/models/recipe.cpp
src/backend/models/shopping_list.cpp
src/backend/models/publication_request_status.cpp
src/backend/models/moderation.cpp
)
29 changes: 22 additions & 7 deletions src/backend/api/api.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#pragma once

#include "backend/api/ingredients.hpp"
#include "backend/api/recipes.hpp"
#include "backend/api/shopping_lists.hpp"
#include "backend/api/storages.hpp"
#include "backend/api/users.hpp"
#include "ingredients.hpp"
#include "moderation.hpp"
#include "recipes.hpp"
#include "shopping_lists.hpp"
#include "storages.hpp"
#include "users.hpp"

#include <httplib.h>

Expand All @@ -20,13 +21,16 @@ class ApiClient {
IngredientsApi ingredients;
RecipesApi recipes;
ShoppingListApi shoppingList;
ModerationApi moderation;

public:
explicit ApiClient(const std::string& apiAddress)
: api{apiAddress}, users{api}, storages{api}, ingredients{api}, recipes{api}, shoppingList{api} {}
: api{apiAddress}, users{api}, storages{api}, ingredients{api}, recipes{api}, shoppingList{api},
moderation{api} {}
ApiClient(const ApiClient&) = delete;
ApiClient(ApiClient&& other) noexcept
: api{std::move(other.api)}, users{api}, storages{api}, ingredients{api}, recipes{api}, shoppingList{api} {}
: api{std::move(other.api)}, users{api}, storages{api}, ingredients{api}, recipes{api}, shoppingList{api},
moderation{api} {}
ApiClient& operator=(const ApiClient&) = delete;
ApiClient& operator=(ApiClient&& other) noexcept {
if (&other == this)
Expand All @@ -37,6 +41,7 @@ class ApiClient {
ingredients = IngredientsApi{api};
recipes = RecipesApi{api};
shoppingList = ShoppingListApi{api};
moderation = ModerationApi{api};
return *this;
}
~ApiClient() = default;
Expand Down Expand Up @@ -80,6 +85,16 @@ class ApiClient {
operator const ShoppingListApi&() const { // NOLINT(*-explicit-*)
return shoppingList;
}

[[nodiscard]] const ModerationApi& getModerationApi() const {
return moderation;
}

operator const ModerationApi&() const { // NOLINT(*-explicit-*)
return moderation;
}
};

using ApiClientRef = const api::ApiClient&;

} // namespace cookcookhnya::api
19 changes: 0 additions & 19 deletions src/backend/api/common.hpp

This file was deleted.

71 changes: 40 additions & 31 deletions src/backend/api/ingredients.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "backend/api/ingredients.hpp"

#include "backend/api/common.hpp"
#include "backend/api/publicity_filter.hpp"
#include "backend/id_types.hpp"
#include "backend/models/ingredient.hpp"
#include "utils/parsing.hpp"
Expand All @@ -23,11 +23,11 @@ Ingredient IngredientsApi::get(UserId user, IngredientId ingredient) const {

// GET /storages/{storageId}/ingredients
std::vector<Ingredient>
IngredientsApi::getStorageIngredients(UserId user, StorageId storage, std::size_t size, std::size_t offset) const {
IngredientsApi::getStorageIngredients(UserId user, StorageId storage, std::size_t count, std::size_t offset) const {
return jsonGetAuthed<std::vector<Ingredient>>(
user,
std::format("/storages/{}/ingredients", storage),
{{"size", utils::to_string(size)}, {"offset", utils::to_string(offset)}});
{{"size", utils::to_string(count)}, {"offset", utils::to_string(offset)}});
}

// PUT /storages/{storageId}/ingredients/{ingredientId}
Expand All @@ -46,51 +46,59 @@ void IngredientsApi::deleteMultipleFromStorage(UserId user,
const std::vector<IngredientId>& ingredients) const {
httplib::Params params = {};
for (auto id : ingredients)
params.insert({"ingredient", utils::to_string(id)});
params.emplace("ingredient", utils::to_string(id));
jsonDeleteAuthed<void>(user, std::format("/storages/{}/ingredients/", storage), params);
}

// GET /ingredients-for-storage
IngredientSearchForStorageResponse IngredientsApi::searchForStorage(UserId user,
StorageId storage,
std::string query,
std::size_t threshold,
std::size_t size,
std::size_t offset) const {
std::size_t count,
std::size_t offset,
unsigned threshold) const {
return jsonGetAuthed<IngredientSearchForStorageResponse>(user,
"/ingredients-for-storage",
{{"query", std::move(query)},
{"storage-id", utils::to_string(storage)},
{"size", utils::to_string(size)},
{"size", utils::to_string(count)},
{"threshold", utils::to_string(threshold)},
{"offset", utils::to_string(offset)}});
}

// GET /public/ingredients
IngredientSearchResponse
IngredientsApi::publicSearch(std::string query, std::size_t threshold, std::size_t size, std::size_t offset) const {
return jsonGet<IngredientSearchResponse>("/public/ingredients",
{},
{{"query", std::move(query)},
{"threshold", utils::to_string(threshold)},
{"size", utils::to_string(size)},
{"offset", utils::to_string(offset)}});
}

// GET /ingredients
IngredientSearchResponse IngredientsApi::search(UserId user,
PublicityFilterType filter,
std::string query,
std::size_t threshold,
std::size_t size,
std::size_t count,
std::size_t offset,
filterType filter) const {
unsigned threshold) const {
return jsonGetAuthed<IngredientSearchResponse>(user,
"/ingredients",
{{"query", std::move(query)},
{"size", utils::to_string(size)},
{"size", utils::to_string(count)},
{"offset", utils::to_string(offset)},
{"threshold", utils::to_string(threshold)},
{"filter", filterStr(filter)}});
{"filter", utils::to_string(filter)}});
}

// GET /ingredients
IngredientList
IngredientsApi::getList(UserId user, PublicityFilterType filter, std::size_t count, std::size_t offset) const {
auto result = search(user, filter, "", count, offset, 0);
return {.page = std::move(result.page), .found = result.found};
}

// GET /ingredients
CustomIngredientList IngredientsApi::customIngredientsSearch(
UserId user, std::string query, std::size_t threshold, std::size_t count, std::size_t offset) const {
return jsonGetAuthed<CustomIngredientList>(user,
"/ingredients",
{{"query", std::move(query)},
{"size", utils::to_string(count)},
{"offset", utils::to_string(offset)},
{"threshold", utils::to_string(threshold)},
{"filter", utils::to_string(PublicityFilterType::Custom)}});
}

// GET /public/ingredients/{ingredientId}
Expand All @@ -109,17 +117,13 @@ void IngredientsApi::deleteFromRecipe(UserId user, RecipeId recipe, IngredientId
}

// GET /ingredients-for-recipe
IngredientSearchForRecipeResponse IngredientsApi::searchForRecipe(UserId user,
RecipeId recipe,
std::string query,
std::size_t threshold,
std::size_t size,
std::size_t offset) const {
IngredientSearchForRecipeResponse IngredientsApi::searchForRecipe(
UserId user, RecipeId recipe, std::string query, std::size_t count, std::size_t offset, unsigned threshold) const {
return jsonGetAuthed<IngredientSearchForRecipeResponse>(user,
"/ingredients-for-recipe",
{{"query", std::move(query)},
{"threshold", utils::to_string(threshold)},
{"size", utils::to_string(size)},
{"size", utils::to_string(count)},
{"offset", utils::to_string(offset)},
{"recipe-id", utils::to_string(recipe)}});
}
Expand All @@ -129,6 +133,11 @@ IngredientId IngredientsApi::createCustom(UserId user, const IngredientCreateBod
return utils::parse<IngredientId>(postWithJsonAuthed(user, "/ingredients", body));
}

// DELETE /ingredients/{ingredientId}
void IngredientsApi::deleteCustom(UserId user, IngredientId ingredient) const {
jsonDeleteAuthed<void>(user, std::format("/ingredients/{}", ingredient));
}

// POST /recipes/{ingredientId}/request-publication
void IngredientsApi::publishCustom(UserId user, IngredientId ingredient) const {
jsonPostAuthed<void>(user, std::format("/ingredients/{}/request-publication", ingredient));
Expand Down
Loading
Loading