File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -27,21 +27,18 @@ export const ephemeralEdgeDB = async () => {
27
27
async function dropStale ( db : Client ) {
28
28
const branches = await db . query < string > ( 'select sys::Database.name' ) ;
29
29
30
- const stale = branches . flatMap ( ( name ) => {
30
+ const stale = branches . filter ( ( name ) => {
31
31
if ( ! name . startsWith ( 'test_' ) ) {
32
- return [ ] ;
32
+ return false ;
33
33
}
34
34
const ts = Number ( name . slice ( 5 ) ) ;
35
35
if ( isNaN ( ts ) ) {
36
- return [ ] ;
36
+ return false ;
37
37
}
38
38
const createdAt = DateTime . fromMillis ( ts ) ;
39
- return createdAt . diffNow ( ) . as ( 'hours' ) > 4 ? name : [ ] ;
40
- } ) ;
41
- if ( stale . length === 0 ) {
42
- return ;
43
- }
44
- await db . execute ( 'drop branch array_unpack(<array<string>>$branches)' , {
45
- branches : stale ,
39
+ // more than 1 hour old
40
+ return createdAt . diffNow ( ) . as ( 'hours' ) < - 1 ;
46
41
} ) ;
42
+
43
+ await Promise . all ( stale . map ( ( branch ) => db . execute ( `drop branch ${ branch } ` ) ) ) ;
47
44
}
You can’t perform that action at this time.
0 commit comments