From fe2fca4868111b6066c54841bb29479751b5a7f2 Mon Sep 17 00:00:00 2001 From: Yadd Date: Sun, 15 Dec 2024 19:03:46 +0100 Subject: [PATCH] Fix sessions count --- Changes.md | 1 + full/Dockerfile | 1 + full/fix-sessions-count.patch | 19 +++++++++++++++++++ manager/Dockerfile | 1 + manager/fix-sessions-count.patch | 19 +++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 full/fix-sessions-count.patch create mode 100644 manager/fix-sessions-count.patch diff --git a/Changes.md b/Changes.md index 1b70b30..5ddefe1 100644 --- a/Changes.md +++ b/Changes.md @@ -3,6 +3,7 @@ ## v2.20.1-2 * Add "Last-Modified" header for OIDC metadata * Add hook to modify refresh\_token +* Fix offline sessions count ## v2.20.1-1 _(2024-11-19)_ * Update to 2.20.1 diff --git a/full/Dockerfile b/full/Dockerfile index 92a42a6..97cecbc 100644 --- a/full/Dockerfile +++ b/full/Dockerfile @@ -26,6 +26,7 @@ RUN \ echo patch matrix-token-exchange.patch && patch -p1 < matrix-token-exchange.patch && \ echo patch globalLogout.patch && patch -p1 < globalLogout.patch && \ echo patch metadata-ttl.patch && patch -p1 < metadata-ttl.patch && \ + echo patch fix-sessions-count.patch && patch -p1 run( \ diff --git a/full/fix-sessions-count.patch b/full/fix-sessions-count.patch new file mode 100644 index 0000000..7ae5ccc --- /dev/null +++ b/full/fix-sessions-count.patch @@ -0,0 +1,19 @@ +--- a/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm ++++ b/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm +@@ -396,6 +396,7 @@ qq{Use of an uninitialized attribute "$group" to group sessions}, + } + + # Build result ++ $total = 0; + $res = [ + sort { + my @a = ( $a->{value} =~ /^(\d+)(?:\.(\d+))*$/ ); +@@ -407,7 +408,7 @@ qq{Use of an uninitialized attribute "$group" to group sessions}, + or $a[3] <=> $b[3] ) + : $a->{value} cmp $b->{value} + } +- map { { value => $_, count => $r->{$_} } } keys %$r ++ map { $total += $r->{$_}; { value => $_, count => $r->{$_} } } keys %$r + ]; + } + diff --git a/manager/Dockerfile b/manager/Dockerfile index 269422c..d323810 100644 --- a/manager/Dockerfile +++ b/manager/Dockerfile @@ -33,6 +33,7 @@ RUN \ echo patch matrix-token-exchange.patch && patch -p1 < matrix-token-exchange.patch && \ echo patch globalLogout.patch && patch -p1 < globalLogout.patch && \ echo patch metadata-ttl.patch && patch -p1 < metadata-ttl.patch && \ + echo patch fix-sessions-count.patch && patch -p1 run( \ diff --git a/manager/fix-sessions-count.patch b/manager/fix-sessions-count.patch new file mode 100644 index 0000000..7ae5ccc --- /dev/null +++ b/manager/fix-sessions-count.patch @@ -0,0 +1,19 @@ +--- a/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm ++++ b/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm +@@ -396,6 +396,7 @@ qq{Use of an uninitialized attribute "$group" to group sessions}, + } + + # Build result ++ $total = 0; + $res = [ + sort { + my @a = ( $a->{value} =~ /^(\d+)(?:\.(\d+))*$/ ); +@@ -407,7 +408,7 @@ qq{Use of an uninitialized attribute "$group" to group sessions}, + or $a[3] <=> $b[3] ) + : $a->{value} cmp $b->{value} + } +- map { { value => $_, count => $r->{$_} } } keys %$r ++ map { $total += $r->{$_}; { value => $_, count => $r->{$_} } } keys %$r + ]; + } +