diff --git a/.github/workflows/push-container.yml b/.github/workflows/push-container.yml index 8487216..984a590 100644 --- a/.github/workflows/push-container.yml +++ b/.github/workflows/push-container.yml @@ -15,22 +15,8 @@ jobs: id: prep run: | IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/rfd-notify - VERSION=${GITHUB_REF##*/} - - if [[ $GITHUB_REF == refs/heads/main ]]; then - VERSION=1 - fi - - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/v} - fi - + VERSION=2 TAGS="${IMAGE_NAME}:${VERSION}" - - if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - TAGS="$TAGS,${IMAGE_NAME}:2" - fi - echo ::set-output name=tags::${TAGS} - name: Set up Docker Buildx diff --git a/README.md b/README.md index aeb554f..5bb502f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This was originally written before [alerts](https://www.redflagdeals.com/alerts/ The simplest way to get started is to clone this repo, and run with docker: ```sh -docker run -it -v "$(pwd)/examples/config.yml:/app/config.yml" ghcr.io/davegallant/rfd-notify:1 +docker run -it -v "$(pwd)/examples/config.yml:/app/config.yml" ghcr.io/davegallant/rfd-notify:2 ``` To run the code with [poetry](https://python-poetry.org/), clone this repo and run the following: diff --git a/poetry.lock b/poetry.lock index 8c673ea..b73480a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "apprise" @@ -242,6 +242,20 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "humanize" +version = "4.12.1" +description = "Python humanize utilities" +optional = false +python-versions = ">=3.9" +files = [ + {file = "humanize-4.12.1-py3-none-any.whl", hash = "sha256:86014ca5c52675dffa1d404491952f1f5bf03b07c175a51891a343daebf01fea"}, + {file = "humanize-4.12.1.tar.gz", hash = "sha256:1338ba97415c96556758a6e2f65977ed406dddf4620d4c6db9bbdfd07f0f1232"}, +] + +[package.extras] +tests = ["freezegun", "pytest", "pytest-cov"] + [[package]] name = "idna" version = "3.7" @@ -731,4 +745,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "5aa566ddd905579ebaaa263114dbf1b5452b8d86c81e92ff58f8f54be1ce996f" +content-hash = "54449b2b645fde726694dda72179361a63d12eeeccb7607e2fadfd63d02fcdce" diff --git a/pyproject.toml b/pyproject.toml index 2e2990d..e5df0b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [tool.poetry] name = "rfd-notify" -version = "2.0.0" +version = "2.1.0" description = "get notified of deals based on regex" -authors = ["Dave Gallant "] +authors = ["Dave Gallant "] readme = "README.md" packages = [{include = "rfd_notify"}] @@ -12,6 +12,7 @@ requests = "^2.31.0" pyyaml = "^6.0" loguru = "^0.7.2" apprise = "^1.7.1" +humanize = "^4.12.1" [tool.poetry.group.dev.dependencies] pytest = "^8.0.0" diff --git a/rfd_notify/notifications.py b/rfd_notify/notifications.py index 573260f..4626087 100644 --- a/rfd_notify/notifications.py +++ b/rfd_notify/notifications.py @@ -1,6 +1,7 @@ from datetime import datetime, timezone import apprise +import humanize from models.topic import Topic from loguru import logger from constants import API_BASE_URL @@ -17,7 +18,7 @@ def send_notification(topic: Topic, expression: str, servers: str) -> None: subject = topic.title body = f"""\ {API_BASE_URL}{topic.web_path} -Age: {datetime.now(timezone.utc) - datetime.fromisoformat(topic.post_time)} +⌚ {humanize.naturaltime(datetime.now(timezone.utc) - datetime.fromisoformat(topic.post_time))} Matched by expression: {expression} """