-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from adamjmcgrath/feature/1-change-average-scor…
…e-calculation Feature/1 change average score calculation
- Loading branch information
Showing
16 changed files
with
109 additions
and
21 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,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 |
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 |
---|---|---|
|
@@ -13,3 +13,6 @@ src/pylib | |
src/secrets.py | ||
npm-debug.log | ||
node_modules | ||
.idea | ||
.env | ||
|
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,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 | ||
import datetime | ||
|
||
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'] = '[email protected]' | ||
|
||
|
||
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) > datetime.timedelta(days=7)): | ||
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() |
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
Binary file not shown.
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 |
---|---|---|
|
@@ -11,8 +11,10 @@ | |
DEBUG = os.environ.get('SERVER_SOFTWARE', '').startswith('Dev') | ||
FMJ_EMAIL_SHORT = '[email protected]' | ||
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') |
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