christianwgd / django_restic_gui

A GUI web application for restic backup
MIT License
8 stars 2 forks source link

Stats #14

Closed morlandi closed 2 years ago

morlandi commented 2 years ago

The total file count has been added to RepoSize and collected using the "stats" restic command.

I refactored a little the repository chart as follows:

Finally, a "summary chart" for all repos has been added to the home page; this has been my real target since the beginning: to have a visual feedback of how repos are proceeding.

Unfortunately, I just collected real data for a couple of days, and sadly my summary chart just displays some flat, meaningless segments. Hopefully, this will improve as soon as a more significant set of data will be collected.

On the long run, the opposite problem will occur: too many data in the chart; when this will happen, I might consider doing some aggregation on the backend with hte ORM, or maybe simply ignore the oldest values and plot only the most recent stats.

A more serious limitation is that different repos may have very, very different sizes; as a result, the plots for the smallest ones will be extremely compressed along the Y axis. A possible solution could be to show the percentage increase over time as suggested here: https://blog.datawrapper.de/dualaxis/ (read section "Solution 2: Indexed charts")

christianwgd commented 2 years ago

Hi Mario,

found a little bug when testing: If I go into a repos snapshot list and return via breadcrumb, everything is fine. Returning by clicking the browsers "back" button gives me the spinner on the homepage spinning forever. Reloading the page makes it disappear. Seems like the initial state of the spinner is not correct. Can you fix that?

Thanks, Christian

morlandi commented 2 years ago

Hello Christian, good catch .. but I'm unable to reproduce it (I'm using Chrome on Mac OS/X). In which context did you see the problem ?

The initial spinner state is hidden, then becomes visible as a side effetct of clicking the link; after a page refresh it'll be hidden again. That was the simplest trick I could think of , though admittedly rather rude.

I might try to fix it by following this:

https://codepen.io/balatd/pen/VwabrZg

but first would like to reproduce the problem

christianwgd commented 2 years ago

Hi Mario,

tried Safari, Firefox and Chrome (all on macOS) and all the same, the spinner shows up after browser back.

I’m afraid the function „wip()“ in the base template is much too global. After pressing browser back, the body still has the class „wip“, so is shown and the page is greyed out. Actually I didn’t find any „removeClass()“ for the wip class. Can you give a short explanation, what does reset the wip?

Christian

Am 22.06.2022 um 08:05 schrieb morlandi @.***>:

Hello Christian, good catch .. but I'm unable to reproduce it (I'm using Chrome on Mac OS/X). In which context did you see the problem ?

The initial spinner state is hidden, then becomes visible as a side effetct of clicking the link; after a page refresh it'll be hidden again. That was the simplest trick I could think of , though admittedly rather rude.

I might try to fix it by following this:

https://codepen.io/balatd/pen/VwabrZg https://codepen.io/balatd/pen/VwabrZg but first would like to reproduce the problem

— Reply to this email directly, view it on GitHub https://github.com/christianwgd/django_restic_gui/pull/14#issuecomment-1162681459, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACG2A34FWJPQSCZURSUQDL3VQKUJTANCNFSM5ZOGNQPQ. You are receiving this because you commented.

morlandi commented 2 years ago

Actually I didn’t find any „removeClass()“ for the wip class. Can you give a short explanation, what does reset the wip?

Nobody calls removeClass() since I rely on the next page refresh, after the slow restic command has been completed server side and the new response has been sent back to the client.

I was able to reproduce the problem with Firefox and Safari (not with Chrome, though). I tried a couple of fixes with no luck.

In the snippet below, a few redundant actions have been attempted, but they didn't help.

<script>

    $('body').removeClass('wip');
    function wip() {$('body').addClass('wip');}
    function nowip() {console.log('nowip...'); $('body').removeClass('wip')}

    $(document).ready(function() {
        nowip();
        console.log('ready');
        $(window).on('popstate', function(event) {
            nowip();
        });
    });

</script>

