Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
189 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | ||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> | ||
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> | ||
<title>{% block title %}{% endblock %} Web View</title> | ||
</head> | ||
<body> | ||
<div id="content"> | ||
{% include "nav_bar.html" %} | ||
{% block content %} | ||
{% endblock %} | ||
</div> | ||
|
||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% block content %} | ||
|
||
<nav class="navbar navbar-inverse"> | ||
<div class="container-fluid"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="/">twitter geolocater</a> | ||
</div> | ||
<ul class="nav navbar-nav"> | ||
<li><a href="/search">Search in tables</a></li> | ||
<li><a href="#">Calculate scores</a></li> | ||
<li><a href="#">View on map</a></li> | ||
</ul> | ||
</div> | ||
</nav> | ||
|
||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
|
||
{% include "tables.html" %} | ||
|
||
{% include "search_table.html"%} | ||
|
||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% block content %} | ||
<h1>Table: {{data.table}}</h1> | ||
<table class="table table-condensed"> | ||
<thead> | ||
<tr> | ||
{% for columns in data.cols %} | ||
<th>{{columns}}</th> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
{% for entry in data.entries%} | ||
{% for datapoint in entry%} | ||
<td>{{datapoint}}</td> | ||
{% endfor %} | ||
</tr> | ||
{% endfor%} | ||
|
||
</tbody> | ||
</table> | ||
|
||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
|
||
<div>Tweet count: {{ tweet_count }}</div> | ||
<div>Retweet count: {{ retweet_count }}</div> | ||
<div>Commented retweets count: {{ commented_retweet_count }}</div> | ||
<div>Reply tweets count: {{ reply_tweet_count }}</div> | ||
<div>Mention tweets count: {{ total_mention_count }}</div> | ||
|
||
<br> | ||
|
||
<div>Retweet percentage: {{ (retweet_count/tweet_count)|round(3) }}%</div> | ||
<div>Commented retweet percentage: {{ (commented_retweet_count/tweet_count)|round(3) }}%</div> | ||
<div>Reply tweet percentage: {{ (reply_tweet_count/tweet_count)|round(3) }}%</div> | ||
<div>Mention tweet percentage: {{ (total_mention_count/tweet_count)|round(3) }}%</div> | ||
|
||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% block content %} | ||
<h1>Select the table you want to view</h1> | ||
<div class="row"> | ||
<div class="col-lg-6"> | ||
<div class="input-group"> | ||
<div class="input-group-btn"> | ||
<div class="dropdown"> | ||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Tables<span class="caret"></span></button> | ||
<ul class="dropdown-menu"> | ||
{% for table in tables %} | ||
<li><a href=/search/{{table}}>{{table}}</a></li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div><!-- /btn-group --> | ||
</div><!-- /input-group --> | ||
</div><!-- /.col-lg-6 --> | ||
</div> | ||
<script type="text/javascript"> | ||
$(".dropdown-menu li a").click(function(){ | ||
$(this).parents(".dropdown").find('.btn').html($(this).text() + ' <span class="caret"></span>'); | ||
$(this).parents(".dropdown").find('.btn').val($(this).data('value')); | ||
}); | ||
</script> | ||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% block content %} | ||
|
||
<h1>Hello World, we currently have {{nbrOfUsers}} users!</h1> | ||
|
||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from database import Database | ||
|
||
class Database(Database): | ||
|
||
def get_total_clean_retweet_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
SELECT count(*) | ||
FROM tweets | ||
WHERE text ILIKE 'RT @realDonaldTrump%' | ||
""" | ||
|
||
cur.execute(statement) | ||
retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return retweet_count[0] | ||
|
||
def get_total_commented_retweet_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
SELECT count(*) | ||
FROM tweets | ||
WHERE text ILIKE '@realDonaldTrump%https://t.co/%' | ||
""" | ||
cur.execute(statement) | ||
commented_retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return commented_retweet_count[0] | ||
|
||
def get_total_reply_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
SELECT | ||
(SELECT count(*) | ||
FROM tweets | ||
WHERE text ILIKE '@realDonaldTrump%' | ||
AND in_reply_to_user_id IN (SELECT user_id FROM trumps_tweets LIMIT 1)) | ||
- | ||
(SELECT count(*) | ||
FROM tweets | ||
WHERE text ILIKE '@realDonaldTrump%https://t.co/%') | ||
AS total_count | ||
""" | ||
cur.execute(statement) | ||
commented_retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return commented_retweet_count[0] | ||
|
||
def get_total_mention_count(self): | ||
cur = self.conn.cursor() | ||
|
||
statement = """ | ||
SELECT | ||
(SELECT count(*) | ||
FROM tweets | ||
WHERE text ILIKE '@realDonaldTrump%' | ||
AND in_reply_to_user_id NOT IN (SELECT user_id FROM trumps_tweets LIMIT 1)) | ||
- | ||
(SELECT count(*) | ||
FROM tweets | ||
WHERE text ILIKE '@realDonaldTrump%https://t.co/%') | ||
AS total_count | ||
""" | ||
cur.execute(statement) | ||
commented_retweet_count = cur.fetchone() | ||
|
||
cur.close() | ||
return commented_retweet_count[0] |
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