Skip to content
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

Open
wants to merge 14 commits into
base: release/0.2.0
Choose a base branch
from
Open

url cleanup upgrade #148

wants to merge 14 commits into from

Conversation

shay123g
Copy link
Contributor

Closes #16

@codecov
Copy link

codecov bot commented Mar 13, 2021

Codecov Report

Merging #148 (75c9a8f) into release/0.2.0 (5afc392) will increase coverage by 0.51%.
The diff coverage is 25.92%.

Impacted file tree graph

@@                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              
Impacted Files Coverage Δ
src/config/index.ts 0.00% <0.00%> (ø)
src/config/types.ts 0.00% <0.00%> (ø)
src/index.ts 0.00% <0.00%> (ø)
src/services/storage/drivers/inMemory/index.ts 0.00% <0.00%> (ø)
src/services/storage/drivers/relational/index.ts 0.00% <0.00%> (ø)
src/services/storage/drivers/relational/types.ts 0.00% <0.00%> (ø)
src/services/storage/index.ts 0.00% <0.00%> (ø)
src/config/validate.ts 91.52% <75.00%> (-1.21%) ⬇️
src/config/__test__/helpers.ts 100.00% <100.00%> (ø)
src/config/normalize.ts 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5afc392...75c9a8f. Read the comment docs.

@SnirShechter
Copy link
Member

@shay123g

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.

@shay123g
Copy link
Contributor Author

shay123g commented Mar 13, 2021

@shay123g

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.

  1. I will fix
  2. Relational - @Danielg212 still working on it, he need to complete the fix for deleteOverdue

Shay.Gazit added 3 commits March 13, 2021 21:01
 into release/0.2.0

� Conflicts:
�	src/services/storage/drivers/inMemory/index.ts
@shay123g
Copy link
Contributor Author

@SnirShechter pls check

@shay123g shay123g requested review from SnirShechter and lesagi and removed request for lesagi, Danielg212 and SnirShechter March 16, 2021 11:13
.env.development Outdated Show resolved Hide resolved
@shay123g shay123g requested a review from lesagi March 16, 2021 11:38
Copy link
Contributor

@lesagi lesagi left a 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

@shay123g
Copy link
Contributor Author

@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

@shay123g shay123g requested a review from lesagi March 16, 2021 14:14
@shay123g shay123g changed the title #16 url cleanup upgrade Mar 17, 2021
@shay123g shay123g linked an issue Mar 17, 2021 that may be closed by this pull request
@@ -43,8 +43,8 @@ export class InMemoryStorage implements StorageDriver {
let deletedCount = 0
Copy link
Member

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

src/config/validate.ts Outdated Show resolved Hide resolved
src/config/validate.ts Outdated Show resolved Hide resolved
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";
Copy link
Member

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++
}
Copy link
Member

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?

@@ -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')) {
Copy link
Member

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'.

shay123g and others added 2 commits March 22, 2021 10:04
Co-authored-by: Snir Shechter <[email protected]>
Co-authored-by: Snir Shechter <[email protected]>
Shay.Gazit added 3 commits March 28, 2021 19:37
 into 16

� Conflicts:
�	src/config/types.ts
�	src/index.ts
�	src/services/storage/drivers/inMemory/index.ts
�	src/services/storage/drivers/relational/index.ts
@shay123g
Copy link
Contributor Author

@SnirShechter conflicts resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Url cleanup upgrades
4 participants