Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebUI: Add "isPrivate" filter for 'info' API #20833

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ManiMatter
Copy link
Contributor

@ManiMatter ManiMatter commented May 13, 2024

It is already possible to filter the "info" response by hashes, status, tag, category.
Since the "isPrivate" flag has been added in #20686, it would be nice if it was possible to also pre-filter the response by this attribute.

I have - to the best of my abilities - implemented the code, but it is at the edge of my skills and I would appreciate your review.

The failed checks seem macOS related and affecting any PRs right now, thus not triggered by the changes I propose here

@thalieht thalieht added the WebAPI WebAPI-related issues/changes label May 13, 2024
@ManiMatter ManiMatter force-pushed the info-API-filter-by-isPrivate-flag branch 3 times, most recently from 31955e6 to 37ee324 Compare May 13, 2024 13:37
@ManiMatter ManiMatter force-pushed the info-API-filter-by-isPrivate-flag branch from 37ee324 to 44e71b0 Compare May 13, 2024 13:41
src/base/torrentfilter.h Outdated Show resolved Hide resolved
src/base/torrentfilter.h Outdated Show resolved Hide resolved
src/base/torrentfilter.h Outdated Show resolved Hide resolved
src/webui/api/serialize/serialize_torrent.h Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/base/torrentfilter.cpp Outdated Show resolved Hide resolved
src/base/torrentfilter.cpp Outdated Show resolved Hide resolved
src/base/torrentfilter.cpp Outdated Show resolved Hide resolved
@glassez glassez requested review from a team May 16, 2024 13:19
@glassez glassez added this to the 5.0 milestone May 16, 2024
@ManiMatter ManiMatter requested a review from glassez May 16, 2024 16:50
@ManiMatter
Copy link
Contributor Author

@glassez Thanks having included this on milestone 5.0, and for having reviewed the code. I was not able to figure out how to test whether the feature works properly. Just wanted to check if you had a chance to test if it actually works?

Many thanks

@ManiMatter
Copy link
Contributor Author

@glassez - quick question, do I need to do anything here to get this merged?

@glassez
Copy link
Member

glassez commented Jun 6, 2024

@glassez - quick question, do I need to do anything here to get this merged?

At least it should be confirmed by someone from the team (or maybe by couple of other people) that it works as intended.

@ManiMatter
Copy link
Contributor Author

Thank you for the fast response. I unfortunately did not figure out how to build a docker image from the code so that I could test it myself.

Did you test it on your end by any chance? If so, did it work?

Looking forward for the other people to test it (guess that is done via qbittorrent/web-developers ?)

src/webui/api/serialize/serialize_torrent.h Show resolved Hide resolved
src/webui/api/serialize/serialize_torrent.cpp Show resolved Hide resolved
src/base/torrentfilter.h Outdated Show resolved Hide resolved
src/base/torrentfilter.h Outdated Show resolved Hide resolved
src/base/torrentfilter.h Outdated Show resolved Hide resolved
src/base/torrentfilter.h Show resolved Hide resolved
@@ -70,6 +70,7 @@ class TorrentFilter
static const std::optional<QString> AnyCategory;
static const std::optional<TorrentIDSet> AnyID;
static const std::optional<Tag> AnyTag;
static const std::optional<bool> AnyIsPrivate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would name it AnyPrivate.

src/base/torrentfilter.h Show resolved Hide resolved
@@ -34,6 +34,7 @@
const std::optional<QString> TorrentFilter::AnyCategory;
const std::optional<TorrentIDSet> TorrentFilter::AnyID;
const std::optional<Tag> TorrentFilter::AnyTag;
const std::optional<bool> TorrentFilter::AnyIsPrivate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would name it AnyPrivate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnyPrivate looks confusing.

Now since we use std::optional these constants don't do much good. We can use std::nullopt directly and not bother to come up with names for these constants.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use std::nullopt directly and not bother to come up with names for these constants.

👍

src/webui/api/torrentscontroller.cpp Show resolved Hide resolved
ManiMatter and others added 6 commits June 6, 2024 22:38
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
@ManiMatter
Copy link
Contributor Author

ManiMatter commented Jun 6, 2024

@Chocobo1 - many thanks for your review. I incorporated your changes.

Regarding renaming: I am not sure I understand your suggestion to rename the "isPrivate" to "private" in the various places. Since the flag that is returned currently in the properties is called "isPrivate", I feel it makes sense to keep calling it like this, rather than changing to "private". What was your thinking when suggesting the rename?

In terms of functionality, did the feature work for you as expected?

ManiMatter and others added 4 commits June 7, 2024 06:36
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
@Chocobo1
Copy link
Member

Chocobo1 commented Jun 7, 2024