Here is a jQuery plugin to detect "back button"; that's too much for my taste :wink:

https://www.jqueryscript.net/other/jQuery-Plugin-To-Detect-Back-Button-Click-In-Browser-backDetect.html#google_vignette

Another option could be to disable caching, but this means to modify different views; I tried with RepositoryList:

from django.utils.decorators import method_decorator
from django.views.decorators.cache import never_cache

class RepositoryList(LoginRequiredMixin, ListView):
    model = Repository

    @method_decorator(never_cache)
    def dispatch(self, *args, **kwargs):
        return super().dispatch(*args, **kwargs)

and it seems to help with Firefox, but not with Safari. Oh boy, this is more challenging then I expected.

Christian, I exhausted my spare time for today :smile: but I'll be back asap on this

christianwgd commented 2 years ago

Best we could do, is setup a socket server in javascript, that will listen to simple signals for enabling and disabling the spinner (see here). Sending the signals could be done in "restic_command".

christianwgd commented 2 years ago

Could you please comment out the spinner for now, so that i can merge this pull request? Seems like the charts are working fine and i would like to see, if the scaling is a problem with real life data

morlandi commented 2 years ago

Could you please comment out the spinner for now, so that i can merge this pull request? Seems like the charts are working fine and i would like to see, if the scaling is a problem with real life data

I will in a few minutes

morlandi commented 2 years ago

PR updated; go ahead ;)

and i would like to see, if the scaling is a problem with real life data

I'm curious too 😉

Thats what I see now .. not very exciting:

Screen Shot 2022-06-22 at 11 22 51

By removing all but one repo, things start to get more interesting since the Y axis range is more appropriate; at least you can see a trend ...

Screen Shot 2022-06-22 at 11 26 09
morlandi commented 2 years ago

.. so that an interesting alternative could be this one:

Screen Shot 2022-06-22 at 11 50 57

https://blog.datawrapper.de/dualaxis/

christianwgd commented 2 years ago

Ok, can't tell until tomorrow, since my file count is zero for now.

Concerning the socket communication this would be a good start. Maybe a little oversized, but mature, stable, well documented and currently maintained.

morlandi commented 2 years ago

Ok, can't tell until tomorrow, since my file count is zero for now.

at least you can check the size in GB; since the file counts uses the secondary Y axis, it sholdn't interfere

@christianwgd I'm a big fan of django-channel and have been using it extensively in some projects; here below is a "recap" checklist I shared some time ago with other people interested in this technology, and that you might want to take a quick look at to have an idea about the required context:

https://stackoverflow.com/questions/56913676/dynamic-updates-in-real-time-to-a-django-template/56964980#56964980

Having said this, I sadly do believe this is too much to quit a spinner. django-channels has several dependencies, which need constant updates as Django evolves; depending on the available version of redis, you might need to fine tune the pinned version for both channels and channels-redis; which is doable, but rather annoing.

I would rather investigate the socket.io options you were talking about a few comments above, both to apply an hopefully lightest solution, and to learn something new I'm really interested in

christianwgd commented 1 year ago

No hurry, was more of a reminder than a immediate request ;-)

Am 22.06.2022 um 11:18 schrieb morlandi @.***>:

Could you please comment out the spinner for now, so that i can merge this pull request? Seems like the charts are working fine and i would like to see, if the scaling is a problem with real life data

I will in a few minutes

— Reply to this email directly, view it on GitHub https://github.com/christianwgd/django_restic_gui/pull/14#issuecomment-1162857404, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACG2A3Z5M3IAL6PC6FUYU4LVQLK43ANCNFSM5ZOGNQPQ. You are receiving this because you commented.

morlandi commented 1 year ago

Hello @christianwgd ...

I had the opportunity to consider socket.io for another project, and by checking in more detail I realized that it is actually a wrapper on Websocket, so in this case I think it is more linear to use Websocket directly.

In this specific case, I think it would still be a bit over-engineering to include django-channels for so little