Skip to content

Commit

Permalink
Change ranking to gross revenue then shortest name so we can find old…
Browse files Browse the repository at this point in the history
… films with short names like jaws
  • Loading branch information
adamjmcgrath committed Nov 1, 2015
1 parent 15dab74 commit 0fa9de2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
14 changes: 7 additions & 7 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]'
Expand All @@ -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()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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


Expand Down
1 change: 0 additions & 1 deletion src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,3 @@ def get(self):
response = '%s(%s)' % (callback, response)

return webapp2.Response(response)

4 changes: 2 additions & 2 deletions src/cron.yaml
Original file line number Diff line number Diff line change
@@ -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
schedule: every 60 minutes
1 change: 0 additions & 1 deletion src/lib/dateutil

This file was deleted.

2 changes: 2 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import tasks
import views

from google.appengine.ext import vendor
vendor.add('lib')

app = webapp2.WSGIApplication([
('/', views.HomePage),
Expand Down
2 changes: 1 addition & 1 deletion src/secrets.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = '[email protected] (Adam McGrath)'

API_KEY = 'YOUR-API-KEY'
API_KEY = 'YOUR-API-KEY'
6 changes: 4 additions & 2 deletions src/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 0fa9de2

Please sign in to comment.