Regarding renaming: I am not sure I understand your suggestion to rename the "isPrivate" to "private" in the various places. Since the flag that is returned currently in the properties is called "isPrivate", I feel it makes sense to keep calling it like this, rather than changing to "private". What was your thinking when suggesting the rename?

It looks weird to me.
For example: bool TorrentFilter::matchIsPrivate(const BitTorrent::Torrent *const torrent) and without going into the internals, what is it supposed to mean? A match/matching is private... what? No, it is matching for a private flag/property on a torrent object. Using another name like matchPrivate (or matchPrivateTorrent, matchPrivateFlag, etc.) could avoid the confusion IMO. Look at other similar functions, they aren't that hard to read and understand: matchState, matchHash, matchCategory.
Another one: TorrentFilter::TorrentFilter(..., const std::optional<bool> isPrivate). What does it mean for the parameter by "is private"? Is it running a test (with some outcome) on the parameter/variable? No, I suppose the function want some state for a "private" flag/property. And therefore I would suggest just call it private (or privateFlag, privateState or something like that).

In terms of functionality, did the feature work for you as expected?

I haven't got time to test. BTW our CI do provide build artifacts, you can use it to verify.

@glassez
Copy link
Member

glassez commented Jun 7, 2024

And therefore I would suggest just call it private

👍
The torrent property is called "private". Using the Qt naming convention getter/setter methods are called isPrivate/setPrivate accordingly. But in most cases we have to refer to the original property name (i.e. without is prefix).

@ManiMatter
Copy link
Contributor Author

BTW our CI do provide build artifacts, you can use it to verify.

Thank you for the pointer, which helped me find the CI artefacts.
However, I am not sure I know how to run them, would you mind pointing me in the right direction once more?

In my regular setup, I run a docker container which I pull from lscr.io/linuxserver/qbittorrent:latest.
My take is that the artefacts from the CI do not provide a docker image, correct?

If that's the case, I'm left off with my Mac to test (which runs on Sonoma).
Under the Mac OS checks, I see four options:
build 2.0.10 vs build 1.2.19 and GUI on vs GUI off.
What is the difference between those?

Lastly, after downloading them and unpacking the .zip, I see there is a .dmg inside and a cmake folder. The app inside the .dmg is crossed out in my case and when trying to open it I get a message "Not supported on this Mac".

Appreciate your patience and help - happy to support testing.. Just need to figure out how to get the artefacts to run.

@ManiMatter
Copy link
Contributor Author

mh. I changed the naming convention across the board, but now CI complains, since the word "private" is a reserved word in C++. Any suggestions what to do? Change to "privateFlag"?

@glassez
Copy link
Member

glassez commented Jun 7, 2024

mh. I changed the naming convention across the board, but now CI complains, since the word "private" is a reserved word in C++. Any suggestions what to do? Change to "privateFlag"?

I couldn't imagine that you would misinterpret my comment above so much. I definitely didn't want you to change naming convention we use. I was just stating a fact about such a convention so that you could understand where the name of the method isPrivate came from.

@ManiMatter
Copy link
Contributor Author

sorry. new to all of this.. let me revert the commit.
My understanding was that the suggestion was to consistently rename the "is private" to "private"; I must have misunderstood.

Could you again please point me in the right direction in what sense I shall change the namings? Are we only talking about the matchIsPrivate and setIsPrivate functions to matchPrivate and setPrivate?

@ManiMatter ManiMatter force-pushed the info-API-filter-by-isPrivate-flag branch from 7f51598 to 47c05fd Compare June 7, 2024 15:13
@Chocobo1
Copy link
Member

Chocobo1 commented Jun 8, 2024

In my regular setup, I run a docker container which I pull from lscr.io/linuxserver/qbittorrent:latest.
My take is that the artefacts from the CI do not provide a docker image, correct?

Yes, no docker image.

If that's the case, I'm left off with my Mac to test (which runs on Sonoma).
Under the Mac OS checks, I see four options:
build 2.0.10 vs build 1.2.19 and GUI on vs GUI off.
What is the difference between those?

Different libtorrent versions and with GUI or not. Probably doesn't matter for you.

Lastly, after downloading them and unpacking the .zip, I see there is a .dmg inside and a cmake folder. The app inside the .dmg is crossed out in my case and when trying to open it I get a message "Not supported on this Mac".

It seems our mac artifacts is for ARM. You're out of luck then...

@ManiMatter
Copy link
Contributor Author

Many thanks for the guidance, @Chocobo1 . Besides not being 100% on the proposed renamings of the variables/functions (last post), I unfortunately do not know how to finish this PR without being able to test myself. Do you see any way that I can test (or would you know about someone who could support)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebAPI WebAPI-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants