Implements member creation. Existing member detection working as well. Still has to find a clever way to flush data to db. Also creates a sublime project in repo.

This commit is contained in:
Julien Lengrand-Lambert
2013-01-04 14:28:27 +01:00
parent edd02a4c13
commit fe47180269
4 changed files with 215 additions and 1 deletions

Binary file not shown.

View File

@@ -57,6 +57,10 @@ class Counter():
t_auth = tweet.author
print "###"
print t_auth, t_hash
debug = self.session.query(Member).all()
print "''''''''''''''''''''''"
for d in debug:
print d.author, d.hashtag
m_query = self.session.query(Member).filter(Member.author == t_auth).filter(Member.hashtag == t_hash)
# Checking if we already have such a member
@@ -82,7 +86,24 @@ class Counter():
print "Cannot create Member, Tweet is not valid"
raise Exception
self.session.add(member)
cpt = 1
# trying to flush if needed
if cpt >= 1: # FIXME: Raise limit later on
self.session.commit() # force saving changes
print "Commiting"
cpt = 0
def member_count(self):
"""
Returns the number of Members in table
"""
query = self.session.query(Member).order_by(Member.id).all()
print "Members: %d" % (len(query))
engine_url = 'sqlite:///twiderboard.db'
c = Counter(engine_url)
c.count()
c.member_count()

View File

@@ -0,0 +1,8 @@
{
"folders":
[
{
"path": "/home/airballman/Documents/twiderboard/twitterboard"
}
]
}

View File

@@ -0,0 +1,185 @@
{
"auto_complete":
{
"selected_items":
[
[
"has",
"has_author"
],
[
"a",
"author"
],
[
"t_",
"t_hash"
],
[
"sum",
"sum_elements"
],
[
"pow",
"pow_to_go"
],
[
"process",
"process_running"
]
]
},
"buffers":
[
],
"build_system": "",
"command_palette":
{
"height": 348.0,
"selected_items":
[
[
"acka",
"Package Control: Install Package"
],
[
"pack",
"Package Control: Install Package"
]
],
"width": 449.0
},
"console":
{
"height": 139.0
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"file_history":
[
"/home/airballman/.gitconfig",
"/home/airballman/Documents/twiderboard/twitterboard/.git/COMMIT_EDITMSG",
"/home/airballman/Desktop/Taf/workspace/project_euler/README.markdown",
"/home/airballman/.config/sublime-text-2/Packages/User/Preferences.sublime-settings"
],
"find":
{
"height": 35.0
},
"find_in_files":
{
"height": 0.0,
"where_history":
[
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"on_e"
],
"highlight": true,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
],
"reverse": false,
"show_context": true,
"use_buffer2": true,
"whole_word": false,
"wrap": true
},
"groups":
[
{
"sheets":
[
]
},
{
"sheets":
[
]
}
],
"incremental_find":
{
"height": 0.0
},
"input":
{
"height": 0.0
},
"layout":
{
"cells":
[
[
0,
0,
1,
1
],
[
1,
0,
2,
1
]
],
"cols":
[
0.0,
0.5302734375,
1.0
],
"rows":
[
0.0,
1.0
]
},
"menu_visible": true,
"output.exec":
{
"height": 100.0
},
"replace":
{
"height": 0.0
},
"save_all_on_build": true,
"select_file":
{
"height": 0.0,
"selected_items":
[
],
"width": 0.0
},
"select_project":
{
"height": 0.0,
"selected_items":
[
],
"width": 0.0
},
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 150.0,
"status_bar_visible": true
}