Skip to content

Commit

Permalink
Updated search to take priority into account
Browse files Browse the repository at this point in the history
Modified priojob
  • Loading branch information
Vin committed Jan 29, 2015
1 parent 6065e16 commit f6ee3f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions manager/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def search(query, limit=5):
},
},
"from": 0, "size": limit,
"sort": [
{ "requests": { "order": "desc", "ignore_unmapped": True }},
{ "_score": { "order": "desc" }}
]
}

res = elasticsearch_instance.search(config.elasticsearch_index, body=query)
Expand Down
4 changes: 2 additions & 2 deletions priojob.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import manager

with manager.MySQLCursor() as cur:
cur.execute("UPDATE `tracks` SET `priority`=GREATEST(0, priority-1);")
cur.execute("UPDATE `tracks` SET `requestcount`=IF(UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(lastrequested) > 3600*24*13, greatest(requestcount - 3, 0), requestcount);")
#cur.execute("UPDATE `tracks` SET `priority`=GREATEST(0, priority-1);")
cur.execute("UPDATE `tracks` SET `requestcount`=IF(UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(lastrequested) > 3600*24*13, greatest(requestcount - 1, 0), requestcount);")

0 comments on commit f6ee3f0

Please sign in to comment.