This repository has been archived by the owner on Dec 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map with location of teachers Added a lot of map specific stuff. Bigg…
…est issue is handling lots of markers which can potentailly overlap. There are two external google maps libraries in use to solve this. I hope I have documented everthing properly. I wil Summary: Necessary changes to reduce scripts, hive queries and frontend to include map of teachers Test Plan: teacher_country should get populated weekly and teacher-students should display map at the bottom of the page. There are numerous additions here, hence possible bugs are varied Reviewers: chris, jace Reviewed By: jace Differential Revision: http://phabricator.khanacademy.org/D2474
- Loading branch information
1 parent
470265f
commit 6d1dfa9
Showing
17 changed files
with
2,369 additions
and
556 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 |
---|---|---|
|
@@ -43,3 +43,6 @@ auth_whitelist.py | |
# Common developer tools | ||
.project | ||
.pydevproject | ||
|
||
# GeoIP Database | ||
GeoLiteCity.dat |
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,3 @@ | ||
[submodule "third_party/pygeoip"] | ||
path = third_party/pygeoip | ||
url = git@github.com:Khan/pygeoip.git |
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
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
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,64 @@ | ||
-- Common part of teachers and students metrics | ||
-- Finds first day for each coach, user when he became a teacher, student | ||
|
||
DROP TABLE IF EXISTS user_coach_date; | ||
CREATE EXTERNAL TABLE IF NOT EXISTS user_coach_date( | ||
user STRING, | ||
coach STRING, | ||
joined_on STRING, | ||
self_coach BOOLEAN | ||
) LOCATION 's3://ka-mapreduce/tmp/user_coach_date'; | ||
|
||
DROP TABLE IF EXISTS teacher_on_date; | ||
CREATE EXTERNAL TABLE IF NOT EXISTS teacher_on_date( | ||
teacher STRING, | ||
dt STRING | ||
) LOCATION 's3://ka-mapreduce/tmp/teacher_on_date'; | ||
|
||
DROP TABLE IF EXISTS student_on_date; | ||
CREATE EXTERNAL TABLE IF NOT EXISTS student_on_date( | ||
student STRING, | ||
teacher STRING, | ||
dt STRING | ||
) LOCATION 's3://ka-mapreduce/tmp/student_on_date'; | ||
|
||
ADD FILE s3://ka-mapreduce/code/py/coach_reduce.py; | ||
ADD FILE s3://ka-mapreduce/code/py/ka_udf.py; | ||
|
||
-- Extract relevant information from UserData table | ||
INSERT OVERWRITE TABLE user_coach_date | ||
SELECT a.user, a.coach, | ||
from_unixtime(cast(cast(a.joined AS FLOAT) AS INT), 'yyyy-MM-dd') | ||
AS joined_on, | ||
(a.coach = a.user or a.coach = a.user_email or | ||
a.coach = a.user_id) as self_coach | ||
FROM ( | ||
SELECT TRANSFORM(UserData.json) | ||
USING 'ka_udf.py explode user,user_id,user_email,joined coaches' | ||
AS user, user_id, user_email, joined, coach | ||
FROM UserData | ||
) a; | ||
|
||
-- Custom map reduce routine - compute first day when | ||
-- given coach became a teacher | ||
-- refer to map_reduce/py/coach_reduce.py for reduce function | ||
FROM ( | ||
SELECT user, coach, joined_on | ||
FROM user_coach_date | ||
WHERE NOT self_coach | ||
DISTRIBUTE BY coach | ||
SORT BY coach DESC, joined_on ASC | ||
) st_date | ||
INSERT OVERWRITE TABLE teacher_on_date | ||
REDUCE st_date.user, st_date.coach, st_date.joined_on | ||
USING 'coach_reduce.py teacher' AS teacher, dt; | ||
|
||
-- Find first date when each user, coach pair became student, teacher pair | ||
INSERT OVERWRITE TABLE student_on_date | ||
SELECT u_dt.user, t_dt.teacher, IF(MIN(t_dt.dt) > MIN(u_dt.joined_on), | ||
MIN(t_dt.dt), MIN(u_dt.joined_on)) AS dt | ||
FROM user_coach_date u_dt | ||
JOIN teacher_on_date t_dt | ||
ON u_dt.coach = t_dt.teacher | ||
WHERE NOT u_dt.self_coach | ||
GROUP BY u_dt.user, t_dt.teacher; |
Oops, something went wrong.