Skip to content

Commit

Permalink
temporarly ommit social_share counteres due to pickletype error
Browse files Browse the repository at this point in the history
  • Loading branch information
noamoss committed Jun 21, 2016
1 parent d8cae5a commit 7f0d3a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ class SharedItem(db.Model):
shares_count = db.Column(Integer)
feed_title= db.Column(String)
project= db.Column(String,nullable=False)
service_share_counter = db.Column(PickleType)
#service_share_counter = db.Column(PickleType)

def __init__(self, full_url, bitly, shares_count,feed_title,project,service_share_counter=None):
def __init__(self, full_url, bitly, shares_count,feed_title,project):
self.full_url=full_url
self.bitly = bitly
self.shares_count = 1
self.feed_title = feed_title
self.project = project
self.service_share_counter=dict.fromkeys(sharing_services,0)
#sharing_services_list = list(sharing_services.keys())
#self.service_share_counter=dict.fromkeys(sharing_services_list,0)

def add_share(self,service):
self.shares_count+=1
self.service_share_counter[service]+=1
#def add_share(self,service):
# self.shares_count+=1
# self.service_share_counter[service]+=1
4 changes: 2 additions & 2 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ def share_item(service=None, title=None, project=None, link=None):
project = request.args.get('project',project)
locate_link = SharedItem.query.filter_by(full_url=link).first()
if locate_link is not None: #if it is not the first time item/link is shared
locate_link.add_share(service)
bitly_link=locate_link.bitly
feed_title=locate_link.feed_title
project=locate_link.project

#locate_link.add_share(service)
else: # if item/link wasn't shared before -
bitlyconnection = bitlyapi.Connection(BITLY_USER, BITLY_KEY)
bitly_link = bitlyconnection.shorten(link)['url']
Expand All @@ -286,7 +286,7 @@ def share_item(service=None, title=None, project=None, link=None):
project=project,
shares_count=1,
)
new_item.service_share_counter[service] = 1
#new_item.service_share_counter[service] = 1
db.session.add(new_item)
db.session.commit() # save changes to db

Expand Down

0 comments on commit 7f0d3a8

Please sign in to comment.