(query: Knex.QueryBuilder, options: CleanDbOptions)
| 159 | } |
| 160 | |
| 161 | const applySelectiveFilters = (query: Knex.QueryBuilder, options: CleanDbOptions): Knex.QueryBuilder => { |
| 162 | if (options.olderThanDays !== undefined) { |
| 163 | const olderThanSeconds = options.olderThanDays * 24 * 60 * 60 |
| 164 | const cutoff = Math.floor(Date.now() / 1000) - olderThanSeconds |
| 165 | query.where('event_created_at', '<', cutoff) |
| 166 | } |
| 167 | |
| 168 | if (options.kinds.length) { |
| 169 | query.whereIn('event_kind', options.kinds) |
| 170 | } |
| 171 | |
| 172 | return query |
| 173 | } |
| 174 | |
| 175 | const getMatchingEventsCount = async (dbClient: Knex, options: CleanDbOptions): Promise<number> => { |
| 176 | const query = dbClient('events') |
no outgoing calls
no test coverage detected