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

Show duration and filesize in results #1776

Conversation

kermieisinthehouse
Copy link
Collaborator

@kermieisinthehouse kermieisinthehouse commented Sep 27, 2021

Resolves #1775

This PR has some issues. Off the top of my head:

  1. the frontend stuff can be ignored. It's a mess and I'm sure I'm doing stuff wrong
  2. the scenes query doesn't work if it requires a join (probably simple)
  3. the images query is untested and doesn't work
  4. For performance, Query () may need to be refactored into something along the lines of:
type SceneQueryStatsRequest struct {
    count bool
    durationSeconds bool
    filesizeBytes bool
}

type SceneQueryStats struct {
    count int
    durationSeconds float64
    filesizeBytes int
}

func Query(query queryBuilder ..., statsToReturn SceneQueryStatsRequested) (scenes ..., stats SceneQueryStats) {
...
}

So that it will conditionally run the queries.

@WithoutPants WithoutPants added bounty This issue has a bounty on it in the OpenCollective improvement Something needed tweaking. labels Sep 27, 2021
@kermieisinthehouse kermieisinthehouse added this to the Version 0.11.0 milestone Oct 10, 2021
@WithoutPants
Copy link
Collaborator

I have finally spent some time working on this. The backend is complete. It refactors the way we perform Scene and Image queries. They now accept a query options object which gives the filter criteria and the wanted return values. They return a query result object, which only contains the ids initially, and can be resolved into objects. All impacted calling methods are adjusted. At the api package-level, the aggregate values (count, filesize etc) are only queried for if the field was requested in the graphql.

The frontend has been adjusted slightly, but imo still needs a bit of work. I'm not yet convinced that - at least currently - having pagination at both the top and bottom is necessarily a good idea. At the top, it uses up quite a lot of vertical real estate.

image

I particularly don't think that its useful (or aesthetically pleasing) to have the pagination statistics at both the top and the bottom.

It looks pretty ordinary especially when there is a small amount of results:

image

I don't have any decent prior art to work with - or UX principles - but these would be my suggestions:

  • both paginations should not be shown if they will be on the same screen without scrolling. I'm not sure how to implement something like this though. The hacky solution is to not show it if there are fewer items than some constant. I suspect that we'll get complaints about inconsistent behaviour with this though.
  • Query statistics should be shown once - either at the bottom, or perhaps right aligned on the same row as the pagination bar, so as not to take up more vertical real estate than necessary.

@kermieisinthehouse
Copy link
Collaborator Author

This is freaking fantastic! Works great, I haven't noticed any performance issues even without the index I thought it needed. Makes it much easier to reason about the relative sizes of sections of a collection.

About the UI concerns, I think they are perfect as-is. I find myself scrolling very often to the bottom of a page to check how many results were returned for a filter, and having it at the top is extremely convenient. You get used to it very quickly. Even with few results, I don't think it's cluttered having it duplicated on the page.

@kermieisinthehouse kermieisinthehouse marked this pull request as ready for review October 21, 2021 06:38
Copy link
Contributor

@SmallCoccinelle SmallCoccinelle left a comment

Choose a reason for hiding this comment

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

This is all the things I can find from a quick glance.

I think it's pretty good.

func QueryWithCount(qb Queryer, imageFilter *models.ImageFilterType, findFilter *models.FindFilterType) ([]*models.Image, int, error) {
// this was moved from the queryBuilder code
// left here so that calling functions can reference this instead
result, err := qb.Query(QueryOptions(imageFilter, findFilter, true))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking, but at this point, result is really a request.

Then you can have request.AddCount()

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is incorrect - Query returns an ImageQueryResult which in this case will contain the ids only. The result is turned into Image objects only with the Resolve function. So not really a request. We want the ability to not resolve the images if we don't need to.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In any case, this particular function is no longer necessary since I removed all reference to it and there are concise alternatives anyway.

return nil, 0, err
}

images, err := result.Resolve()
Copy link
Contributor

Choose a reason for hiding this comment

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

And resolved here into a result. An alternative implementation would return images inside a struct.

It's nitpicking though and I wouldn't let it hold back this patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know the code doesn't do this however.


finder ImageFinder
images []*Image
resolveErr error
Copy link
Contributor

