Skip to content

Commit 2b70cd6

Browse files
authored
Merge pull request #227 from codeforjapan/feat/update-note-rating-status
feat: add daily rating count recalculation to ETL pipeline
2 parents c696cb0 + 9772881 commit 2b70cd6

File tree

10 files changed

+868
-162
lines changed

10 files changed

+868
-162
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
cache: pip
7070
cache-dependency-path: etl/pyproject.toml
7171
- name: dependency install
72-
run: pip install -e "./etl[dev]"
72+
run: pip install -e "./common" -e "./etl[dev]"
7373
- name: copy env
7474
run: cp .env.example etl/.env
7575
- name: test

etl/seed/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": ["ja"],
44
"keywords": [],
55
"start_millis": 1761922800000,
6-
"end_millis": 1771858740000
6+
"end_millis": null
77
},
8-
"description": "Note filtering configuration. start_millis is required. end_millis is optional (null = no upper limit). Timestamps in milliseconds UTC. Current: 2025-11-01 00:00:00 JST ~ 2026-02-23 23:59:00 JST"
8+
"description": "Note filtering configuration. start_millis is required. end_millis is optional (null = no upper limit). Timestamps in milliseconds UTC. Current: 2025-11-01 00:00:00 JST ~"
99
}

etl/src/birdxplorer_etl/extract_ecs.py

Lines changed: 387 additions & 120 deletions
Large diffs are not rendered by default.

etl/src/birdxplorer_etl/lib/lambda_handler/note_status_update_lambda.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ def lambda_handler(event, context):
115115
except Exception as e:
116116
logger.error(f"[ERROR] Commit failed: {str(e)}")
117117
postgresql.rollback()
118-
batch_item_failures = [
119-
{"itemIdentifier": r.get("messageId", "unknown")} for r in event["Records"]
120-
]
118+
batch_item_failures = [{"itemIdentifier": r.get("messageId", "unknown")} for r in event["Records"]]
121119

122120
return {"batchItemFailures": batch_item_failures}
123121

etl/src/birdxplorer_etl/lib/lambda_handler/postlookup_lambda.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,7 @@ def _process_single_tweet(
243243
logger.error(f"[DLQ_CAUSE:UNEXPECTED_RESPONSE] tweet_id={tweet_id} response={json.dumps(post)}")
244244
raise Exception(f"Unexpected API response for tweet: {tweet_id}")
245245

246-
created_at = datetime.strptime(post["data"]["created_at"], "%Y-%m-%dT%H:%M:%S.%fZ").replace(
247-
tzinfo=timezone.utc
248-
)
246+
created_at = datetime.strptime(post["data"]["created_at"], "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
249247
created_at_millis = int(created_at.timestamp() * 1000)
250248
now_millis = int(datetime.now(timezone.utc).timestamp() * 1000)
251249

etl/src/birdxplorer_etl/lib/lambda_handler/topic_detect_lambda.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ def lambda_handler(event, context):
137137
f"[SQS_SUCCESS] Sent tweet lookup message for tweet {post_id}, messageId={message_id}"
138138
)
139139
else:
140-
raise Exception(
141-
f"Failed to send tweet lookup message for tweet {post_id} (note {note_id})"
142-
)
140+
raise Exception(f"Failed to send tweet lookup message for tweet {post_id} (note {note_id})")
143141

144142
except Exception as e:
145143
logger.error(f"[EXCEPTION] Error sending SQS message for tweet lookup: {e}")

etl/src/birdxplorer_etl/lib/sqlite/init.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ def init_postgresql(use_pool: bool = False):
120120
if not use_pool:
121121
engine_kwargs["poolclass"] = NullPool # Lambda向け: コネクションをプールせず毎回接続・切断
122122
else:
123-
engine_kwargs.update({
124-
"pool_size": 5,
125-
"max_overflow": 10,
126-
"pool_timeout": 30,
127-
"pool_recycle": 3600,
128-
})
123+
engine_kwargs.update(
124+
{
125+
"pool_size": 5,
126+
"max_overflow": 10,
127+
"pool_timeout": 30,
128+
"pool_recycle": 3600,
129+
}
130+
)
129131
engine = create_engine(
130132
f"postgresql://{db_user}:{db_pass}@{db_host}:{db_port}/{db_name}",
131133
**engine_kwargs,

0 commit comments

Comments
 (0)