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

feat(api): change calculation variable for pull data from providers #2962

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading