Skip to content

Commit

Permalink
add quick annotation
Browse files Browse the repository at this point in the history
add quick annotation:
+ WHERE annotator IS NULL AND (is_deleted = 1 OR is_banned = 1 )
  • Loading branch information
donnerbaer committed Mar 12, 2024
1 parent 232da5c commit 8fc2129
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions views/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<th>Annotator</th>
<th>Database: has already annotated</th>
<th>Database: still has to go</th>
<th>Quick annotation for
<button type="button" class="btn btn-info " data-bs-toggle="tooltip" data-bs-placement="right"
data-bs-title="Set all accounts as annotated, this applies to: [Annotator is NULL and (is_deleted=1 or is_banned=1)] This process can take a while">?</button>
</th>
</tr>
</thead>
<tbody>
Expand All @@ -19,6 +23,7 @@
<td>{{annotator[0]}}</td>
<td><a class="btn btn-primary" href="database/has_annotation/{{annotator[0]}}">Show Database <span class="badge text-bg-secondary">{{annotator[1]}}</span></a></td>
<td><a class="btn btn-primary" href="database/not_annotated/{{annotator[0]}}">Show Database <span class="badge text-bg-secondary">{{data.get('number_not_annotated')-annotator[1]}}</span></a></td>
<td><a class="btn btn-warning" href="/quick_annotation/{{annotator[0]}}">Quick annotation for {{annotator[0]}} <span class="badge text-bg-secondary">{{data.get('quick_annotation')}}</span></a></td>
</tr>
%end
</tbody>
Expand Down
22 changes: 19 additions & 3 deletions webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def index():
FROM reddit_bots
WHERE annotator IS NOT NULL GROUP BY annotator
""").fetchall()
number_not_annotated = cursor.execute("""SELECT COUNT(DISTINCT user_id) FROM reddit_bots """).fetchone()
data['number_not_annotated'] = number_not_annotated[0]
data['number_not_annotated'] = cursor.execute("""SELECT COUNT(DISTINCT user_id) FROM reddit_bots """).fetchone()[0]
data['quick_annotation'] = cursor.execute("""SELECT COUNT(DISTINCT user_id) FROM reddit_bots WHERE annotator IS NULL AND (is_deleted = 1 OR is_banned = 1) GROUP BY annotator""").fetchone()[0]
return template('index',data=data)


Expand Down Expand Up @@ -153,7 +153,7 @@ def database(annotator:str = None):
if annotator is None:
data = cursor.execute("""SELECT * FROM reddit_bots WHERE annotator IS NULL""").fetchall()
else:
data = cursor.execute("""SELECT * FROM reddit_bots WHERE user_id NOT IN (SELECT DISTINCT user_id
data = cursor.execute("""SELECT * FROM reddit_bots WHERE annotator IS NULL AND user_id NOT IN (SELECT DISTINCT user_id
FROM reddit_bots
WHERE annotator = ?
) """, (annotator,)).fetchall()
Expand Down Expand Up @@ -228,6 +228,22 @@ def fetch(user_id:str, annotator:str = None):
redirect('/annotation/{}/{}'.format(user_id, annotator))


@route('/quick_annotation/<annotator>')
def quick_annotation(annotator):
query_select = """SELECT DISTINCT user_id, was_fetched, is_deleted, is_banned
FROM reddit_bots
WHERE annotator IS NULL AND (is_deleted = 1 OR is_banned = 1 )"""

users = cursor.execute(query_select).fetchall()

query_insert = """INSERT OR REPLACE INTO reddit_bots (annotator, user_id, was_fetched, is_deleted, is_banned) VALUES (?, ?, ?, ?, ?)"""
for user in users:
cursor.execute(query_insert,(annotator, user[0], user[1], user[2], user[3]))
connection.commit()
redirect('../../')




@route('/search')
def search():
Expand Down

0 comments on commit 8fc2129

Please sign in to comment.