Skip to content

Update home image query for staff users#479

Merged
Meow merged 7 commits intophilomena-dev:masterfrom
mdashlw:home-query-staff
May 2, 2025
Merged

Update home image query for staff users#479
Meow merged 7 commits intophilomena-dev:masterfrom
mdashlw:home-query-staff

Conversation

@mdashlw
Copy link
Contributor

@mdashlw mdashlw commented Mar 24, 2025

Before you begin

  • I understand my contributions may be rejected for any reason
  • I understand my contributions are for the benefit of Derpibooru and/or the Philomena software
  • I understand my contributions are licensed under the GNU AGPLv3
  • I understand all of the above

closes #426

@Meow
Copy link
Member

Meow commented Mar 25, 2025

Make it a setting staff can toggle on/off, i can see it being useful to see what users see.

@liamwhite
Copy link
Contributor

I'm curious why do this if you can use search *?

@mdashlw
Copy link
Contributor Author

mdashlw commented Apr 7, 2025

Make it a setting staff can toggle on/off, i can see it being useful to see what users see.

I added a new setting in a way that defaults to true for normal users and false for staff.

I'm curious why do this if you can use search *?

I've had this behavior in a userscript for probably over a year and it's really convenient to see new images on the home page directly, e.g. to find your own uploads.


- delay_home_images = if staff?(@conn.assigns.current_user), do: :staff_delay_home_images, else: :delay_home_images
= field_with_help( \
"Delay images on the home page for 3 minutes and until thumbnails are generated",
Copy link
Member

Choose a reason for hiding this comment

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

"Show images on the homepage with a 3 minute delay, to ensure that the thumbnails are generated, and to allow uploaders to check their tagging after upload."

Copy link
Contributor

@MareStare MareStare Apr 7, 2025

Choose a reason for hiding this comment

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

3 minute delay isn't there to ensure the thumbnails are generated. There is a separate condition that ensures that:

must_not: [%{term: %{thumbnails_generated: false}}]

Thus, the current text proposed by @mdashlw is more accurate. Could be slightly "improved" (or worsened?) like this:

Suggested change
"Delay images on the home page for 3 minutes and until thumbnails are generated",
"Hide images without thumbnails on home page, and for the first 3 minutes after upload (to allow for last-minute tag updates)",

But it probably makes sense to split this into two separate settings - for "no thumbnails generated" and "N minute delay"

Copy link
Contributor

@MareStare MareStare Apr 7, 2025

Choose a reason for hiding this comment

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

Another approach may be just a single input for "Home page search query" which defaults to the current

created_at.lte:3 minutes ago, -thumbnails_generated:false

Btw. just noticed that query could be simplified to this (unless I'm missing some caveat):

created_at.lte:3 minutes ago, thumbnails_generated:true

The description of this input would then explain why this query was chosen as the default one.

@Meow Meow merged commit 4c06c40 into philomena-dev:master May 2, 2025
6 checks passed
@mdashlw mdashlw deleted the home-query-staff branch May 2, 2025 23:48
@MareStare
Copy link
Contributor

MareStare commented May 4, 2025

QA

Images without thumbnails are shown by default for Administrator. If this setting is enabled:
image

then images without thumbnails are not shown.

Regular users also have access to this setting, but the delay is enabled by default for them.

Not clear why we need separate staff_delay_home_images and delay_home_images boolean configs. @mdashlw what's the reason to make two different fields here? Couldn't we just use a single field here?

@MareStare MareStare added the qa accepted The change was tested by another person (not the PR author) label May 4, 2025
@mdashlw
Copy link
Contributor Author

mdashlw commented May 5, 2025

@MareStare for different defaults for regular users and staff

@MareStare
Copy link
Contributor

MareStare commented May 5, 2025

for different defaults for regular users and staff

I see, Postgres doesn't allow using other columns of the row in the DEFAULT expression or subqueries. However, we could just make the delay_home_images column nullable, and handle defaulting at the application code level. That might be cleaner.

The existing code already has a similar logic at app level where it selects which of the fields to use (staff_ one or the regular one). Instead, it could check

if(is_nil(user.delay_home_images), do: user.role == "user", else: user.delay_home_images)

@mdashlw
Copy link
Contributor Author

mdashlw commented May 5, 2025

@MareStare feel free to do this if you want.

@MareStare
Copy link
Contributor

MareStare commented May 5, 2025

After I did this change (#561) I realized that with my suggested approach the following unwanted scenario will happen:

  • User creates a fresh account
  • User goes to its "Display" settings, the default delay_home_images: true checkbox is set.
  • User changes the values of unrelated settings, and clicks "save"
  • The value true is now set in the DB column delay_home_images instead of null (taken from the checkbox from Frontend)
  • The user is promoted to a staff user
  • The user already has the value true in delay_home_images, so its delay_home_images stays true even after they became staff

With separate staff_delay_home_images and delay_home_images columns the value of delay changes appropriately when the user is promoted/demoted to/from staff automatically. So, better keep it this way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa accepted The change was tested by another person (not the PR author)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show newest images in Activity

4 participants