Skip to content

Commit e614f24

Browse files
refactored
1 parent 9792399 commit e614f24

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

src/tasks/schedulers.py

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,51 +33,50 @@ def compose_default_tweets(api_name, tweet_lines, media_ids=None):
3333
return tweet
3434

3535

36-
# DEFAULT_TWEETS = [
37-
# compose_default_tweets("EOD Stock Market API", [
38-
# "- Exchange & Ticker Data",
39-
# "- (EOD) Stock Data",
40-
# "- Fundamental Data",
41-
# "- Financial News API",
42-
# "- Social Media Trend Data For Stocks",
43-
# "Create A free API Key today",
44-
# "https://eod-stock-api.site/plan-descriptions/basic"
45-
# ], media_ids=["1647575420009603073"]),
46-
# compose_default_tweets("Financial & Business News API", [
47-
# "- Articles By UUID",
48-
# "- Articles By Publishing Date",
49-
# "- Articles By Stock Tickers",
50-
# "- Articles By Exchange",
51-
# "- Get List of Exchanges & Tickers",
52-
# "- Get List of Publishers & Articles By Publisher",
53-
# "Create A free API Key today",
54-
# "https://bit.ly/financial-business-news-api"
55-
# ], media_ids=["1647575420009603073"]),
56-
# compose_default_tweets("Financial & Business Professional Plan", [
57-
# "- Exchange & Ticker Data",
58-
# "- (EOD) Stock Data",
59-
# "- Fundamental Data",
60-
# "- Financial News API",
61-
# "- Social Media Trend Data For Stocks",
62-
# "Subscribe to our Professional Plan Today",
63-
# "https://eod-stock-api.site/plan-descriptions/professional"
64-
# ], media_ids=["1647575420009603073"]),
65-
# compose_default_tweets("Financial & Business Business Plan", [
66-
# "- Exchange & Ticker Data",
67-
# "- (EOD) Stock Data",
68-
# "- Fundamental Data",
69-
# "- Financial News API",
70-
# "- Social Media Trend Data For Stocks",
71-
# "Subscribe to our Business Plan Today",
72-
# "https://eod-stock-api.site/plan-descriptions/business"
73-
# ], media_ids=["1647575420009603073"])
74-
# ]
75-
76-
DEFAULT_TWEETS = []
36+
DEFAULT_TWEETS = [
37+
compose_default_tweets("EOD Stock Market API", [
38+
"- Exchange & Ticker Data",
39+
"- (EOD) Stock Data",
40+
"- Fundamental Data",
41+
"- Financial News API",
42+
"- Social Media Trend Data For Stocks",
43+
"Create A free API Key today",
44+
"https://eod-stock-api.site/plan-descriptions/basic"
45+
], media_ids=["1647575420009603073"]),
46+
compose_default_tweets("Financial & Business News API", [
47+
"- Articles By UUID",
48+
"- Articles By Publishing Date",
49+
"- Articles By Stock Tickers",
50+
"- Articles By Exchange",
51+
"- Get List of Exchanges & Tickers",
52+
"- Get List of Publishers & Articles By Publisher",
53+
"Create A free API Key today",
54+
"https://bit.ly/financial-business-news-api"
55+
], media_ids=["1647575420009603073"]),
56+
compose_default_tweets("Financial & Business Professional Plan", [
57+
"- Exchange & Ticker Data",
58+
"- (EOD) Stock Data",
59+
"- Fundamental Data",
60+
"- Financial News API",
61+
"- Social Media Trend Data For Stocks",
62+
"Subscribe to our Professional Plan Today",
63+
"https://eod-stock-api.site/plan-descriptions/professional"
64+
], media_ids=["1647575420009603073"]),
65+
compose_default_tweets("Financial & Business Business Plan", [
66+
"- Exchange & Ticker Data",
67+
"- (EOD) Stock Data",
68+
"- Fundamental Data",
69+
"- Financial News API",
70+
"- Social Media Trend Data For Stocks",
71+
"Subscribe to our Business Plan Today",
72+
"https://eod-stock-api.site/plan-descriptions/business"
73+
], media_ids=["1647575420009603073"])
74+
]
75+
7776

7877
class TaskScheduler:
7978
def __init__(self):
80-
79+
self._run_counter = 0
8180
self._tweepy_api = tweepy.API(auth=auth)
8281
self._article_queue = Queue()
8382
self._tweet_queue = Queue()
@@ -159,8 +158,9 @@ async def create_tweets(self):
159158
then send the tweet based on the article using send_tweet
160159
:return:
161160
"""
162-
for tweet in DEFAULT_TWEETS:
163-
await self._tweet_queue.put(tweet)
161+
if self._run_counter % 5 == 0:
162+
for tweet in DEFAULT_TWEETS:
163+
await self._tweet_queue.put(tweet)
164164

165165
while self._article_queue.qsize() > 0:
166166
self._logger.info(f"Articles Found : {self._article_queue.qsize()}")
@@ -174,6 +174,7 @@ async def create_tweets(self):
174174
except ValidationError as e:
175175
self._logger.error(f"Error Creating Tweet: {str(e)}")
176176
pass
177+
self._run_counter += 1
177178

178179
async def run(self):
179180
self._logger.info("Started Run")

0 commit comments

Comments
 (0)