From 80fb33361a5d06cf81f74aa5bfe7c18729e7b24e Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Wed, 10 Jun 2015 22:18:15 +0100 Subject: [PATCH 1/8] add .idea --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4dc7acc..adf6b8a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ src/pylib src/secrets.py npm-debug.log node_modules +.idea \ No newline at end of file From 60eeded6b37170f5620dfce69c651f2068c71810 Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Wed, 10 Jun 2015 23:04:30 +0100 Subject: [PATCH 2/8] add editorconfig fix env path --- .editorconfig | 11 +++++++++++ .gitignore | 4 +++- .travis.yml | 2 +- fabfile.py | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..26d30f9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# EditorConfig + +# top-most EditorConfig file +root = true + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{js,py}] +charset = utf-8 +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore index adf6b8a..97eae2c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,6 @@ src/pylib src/secrets.py npm-debug.log node_modules -.idea \ No newline at end of file +.idea +.env + diff --git a/.travis.yml b/.travis.yml index 90bea9c..ef9f1fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ python: env: global: - secure: KTWs8jE9COxyuULlAiynxrI61wKfZhz56B99zT75e4tdcCSGRIIWut8Skm1thAUSQsEymXhvhhmgND3qbjChyw90F/hAiA8xgo/QxpESvI48AXi9CLPfB9kyaf9SPqXokKxj0yYqCCYLLfmCu/glO66S69+5iQbwn8M+9WHdeHwYffJrFJonUt/E0HAuaNdmJIDCd3nuAp7Ol7JAuUsg8971SoeDqk+wBPNzN4UWYtpWGvxUas51w7YjIPwG7cr6C3XvP/G1x2YPU6yP0gQBtgKt3X3+W6FJqO1GZaiQ1iTK+nRhaU1SecjmkHJJKQjQDX+0CLVWW5Y98SrbtKYht/Ez3/3GG4NyHTtmBZ67F4cC3ikdTRDp3ixTAoay7M4osIgvkdNsCeiYGz8dXvIbOsh+bebCPHwYfdsVk0656XS3V2G5EnXMhqaOzDqdwdCMCUR/LUm4GOmZ2BqNAQT/CnsWugE7BZwyN9I8S1bVMfU0a4soXNAlXbr6Kzr01cdX7Po43y7GOe4QgQHMJuNrFzbJ24IT/OOKJKkgRRfUQoX3LQHH++EHUnKpeTDrT72MRp095jiRW5gjUVjidTtYG0YruZ4PFv66ICKHEmVEm57ATxjupea/goESWslp1/Vj2XV3mKhVcGwJ52WHV2czh8EEu/G16XZMHqwFDjIOg6c= - - APPENGINE_SDK=google_appengine_1.9.19 + - APPENGINE_SDK=google_appengine_1.9.21 cache: directories: diff --git a/fabfile.py b/fabfile.py index c05fd90..f34e22e 100755 --- a/fabfile.py +++ b/fabfile.py @@ -14,7 +14,7 @@ import sys from fabric.api import * -APPENGINE_PATH = os.environ['APPENGINE_SRC'] +APPENGINE_PATH = os.path.abspath(os.environ['APPENGINE_SRC']) APPENGINE_DEV_APPSERVER = os.path.join(APPENGINE_PATH, 'dev_appserver.py') APPENGINE_APP_CFG = os.path.join(APPENGINE_PATH, 'appcfg.py') From 9b07a822c638e49307cabd2d1e999d313965351d Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Sat, 13 Jun 2015 18:46:39 +0100 Subject: [PATCH 3/8] Script to add active_questions_answered for calculating a fairer average score --- scripts/fix_average_score.py | 63 ++++++++++++++++++++++++++++++++++++ src/models.py | 1 + 2 files changed, 64 insertions(+) create mode 100755 scripts/fix_average_score.py diff --git a/scripts/fix_average_score.py b/scripts/fix_average_score.py new file mode 100755 index 0000000..7a0a410 --- /dev/null +++ b/scripts/fix_average_score.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# coding=utf-8 +# +# Copyright Friday Film Club. All Rights Reserved. + +"""Update average score so that archive questions aren't included.""" + +import os +import sys +import getpass + + +APPENGINE_PATH = os.path.abspath(os.environ['APPENGINE_SRC']) +APPENGINE_DEV_APPSERVER = os.path.join(APPENGINE_PATH, 'dev_appserver.py') +APPENGINE_APP_CFG = os.path.join(APPENGINE_PATH, 'appcfg.py') + +sys.path.append(APPENGINE_PATH) +import dev_appserver +dev_appserver.fix_sys_path() + +from google.appengine.ext import ndb +from google.appengine.ext.remote_api import remote_api_stub + +import models + +APP_NAME = 's~ffcapp' +os.environ['AUTH_DOMAIN'] = 'gmail.com' +os.environ['USER_EMAIL'] = 'adamjmcgrath@gmail.com' + + +def auth_func(): + return os.environ['USER_EMAIL'], getpass.getpass('Password:') + + +def fix_user(u): + uqs = [uq for uq in models.UserQuestion.query( + models.UserQuestion.user==u.key, + models.UserQuestion.complete==True, + ndb.OR(models.UserQuestion.score==0, models.UserQuestion.score==None))] + + correction = 0 + + for uq in uqs: + if (uq.created and + (uq.created - uq.question.get().posed).total_seconds() > 20000): + correction += 1 + + u.active_questions_answered = u.questions_answered - correction + print '%s: old: %d, new: %d' % (u.username, u.questions_answered, u.active_questions_answered) + if correction > 1: + u.put() + + +def main(): + # Use 'localhost:8080' for dev server. + remote_api_stub.ConfigureRemoteDatastore(APP_NAME, '/_ah/remote_api', + auth_func, servername='ffcapp.appspot.com') + + for u in models.User.query(): + fix_user(u) + +if __name__ == '__main__': + main() diff --git a/src/models.py b/src/models.py index a1a7320..6aef162 100755 --- a/src/models.py +++ b/src/models.py @@ -187,6 +187,7 @@ class User(AuthUser): overall_score = ndb.IntegerProperty(default=0) overall_clues = ndb.IntegerProperty(default=0) questions_answered = ndb.IntegerProperty(default=0) + active_questions_answered = ndb.IntegerProperty(default=0) invited_by = ndb.KeyProperty(kind='User') joined = ndb.DateTimeProperty(auto_now_add=True) leagues = ndb.KeyProperty(repeated=True) From dac5d03c36b796d3e86d3a843f1747e541299903 Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Sat, 13 Jun 2015 18:50:39 +0100 Subject: [PATCH 4/8] question is current for 7 days --- scripts/fix_average_score.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/fix_average_score.py b/scripts/fix_average_score.py index 7a0a410..06dff1d 100755 --- a/scripts/fix_average_score.py +++ b/scripts/fix_average_score.py @@ -8,7 +8,7 @@ import os import sys import getpass - +import datetime APPENGINE_PATH = os.path.abspath(os.environ['APPENGINE_SRC']) APPENGINE_DEV_APPSERVER = os.path.join(APPENGINE_PATH, 'dev_appserver.py') @@ -42,7 +42,7 @@ def fix_user(u): for uq in uqs: if (uq.created and - (uq.created - uq.question.get().posed).total_seconds() > 20000): + (uq.created - uq.question.get().posed) > datetime.timedelta(days=7)): correction += 1 u.active_questions_answered = u.questions_answered - correction @@ -56,7 +56,8 @@ def main(): remote_api_stub.ConfigureRemoteDatastore(APP_NAME, '/_ah/remote_api', auth_func, servername='ffcapp.appspot.com') - for u in models.User.query(): + for u in models.User.query(models.User.name=='Tom Johnson'): + # for u in models.User.query(): fix_user(u) if __name__ == '__main__': From 7565f96dba856de7ccfe8ebc0897a02facca606b Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Sat, 13 Jun 2015 18:50:58 +0100 Subject: [PATCH 5/8] for all users --- scripts/fix_average_score.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/fix_average_score.py b/scripts/fix_average_score.py index 06dff1d..31f58e6 100755 --- a/scripts/fix_average_score.py +++ b/scripts/fix_average_score.py @@ -56,8 +56,7 @@ def main(): remote_api_stub.ConfigureRemoteDatastore(APP_NAME, '/_ah/remote_api', auth_func, servername='ffcapp.appspot.com') - for u in models.User.query(models.User.name=='Tom Johnson'): - # for u in models.User.query(): + for u in models.User.query(): fix_user(u) if __name__ == '__main__': From 767e535a1013597c718eac080beb292cb1f5a107 Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Sat, 13 Jun 2015 19:03:06 +0100 Subject: [PATCH 6/8] Update active_questions_answered when user completes a current question --- src/api/question.py | 6 ++++-- src/tests/helpers.py | 1 + src/tests/test_api_question.py | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/api/question.py b/src/api/question.py index bea8451..5ff45e8 100644 --- a/src/api/question.py +++ b/src/api/question.py @@ -31,10 +31,12 @@ def update_question(question): deferred.defer(leaderboard.delete_leaderboard_cache) -def update_users_score(user, score, num_guesses): +def update_users_score(user, score, num_guesses, is_current): user.overall_score += score user.overall_clues += num_guesses - 1 user.questions_answered += 1 + if is_current: + user.active_questions_answered += 1 def update_users_season_score(user_season, score, num_guesses): @@ -118,7 +120,7 @@ def get_or_post(self, question_id): user_season = None # Update the users score and stats. - update_users_score(user, score, num_guesses) + update_users_score(user, score, num_guesses, question.is_current) # Update the question answer count and reset the leaderboard cache. update_question(question) diff --git a/src/tests/helpers.py b/src/tests/helpers.py index 4e5e3b1..91d2917 100644 --- a/src/tests/helpers.py +++ b/src/tests/helpers.py @@ -48,6 +48,7 @@ def user(id=None, overall_score=0, overall_clues=0, questions_answered=0, + active_questions_answered=0, invited_by=None, joined=None, leagues=None): diff --git a/src/tests/test_api_question.py b/src/tests/test_api_question.py index dfba367..120c8ed 100644 --- a/src/tests/test_api_question.py +++ b/src/tests/test_api_question.py @@ -221,11 +221,13 @@ def testUpdateUserScore(self): overall_score=10, overall_clues=10, questions_answered=10, + active_questions_answered=5, ) - question_api.update_users_score(user, 5, 5) + question_api.update_users_score(user, 5, 5, True) self.assertEqual(user.overall_score, 15) self.assertEqual(user.overall_clues, 14) self.assertEqual(user.questions_answered, 11) + self.assertEqual(user.active_questions_answered, 6) def testUpdateUsersLeagueScore(self): user = helpers.user() From 23294c3b665f9c2108c69b356601bd1064a52bac Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Sat, 13 Jun 2015 19:41:02 +0100 Subject: [PATCH 7/8] Don't use os environ host, get host from request --- .travis.yml | 2 +- src/api/contacts.py | 4 ++-- src/auth.py | 3 ++- src/secrets.example.py | 9 +++++---- src/secrets.py.enc | Bin 2528 -> 2576 bytes src/settings.py | 12 +++++++----- src/twitter.py | 3 ++- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef9f1fe..d7d8c92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ cache: - bower_components before_install: - - openssl aes-256-cbc -K $encrypted_aac91bacce06_key -iv $encrypted_aac91bacce06_iv -in src/secrets.py.enc -out src/secrets.py -d + - openssl aes-256-cbc -K $encrypted_1d9196d3864d_key -iv $encrypted_1d9196d3864d_iv -in src/secrets.py.enc -out src/secrets.py -d install: - pip install -r requirements.txt diff --git a/src/api/contacts.py b/src/api/contacts.py index addffdb..5f31728 100644 --- a/src/api/contacts.py +++ b/src/api/contacts.py @@ -53,7 +53,7 @@ def get_google_contacts(self): if refresh_token: # Convert the access token to refresh_token - app_id, app_secret, app_scope = secrets.AUTH_CONFIG['google'] + app_id, app_secret, app_scope = secrets.get_auth_config('google', 'prod') data = urllib.urlencode({ 'client_id': app_id, 'client_secret': app_secret, @@ -99,7 +99,7 @@ def get_google_contacts(self): def get_facebook_friends(self): u = self.current_user - app_id, app_secret, app_scope = secrets.AUTH_CONFIG['facebook'] + app_id, app_secret, app_scope = secrets.get_auth_config('facebook', 'prod') # facebook_token = u.facebook_token facebook_token = app_id + '|' + app_secret facebook_uid = u.facebook_uid diff --git a/src/auth.py b/src/auth.py index 00bf7b3..8c30803 100644 --- a/src/auth.py +++ b/src/auth.py @@ -162,7 +162,8 @@ def _callback_uri_for(self, provider): def _get_consumer_info_for(self, provider): """Returns a tuple (key, secret) for auth init requests.""" - return secrets.AUTH_CONFIG[provider] + return secrets.get_auth_config( + provider, settings.get_environment(self.request.host)) def _to_user_model_attrs(self, data, provider, new_user): attrs_map = self.USER_ATTRS[provider] diff --git a/src/secrets.example.py b/src/secrets.example.py index 8f848cf..69125cc 100644 --- a/src/secrets.example.py +++ b/src/secrets.example.py @@ -61,7 +61,8 @@ 'twitter': (TWITTER_CONSUMER_KEY_STAGING, TWITTER_CONSUMER_SECRET_STAGING), } -AUTH_CONFIG = ({ - 'local': _CONFIG_DEV, - 'staging': _CONFIG_STAGING, -}).get(settings.ENVIRONMENT, _CONFIG) +def get_auth_config(provider, environment): + return ({ + 'local': _CONFIG_DEV, + 'staging': _CONFIG_STAGING, + }).get(environment, _CONFIG)[provider] \ No newline at end of file diff --git a/src/secrets.py.enc b/src/secrets.py.enc index 68eb5f0863d3b73fa01ffc1ec26f5c03e050ce89..55b741ec3602f76652b7b7b4cce8cb37590f174a 100644 GIT binary patch literal 2576 zcmV+r3h(v6F>*%oT=u)4(|?TEHC330Og8BD6mTBCuIBk3k4!gEMxbOuzvJL^a+1nO z4>}!-xFH)V1Dn!*l&o}f%Ip6mq8;TDZP_dy0f~7(E<~qMNhx;%vCP2Gm6oYjZ-`0v zeZGDe>HxJq3bc7 zvNl~v)`jQdKjLuuMn0$E3LZ7>Rv2H^;5U_@Ak-z7h>^%`9>%)zHJdNTt5Vfg+At%# zYb3-4jb}Oq*@p;jMrn_4GI9M>!1a^-^l9B)<_AJ&f=sc@2aYK~8UHL~59DO`wSMd8 zoo{0v+tM3F7^Dx-6)aav>3)m4OAA?HUzu@YjqgPGruPJo zus7xT%2R9yujW);h7LEGUkv?6{z^f96#hOjJO#8n;G91o4>Esf;*2xPa;x> zAocnRZwuVOLM?hP7cO&o=9wJ26pPz{(Zb{tlPBaF{q#3A>ka2-~*w-l45M}HunN+|OZ`OBY=7RUVhAg97d%2Ze_2w{D&su}Zk=+5e zd!lJXlM=0v?6$a87=;JEJ62lgPCA9{GZG@cLa1J>{T(szZ}I60awcF_fI-IRt!U|) zY4%vdV7g!lC=tqrR{~Qdv1K|EG~Uq114IS2YR8l>q;9`3dJ%4R-*C%PyHAifvu$va zgiTK6^zz};1Jr?66}o5vUv6GakQc(z^WDf;8Dmglkq%)p4dv`^Ds(MDTN z@)ou#9Ud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1cTEd z8YSj=&-?7#sS3GtJ>xPN4UR4|7&JLYqa`*bg)SEONOCQq5)WUV@&krOylj(rcE-(Q zO~=6$E*(mT5zd};7K+h2NJQ7oz1wagH~V0}qF zObQ!23@!lO}?X$@GlW26f4`(KFXRuoq{)T`fG^VWcW2qxf3!K=X?#Fk_aly?EpTfDfp@8N5o zMySDqQT_&}&Z#!Zqa>tJQB?8X5KV4kNLR8()&rS*imcB?WFJ>BcUh89j~L9U>e^8I z`||@XR0*CAxL)&KKosO(+^;_wzOzTSnvYBjnLiiVha^<8IApnq%T*NsJ1@^cMi<%Y zwT6lA5FK?nBS~S)wzHtY27wa4*#HPYA6r?n64EOaJ zqD^l^)T_~ov?|}T06G)M0$kV;;blg+k(r6NdMq@qG>QCmg$Wa1s808t&n0I_L`~Hy zt@Pnz0`+(}9|pUPn!aty%^UsLr1C;*>Bt)5KRy|ExWD;8+0f0lY&PnpwV+LySs1=p qJ+g#E7k)wqao7VmS diff --git a/src/settings.py b/src/settings.py index ef1df24..cd4f02c 100755 --- a/src/settings.py +++ b/src/settings.py @@ -11,8 +11,10 @@ DEBUG = os.environ.get('SERVER_SOFTWARE', '').startswith('Dev') FMJ_EMAIL_SHORT = 'fmj@fridayfilmclub.com' FMJ_EMAIL = 'Film Master Jack <%s>' % FMJ_EMAIL_SHORT -ENVIRONMENT = ({ - 'www.fridayfilmclub.com': 'prod', - 'ffcapp.appspot.com': 'prod', - 'dev.ffcapp.appspot.com': 'staging', -}).get(os.environ.get('HTTP_HOST'), 'local') + +def get_environment(host): + return ({ + 'www.fridayfilmclub.com': 'prod', + 'ffcapp.appspot.com': 'prod', + 'dev.ffcapp.appspot.com': 'staging', + }).get(host, 'local') \ No newline at end of file diff --git a/src/twitter.py b/src/twitter.py index 0702e08..ce26ae1 100644 --- a/src/twitter.py +++ b/src/twitter.py @@ -17,7 +17,8 @@ from google.appengine.api import urlfetch -consumer_token, consumer_token_secret = secrets.AUTH_CONFIG['twitter'] +# TODO (adamjmcgrath) don't hardcode environment. +consumer_token, consumer_token_secret = secrets.get_auth_config('twitter', 'prod') def timestamp(): From 006495e7045db806ebe6abdcdae61944212bb9f9 Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Sat, 13 Jun 2015 19:42:40 +0100 Subject: [PATCH 8/8] Fix cron --- src/cron.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cron.yaml b/src/cron.yaml index e45e5f6..14158a4 100644 --- a/src/cron.yaml +++ b/src/cron.yaml @@ -14,8 +14,8 @@ cron: url: /tasks/cleanupanonymoususers schedule: every 24 hours -- description: delete obsolete anonymous users - url: /tasks/cleanupanonymoususers +- description: clean up obsolete user tokens + url: /tasks/cleanupusertokens schedule: every monday 05:00 - description: weekly backup