diff --git a/fabfile.py b/fabfile.py index cd9e581..c02471e 100644 --- a/fabfile.py +++ b/fabfile.py @@ -17,9 +17,9 @@ import datetime import re -APPENGINE_DEV_APPSERVER = '/usr/local/bin/dev_appserver.py' -APPENGINE_PATH = '/usr/local/google_appengine/' -APPENGINE_APP_CFG = '/usr/local/bin/appcfg.py' +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') PYTHON = '/usr/bin/python' env.gae_email = 'adamjmcgrath@gmail.com' @@ -35,7 +35,7 @@ def fix_appengine_path(): os.path.join(APPENGINE_PATH, 'lib', 'webob'), os.path.join(APPENGINE_PATH, 'lib', 'yaml', 'lib'), ] - + sys.path = EXTRA_PATHS + sys.path fix_appengine_path() @@ -66,7 +66,7 @@ def last_tag(): def deploy(tag=None, prod=False): if not is_working_directory_clean(): abort('Working directory should be clean before deploying.') - + prepare_deploy(tag=tag, prod=prod) local('%s %s -A %s -V %s --email=%s update %s' % (PYTHON, APPENGINE_APP_CFG, env.app.application, env.app.version, env.gae_email, env.gae_src)) @@ -113,7 +113,7 @@ def prepare_deploy(tag=None, prod=False): if not prod: env.app.version += '-test' - + # Check out a clean copy. deploy_path = local('mktemp -d -t %s' % env.app.application, capture=True) local('git clone . %s' % deploy_path) @@ -123,7 +123,7 @@ def prepare_deploy(tag=None, prod=False): local('find . -name ".git*" | xargs rm -rf') print yellow('App: %s' % env.app.application) print yellow('Ver: %s' % env.app.version) - + env.deploy_path = deploy_path diff --git a/src/api.py b/src/api.py index 74229e2..e46c9ce 100644 --- a/src/api.py +++ b/src/api.py @@ -114,4 +114,3 @@ def get(self): response = '%s(%s)' % (callback, response) return webapp2.Response(response) - diff --git a/src/cron.yaml b/src/cron.yaml index 290a55e..7a3114d 100644 --- a/src/cron.yaml +++ b/src/cron.yaml @@ -1,4 +1,4 @@ cron: -- description: daily get a year of films +- description: hourly get a year of films url: /tasks/getyear - schedule: every 60 minutes \ No newline at end of file + schedule: every 60 minutes diff --git a/src/lib/dateutil b/src/lib/dateutil deleted file mode 120000 index e8d3caf..0000000 --- a/src/lib/dateutil +++ /dev/null @@ -1 +0,0 @@ -../../submodules/python-dateutil/dateutil \ No newline at end of file diff --git a/src/main.py b/src/main.py index a44042b..19c4c35 100644 --- a/src/main.py +++ b/src/main.py @@ -9,6 +9,8 @@ import tasks import views +from google.appengine.ext import vendor +vendor.add('lib') app = webapp2.WSGIApplication([ ('/', views.HomePage), diff --git a/src/secrets.py.example b/src/secrets.py.example index 66a3f03..ae3d9e1 100644 --- a/src/secrets.py.example +++ b/src/secrets.py.example @@ -4,4 +4,4 @@ __author__ = 'adamjmcgrath@gmail.com (Adam McGrath)' -API_KEY = 'YOUR-API-KEY' \ No newline at end of file +API_KEY = 'YOUR-API-KEY' diff --git a/src/tasks.py b/src/tasks.py index f4030c0..3fb65f4 100644 --- a/src/tasks.py +++ b/src/tasks.py @@ -93,12 +93,14 @@ def create_film_document(film): imdb_id = film['imdb_id'] and film['imdb_id']['value'] gross_revenue = int(film['gross_revenue'] and film['gross_revenue']['amount'] or 0) release_date = parse(film['initial_release_date'], default=DEFAULT_DATE) + film_name = film['name'] return search.Document(doc_id=film['id'], - rank=max(gross_revenue, release_date.year), # Rank films by gross revenue, then by date. + # Rank films by gross revenue, then by length of name desc. + rank=max(gross_revenue, 1000 - len(film_name)), language='en', fields=[ - search.TextField(name='name', value=film['name']), + search.TextField(name='name', value=film_name), search.TextField(name='tokens', value=tokens), search.TextField(name='imdb_id', value=imdb_id), search.NumberField(name='gross_revenue', value=gross_revenue),