-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
url cleanup upgrade #148
base: release/0.2.0
Are you sure you want to change the base?
url cleanup upgrade #148
Conversation
Codecov Report
@@ Coverage Diff @@
## release/0.2.0 #148 +/- ##
=================================================
+ Coverage 18.11% 18.63% +0.51%
=================================================
Files 36 36
Lines 1325 1358 +33
Branches 46 47 +1
=================================================
+ Hits 240 253 +13
- Misses 1057 1077 +20
Partials 28 28
Continue to review full report at Codecov.
|
That's only for the InMemory driver. What about the Relational driver? Also, we've talked about a possible flag in the config to specify whether to delete from created_at date or from last_used date. |
|
@SnirShechter pls check |
Co-authored-by: lesagi <[email protected]>
Co-authored-by: lesagi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing crucial, everything looks fine
the .env I changed to the same format of choosing one option out of many as the 'storage' has
in the relativeDate, I'm trying to use const as much as I can, but that's just a general preference, you can ignore it if you think it's less readable
@lesagi I already accept your changes and commited them.. thanks for the explanation though. I asked for review again to check those changes and approve\request more changes |
@@ -43,8 +43,8 @@ export class InMemoryStorage implements StorageDriver { | |||
let deletedCount = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment in the PR
import type { StoredUrl, UrlWithInformation, UrlRequestData, UrlInformation } from '../../types/url.js' | ||
import type {StoredUrl, UrlWithInformation, UrlRequestData, UrlInformation} from '../../types/url.js' | ||
import {logger} from "../../../logger/logger"; | ||
import {getRawConfig} from "../../../../config/__test__/helpers"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to pass the expireFrom via the driver configurations instead of importing the config.
Also, you imported functions from the tests.
const updatedAt = new Date(storedUrl.updatedAt).getTime() | ||
if (updatedAt <= deleteBefore) { | ||
const relativeDate = new Date(deleteFrom === 'update' ? storedUrl.updatedAt : storedUrl.createdAt).getTime() | ||
if (relativeDate <= deleteBefore) { | ||
this.storage.data.urls.delete(storedUrl.id) | ||
deletedCount++ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's the Relational implementation?
src/config/validate.ts
Outdated
@@ -101,6 +102,13 @@ function validateUrlLifetime(urlLifetime: string): void { | |||
} | |||
} | |||
|
|||
function validateUrlExpireFrom(urlExpire: string): void { | |||
logger.debug(`Start validateUrlExpireFrom with ${urlExpire}`) | |||
if (!urlExpire || (urlExpire != 'create' && urlExpire != 'update')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature we talked about is "expire from either 'create' or 'last used' ". You should add the 'last used'.
Co-authored-by: Snir Shechter <[email protected]>
Co-authored-by: Snir Shechter <[email protected]>
@SnirShechter conflicts resolved |
Closes #16