-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Yuuzi261/develope
Bug fixes and performance enhancements
- Loading branch information
Showing
6 changed files
with
55 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
import os | ||
import sqlite3 | ||
from src.notification.date_comparator import date_comparator | ||
|
||
def get_tweets(tweets, username): | ||
tweets = [tweet for tweet in tweets if tweet.author.username == username] | ||
if tweets != []: | ||
return sorted(tweets, key=lambda x: x.created_on, reverse=True)[0] | ||
else: | ||
return None | ||
|
||
conn = sqlite3.connect(f"{os.getenv('DATA_PATH')}tracked_accounts.db") | ||
cursor = conn.cursor() | ||
last_tweet_at = cursor.execute('SELECT lastest_tweet FROM user WHERE username = ?', (username,)).fetchone()[0] | ||
conn.close() | ||
|
||
tweets = [tweet for tweet in tweets if tweet.author.username == username and date_comparator(tweet.created_on, last_tweet_at) == 1] | ||
|
||
if tweets != []: return sorted(tweets, key=lambda x: x.created_on) | ||
else: return None |