Skip to content

Commit

Permalink
Ony hyrdate posts 7 days old
Browse files Browse the repository at this point in the history
  • Loading branch information
richardr1126 committed Jan 11, 2025
1 parent 85e9bf4 commit 807c47f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /usr/src/app/
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
# Copy the rest of the application code except .dockerignore files
COPY . .

EXPOSE 8000
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:

firehose:
container_name: firehose
image: richardr1126/firehose
image: richardr1126/cosmere-firehose
build:
context: ./firehose
env_file:
Expand Down
5 changes: 1 addition & 4 deletions firehose/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ FROM python:3.12.8-slim-bookworm
VOLUME /var/data/
WORKDIR /usr/src/app/

# Copy package files and install dependencies
COPY ../requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . .
RUN pip install --no-cache-dir -r requirements.txt

# Runs when the container is started
CMD python start_stream.py
6 changes: 3 additions & 3 deletions firehose/db_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def hydrate_posts_with_interactions(client: Client, batch_size: int = 25, schedu
try:
with db.connection_context():
logger.info("Hydration Database connection opened.")
# get posts with uri and interactions
posts = Post.select(Post.uri, Post.interactions)
# get posts with uri and interactions from the last 7 days
posts = Post.select(Post.uri, Post.interactions).where(Post.indexed_at > (datetime.now() - timedelta(days=7)))
uris = [post.uri for post in posts]

if not uris:
Expand Down Expand Up @@ -134,7 +134,7 @@ def hydrate_posts_with_interactions(client: Client, batch_size: int = 25, schedu
posts_to_update.append(current_post)

# pause the loop for 3 seconds
time.sleep(3)
#time.sleep(3)

except exceptions.AtProtocolError as api_err:
if api_err.response:
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ peewee
Flask
python-dotenv
gunicorn
honcho
apscheduler
psycopg2-binary

0 comments on commit 807c47f

Please sign in to comment.