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

add optional expiration date to cleezy #36

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

drew-tom1
Copy link
Collaborator

Synchronized time formatting to '%Y-%m-%dT%H:%M:%S.
Added expiration date column to db table (OPTIONAL PARAMETER, SHOULD WORK EITHER WAY)
Auto delete on next URL request if expiration date is invalid

Some inconsistencies with timestamp formatting when I tested with Postman but I didn't know how to fix, small detail to clean up

Added expiration date column to db table (OPTIONAL PARAMETER)
@drew-tom1 drew-tom1 linked an issue Jun 21, 2024 that may be closed by this pull request
5 tasks
@drew-tom1 drew-tom1 marked this pull request as draft June 21, 2024 14:21
@drew-tom1 drew-tom1 closed this Jun 21, 2024
@drew-tom1 drew-tom1 reopened this Jun 21, 2024
@drew-tom1 drew-tom1 marked this pull request as ready for review June 21, 2024 15:59
@@ -17,6 +17,7 @@ def maybe_create_table(sqlite_file: str) -> bool:
url TEXT NOT NULL,
alias TEXT NOT NULL,
created_at DATETIME NOT NULL,
expiration_date DATETIME DEFAULT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this the last column, right now its second to last

@drew-tom1
Copy link
Collaborator Author

done

@@ -93,7 +104,7 @@ async def get_url(alias: str):
logging.debug(f"/find called with alias: {alias}")
with MetricsHandler.query_time.labels("find").time():
url_output = sqlite_helpers.get_url(DATABASE_FILE, alias)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

if response is not None:
MetricsHandler.url_count.inc(1)
return { "url": urljson['url'], "alias": alias, "created_at": response}
return { "url": urljson['url'], "alias": alias, "created_at": response, "expiration_date": expiration_date}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return { "url": urljson['url'], "alias": alias, "created_at": response, "expiration_date": expiration_date}
return return {
"url": urljson['url'],
"alias": alias,
"created_at": response,
"expiration_date": expiration_date,
}

db.commit()
return True

year_ago_date = current - timedelta(days=365)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last thing, can we remove the logic to automatically delete urls that are a year old? from now on the user will have to specify an expiration date if they want it deleted

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be done

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.

Add an optional expiration date column for urls
2 participants