Permalink
Browse files

goog analytics code, logarithmic random join weight, disabled dead pages

  • Loading branch information...
1 parent ebdaa7a commit 4d1cde5a2e18bc88c7eb674b5b4ea4ebf0d39ece @paulftw committed May 11, 2011
Showing with 27 additions and 8 deletions.
  1. +11 −4 apps/utsoac/models.py
  2. +4 −4 apps/utsoac/urls.py
  3. +12 −0 templates/layout.html
View
@@ -1,6 +1,8 @@
from google.appengine.ext import db
from datetime import datetime
+import math
+import os
from tipfy.ext.auth.model import User as TipfyUser
@@ -50,9 +52,8 @@ def txn():
def join(self, username, when=datetime.now(), **kwargs):
- w = when - self.created
- intW = w.days * 86400 + w.seconds
- joinRecord = Join(parent=self, key_name=username, weight=intW, **kwargs)
+ w = Join.weight(when - self.created)
+ joinRecord = Join(parent=self, key_name=username, weight=w, **kwargs)
joinRecord.put()
return joinRecord
@@ -75,4 +76,10 @@ class Join(db.Model):
car = db.StringProperty()
comments = db.StringProperty()
gear = db.StringProperty()
-
+
+ @classmethod
+ def weight(self, delta):
+ secs = delta.days * 86400 + delta.seconds
+ log = math.ceil(math.log(secs / 4.0 / 3600, 2))
+ return log * 1000 + (ord(os.urandom(1)[0]) / 3)
+
View
@@ -5,10 +5,10 @@
{'url':'', 'name':'home', 'handler':'MainPage'},
{'url':'activity', 'name':'New Activity', 'handler':'NewActivity'},
{'url':'activities', 'name':'activities', 'handler':'ActivityList'},
- {'url':'gallery', 'name':'photos', 'handler':'Gallery'},
- {'url':'join', 'name':'join club', 'handler':'JoinForm'},
- {'url':'contact', 'name':'contact\'em', 'handler':'Committee'},
- {'url':'about', 'name':'about this', 'handler':'StaticPage'},
+# {'url':'gallery', 'name':'photos', 'handler':'Gallery'},
+# {'url':'join', 'name':'join club', 'handler':'JoinForm'},
+# {'url':'contact', 'name':'contact\'em', 'handler':'Committee'},
+# {'url':'about', 'name':'about this', 'handler':'StaticPage'},
]
def get_rules(app):
View
@@ -4,6 +4,18 @@
<head>
<title>{{ title }}</title>
<link rel="stylesheet" type="text/css" href="/static/styles/screen.css">
+
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-23261377-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>
</head>
<body>
<div class="yui-d1">

0 comments on commit 4d1cde5

Please sign in to comment.