File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ use strict;
2
+ use warnings;
3
+ use v5.36;
4
+
5
+ use DateTime ();
6
+
7
+ use MetaCPAN::Logger qw< :log :dlog > ;
8
+
9
+ use MetaCPAN::ES;
10
+
11
+ # setup
12
+ my $es = MetaCPAN::ES-> new( index => " user" , type => " session" );
13
+ my $bulk = $es -> bulk( max_count => 10_000, );
14
+ my $scroll = $es -> scroll(
15
+ size => 10_000,
16
+ scroll => ' 1m' ,
17
+ );
18
+
19
+ my $cutoff = DateTime-> now-> subtract( months => 1 )-> epoch;
20
+
21
+ while ( my $search = $scroll -> next ) {
22
+ next unless $search -> {_source }{__updated } < $cutoff ;
23
+ $bulk -> delete ( { id => $search -> {_id } } );
24
+ }
25
+
26
+ $bulk -> flush;
27
+
28
+ log_info {' done' };
29
+
30
+ 1;
31
+
32
+ =pod
33
+
34
+ Purges user sessions. we iterate over the sessions for the time being and
35
+ perform bulk delete.
36
+
37
+ =cut
You can’t perform that action at this time.
0 commit comments