Skip to content

Commit 45b41af

Browse files
committed
add basic github api worker
1 parent cc2c186 commit 45b41af

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

pyhackers/service/post.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pyhackers.utils import markdown_to_html
77

88

9-
def load_posts(post_ids,current_user_id=None):
9+
def load_posts(post_ids, current_user_id=None):
1010
"""
1111
Select multiple posts from the service.
1212
We will definitely need to [mem]Cache these records to do a fast lookup batch query.

pyhackers/worker/github_worker.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import logging
2+
from pyhackers.model.user import User, SocialUser
3+
from pyhackers.model.cassandra.hierachy import (
4+
User as CsUser, Post as CsPost, UserPost as CsUserPost, UserFollower as CsUserFollower,
5+
UserTimeLine)
6+
7+
8+
class RegistrationGithubWorker():
9+
"""
10+
Once a user registers via GitHub, we will fetch the stars/watching projects
11+
following users/followers
12+
"""
13+
14+
def __init__(self, user_id, social_account_id):
15+
self.user_id = user_id
16+
self.social_account_id = social_account_id
17+
self.access_token = None
18+
19+
def get_user_details_from_db(self):
20+
user = User.query.get(self.user_id)
21+
social_account = SocialUser.query.get(self.social_account_id)
22+
self.access_token = social_account.access_token
23+
24+
def run(self):
25+
self.get_user_details_from_db()
26+
pass
27+
28+
29+
def new_github_registration(user_id, social_account_id):
30+
logging.warn("[TASK][new_github_registration]: [UserId:{}] [SAcc:{}]".format(user_id, social_account_id))
31+
32+
RegistrationGithubWorker(user_id,social_account_id).run()

0 commit comments

Comments
 (0)