Choose a reason for hiding this comment

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

would probably just call this err. It's implicit it is for resolution.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think renaming it to err could imply that its the error for the query operation and not the resolve operation.

@kermieisinthehouse
Copy link
Collaborator Author

I can't approve my own PR, but
<Tested-By: kermieisinthehouse>

@WithoutPants WithoutPants merged commit 4dd56c3 into stashapp:develop Oct 25, 2021
@kermieisinthehouse kermieisinthehouse deleted the show-duration-and-filesize-in-results branch October 25, 2021 00:43
@Emilaia
Copy link

Emilaia commented Oct 25, 2021

Started getting the following issue since either yesterday or this morning.

image

So I'm going through the newest additions to see what queried an aggregate value, and I believe it should be this feature.

When I apply a filter to target a very limited subset of scenes/images, this error doesn't pop up, but when I leave it to my default filters (which are basically just a random that targets all my entries), this starts to happen. I don't know the concrete implementation to know if one unit of the size int should represent a byte, mb or something higher or smaller.

Can't tell what extra information I should provide other than my library stats, so here you go.

image

@kermieisinthehouse
Copy link
Collaborator Author

@Emilaia What platform are you running on? I'll try to reproduce this

@Emilaia
Copy link

Emilaia commented Oct 25, 2021

Running on a raspberry pi 4B, via docker (so linux/arm), using the latest stashapp/stash:development image.

@kermieisinthehouse
Copy link
Collaborator Author

Can you post the results of docker version and uname -a?

@Emilaia
Copy link

Emilaia commented Oct 25, 2021

image

@SmallCoccinelle
Copy link
Contributor

Armv7l is 32bit, so int is 32bit on that platform. So the count doesn't fit when it is signed. It has to be an int64 to make sure stuff fits in it. The JSON will usually have a problem once get past 53bit integers, since that's the breakoff point for a float64: once you have a larger integer it is not float64-representable.

@SmallCoccinelle
Copy link
Contributor

And sizes are often stored in uint64 or the like. They can't be negative, so it's worth signifying this.

@kermieisinthehouse
Copy link
Collaborator Author

Any number around 3 billion and change always tips me off to 32 bit problems. It's strange how the front page stats don't seem to have a problem. I'll put up a fix when I find the culprit

@bnkai
Copy link
Collaborator

bnkai commented Oct 25, 2021

Same issue was present in the main stats page
Relevant fix #994

@kermieisinthehouse
Copy link
Collaborator Author

Same issue was present in the main stats page Relevant fix #994

You just saved me a few hours!

@kermieisinthehouse
Copy link
Collaborator Author

@Emilaia I opened up a PR, #1895 with a proposed fix, but I don't have an RPI handy to test.

Can you test and see if the problem is resolved? I've created a build for armv7, available at https://kermie.isinthe.house/stash-linux-arm32v7-statsfix

@Emilaia
Copy link

Emilaia commented Oct 26, 2021

Sorry, but I'm unaware as to how use this and docker/docker-compose, as I don't see a file extension attached to it, have only worked with tar files.

@kermieisinthehouse
Copy link
Collaborator Author

It's a plain linux executable. Let me see if I can put together a docker build

@kermieisinthehouse
Copy link
Collaborator Author

@Emilaia
I've created an arm32 docker image for that branch, available at https://kermie.isinthe.house/docker-stashapp-stash-stats-test.tar . You can use it by doing docker load < docker-stashapp-stash-stats-test.tar. Let me know if you need anything else to test.

@Emilaia
Copy link

Emilaia commented Oct 26, 2021

It leads me to a 404

@kermieisinthehouse
Copy link
Collaborator Author

Sorry, I thought it would upload a lot faster - should be all set now.

@Emilaia
Copy link

Emilaia commented Oct 26, 2021

Tested it on all the screens that I had the issues with before, no issues now.
Guess I'll keep this image until the official rollout comes, haha.

@kermieisinthehouse
Copy link
Collaborator Author

Fantastic! That PR will probably hit develop soon, and if you use the 'latest' branch, it will probably be sometime in November.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty This issue has a bounty on it in the OpenCollective improvement Something needed tweaking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Show stats / totals for list results
5 participants