Skip to content

Commit

Permalink
feat(api): change calculation variable for pull data from providers (#…
Browse files Browse the repository at this point in the history
…2962)

Co-authored-by: Tal <[email protected]>
  • Loading branch information
00041275 and talboren authored Jan 5, 2025
1 parent 81d69fe commit 8ecb6b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions keep/api/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

load_dotenv(find_dotenv())
RUNNING_IN_CLOUD_RUN = os.environ.get("K_SERVICE") is not None
PROVIDER_PULL_INTERVAL_DAYS = int(
os.environ.get("KEEP_PULL_INTERVAL", 7)
PROVIDER_PULL_INTERVAL_MINUTE = int(
os.environ.get("KEEP_PULL_INTERVAL", 10080)
) # maximum once a week
STATIC_PRESETS = {
"feed": PresetDto(
Expand Down
8 changes: 4 additions & 4 deletions keep/api/routes/preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pydantic import BaseModel
from sqlmodel import Session, select

from keep.api.consts import PROVIDER_PULL_INTERVAL_DAYS, STATIC_PRESETS
from keep.api.consts import PROVIDER_PULL_INTERVAL_MINUTE, STATIC_PRESETS
from keep.api.core.db import get_db_preset_by_name
from keep.api.core.db import get_presets as get_presets_db
from keep.api.core.db import (
Expand Down Expand Up @@ -87,13 +87,13 @@ def pull_data_from_providers(

if provider.last_pull_time is not None:
now = datetime.now()
days_passed = (now - provider.last_pull_time).days
if days_passed <= PROVIDER_PULL_INTERVAL_DAYS:
minutes_passed = (now - provider.last_pull_time).total_seconds() / 60
if minutes_passed <= PROVIDER_PULL_INTERVAL_MINUTE:
logger.info(
"Skipping provider data pulling since not enough time has passed",
extra={
**extra,
"days_passed": days_passed,
"minutes_passed": minutes_passed,
"provider_last_pull_time": str(provider.last_pull_time),
},
)
Expand Down

0 comments on commit 8ecb6b8

Please sign in to comment.