fixing query
parent
90cec75cde
commit
bd93498aa0
18
README.md
18
README.md
|
@ -17,13 +17,13 @@ All queries can also be found [here](https://github.com/Miracle-Fruit/kikeriki/t
|
||||||
![result_ex1](../query_results/ex1.png)
|
![result_ex1](../query_results/ex1.png)
|
||||||
|
|
||||||
2. Find the 100 accounts with the most followers
|
2. Find the 100 accounts with the most followers
|
||||||
``` python
|
|
||||||
# 2. Find the 100 accounts with the most followers
|
CREATE MATERIALIZED VIEW twitter.most_follows AS
|
||||||
rows = session.execute('SELECT user_id,follower_len FROM twitter.most_follows;')
|
SELECT user_id, follower_len from twitter.user_stats
|
||||||
sorted_rows = dict(sorted(dict(rows).items(), key=lambda item: item[1]))
|
WHERE user_id is not null and follower_len is not null
|
||||||
most_follows = list(sorted_rows.keys())[-100:]
|
PRIMARY KEY (follower_len,user_id);
|
||||||
print("Top 100 most followed accounts:",most_follows)
|
|
||||||
```
|
SELECT user_id FROM twitter.most_follows LIMIT 100;
|
||||||
|
|
||||||
Top 100 most followed accounts: [817268, 173732041, 14506809, 158804228, 358775055, 45416789, 302282272, 65913144, 261001122, 14246001, 7702232, 101204352, 280365428, 15439395, 26929220, 46537966, 32774989, 2367911, 7429892, 88097807, 274153775, 41147062, 127973392, 10350, 12127832, 18666844, 279787626, 14511951, 116036694, 225784456, 270449528, 63796828, 22784458, 364917755, 15693493, 17346342, 28933226, 7872262, 14180231, 100581193, 88323281, 131029775, 25952851, 14692604, 21681252, 309366491, 25376226, 22705686, 188108667, 18715024, 3829151, 41172837, 92319025, 24081780, 15102849, 83943787, 15680204, 7846, 184097849, 7377812, 204317520, 24641194, 14691709, 112939321, 7081402, 153226312, 14269220, 94414805, 108811740, 1065921, 221829166, 116952434, 15222083, 6608332, 17759701, 16098603, 7860742, 20471349, 6519522, 19040580, 14536491, 197504076, 12611642, 36198161, 3840, 22841103, 440963134, 20273398, 17092592, 13348, 17093617, 22679419, 208132323, 18776017, 15846407, 18581803, 5442012, 813286, 3359851, 59804598]
|
Top 100 most followed accounts: [817268, 173732041, 14506809, 158804228, 358775055, 45416789, 302282272, 65913144, 261001122, 14246001, 7702232, 101204352, 280365428, 15439395, 26929220, 46537966, 32774989, 2367911, 7429892, 88097807, 274153775, 41147062, 127973392, 10350, 12127832, 18666844, 279787626, 14511951, 116036694, 225784456, 270449528, 63796828, 22784458, 364917755, 15693493, 17346342, 28933226, 7872262, 14180231, 100581193, 88323281, 131029775, 25952851, 14692604, 21681252, 309366491, 25376226, 22705686, 188108667, 18715024, 3829151, 41172837, 92319025, 24081780, 15102849, 83943787, 15680204, 7846, 184097849, 7377812, 204317520, 24641194, 14691709, 112939321, 7081402, 153226312, 14269220, 94414805, 108811740, 1065921, 221829166, 116952434, 15222083, 6608332, 17759701, 16098603, 7860742, 20471349, 6519522, 19040580, 14536491, 197504076, 12611642, 36198161, 3840, 22841103, 440963134, 20273398, 17092592, 13348, 17093617, 22679419, 208132323, 18776017, 15846407, 18581803, 5442012, 813286, 3359851, 59804598]
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ print("100 accounts that follow the most of the accounts found in 2)",followed_t
|
||||||
(172883064, 233248636, 'NoName','taylorswift12', 'Hallo there BDEA','DE', dateof(now()), 'NoID', 'de', 48, 48, 10000000, 0, 0);
|
(172883064, 233248636, 'NoName','taylorswift12', 'Hallo there BDEA','DE', dateof(now()), 'NoID', 'de', 48, 48, 10000000, 0, 0);
|
||||||
|
|
||||||
INSERT INTO twitter.tweets(author, content, country, date_time, id, language, latitude, longitude, number_of_likes, number_of_shares ,author_id)
|
INSERT INTO twitter.tweets(author, content, country, date_time, id, language, latitude, longitude, number_of_likes, number_of_shares ,author_id)
|
||||||
VALUES
|
VALUES
|
||||||
('taylorswift12', 'Hallo there BDEA','DE', dateof(now()), 'NoID', 'de', 48, 48, 10000000, 0, 0 '233248636');
|
('taylorswift12', 'Hallo there BDEA','DE', dateof(now()), 'NoID', 'de', 48, 48, 10000000, 0, 233248636);
|
||||||
|
|
||||||
![result_ex4_2](../query_results/ex4_2_likes.png)
|
![result_ex4_2](../query_results/ex4_2_likes.png)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue