Skip to content

Commit 412ecc4

Browse files
committed
twitter_tags : fix
1 parent 035439e commit 412ecc4

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

source-twitter-fetcher/source_twitter_fetcher/source.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
2222
token_refresh_endpoint="https://api.x.com/2/oauth2/token"
2323
)
2424

25-
tweet = Tweet(
26-
authenticator=auth,
27-
account_id=config["account_id"],
28-
start_time=datetime.strptime(config['start_time'], DATE_FORMAT),
29-
)
25+
# Parse start_time if provided, otherwise streams will use their defaults
26+
start_time = None
27+
if "start_time" in config:
28+
start_time = datetime.strptime(config['start_time'], DATE_FORMAT)
29+
30+
tweet_kwargs = {
31+
"authenticator": auth,
32+
"account_id": config["account_id"]
33+
}
34+
if start_time:
35+
tweet_kwargs["start_time"] = start_time
36+
37+
tweet = Tweet(**tweet_kwargs)
3038

3139
tags_kwargs = {
3240
"authenticator": auth,
@@ -35,8 +43,8 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
3543
}
3644

3745
# Add start_time only if provided in config
38-
if "start_time" in config:
39-
tags_kwargs["start_time"] = datetime.strptime(config['start_time'], DATE_FORMAT)
46+
if start_time:
47+
tags_kwargs["start_time"] = start_time
4048

4149
# Add tags_frequent_extractions if provided in config
4250
if "tags_frequent_extractions" in config:
@@ -56,11 +64,14 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
5664
parent=tweet
5765
)
5866

59-
promoted_tweet_active = PromotedTweetActive(
60-
authenticator=auth,
61-
account_id=config['account_id'],
62-
start_time=datetime.strptime(config['start_time'], DATE_FORMAT),
63-
)
67+
promoted_tweet_active_kwargs = {
68+
"authenticator": auth,
69+
"account_id": config['account_id']
70+
}
71+
if start_time:
72+
promoted_tweet_active_kwargs["start_time"] = start_time
73+
74+
promoted_tweet_active = PromotedTweetActive(**promoted_tweet_active_kwargs)
6475

6576
promoted_tweet_billing = PromotedTweetBilling(
6677
authenticator=auth,
@@ -74,11 +85,14 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
7485
parent=promoted_tweet_active
7586
)
7687

77-
space = Space(
78-
authenticator=auth,
79-
account_id=config['account_id'],
80-
start_time=datetime.strptime(config['start_time'], DATE_FORMAT)
81-
)
88+
space_kwargs = {
89+
"authenticator": auth,
90+
"account_id": config['account_id']
91+
}
92+
if start_time:
93+
space_kwargs["start_time"] = start_time
94+
95+
space = Space(**space_kwargs)
8296

8397
return [
8498
Account(authenticator=auth, account_id=config["account_id"]),

source-twitter-fetcher/source_twitter_fetcher/spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ connectionSpecification:
5050
description: "List of Twitter handles to monitor (e.g., ['@IFT', '@Airbyte'])"
5151
items:
5252
type: string
53-
minItems: 1
53+
minItems: 1
5454
tags_frequent_extractions:
5555
type: boolean
5656
title: "Tags Frequent Extractions"

0 commit comments

Comments
 (0)