Skip to content

Commit

Permalink
db clean functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
condaatje committed Dec 13, 2016
1 parent 6dd1032 commit 4888429
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
6 changes: 1 addition & 5 deletions api/ttio/templates/ttio/model.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
{% include 'ttio/header.html' %}

<div class="container-fluid">
<!--http://stackoverflow.com/questions/16616260/django-template-context-for-loop-traversal-->
{% for question, info in data.items %}
<br/>
<table class="table table-striped">
<!--http://stackoverflow.com/questions/22486402/html-bootstrap-table-title-caption-with-title-on-left-side-and-buttons-on-righ-->

<caption class="text-center" style="border: inherit; background-color: lightgrey;">
<strong>Question: </strong> "{{question}}"
<br/>
Expand All @@ -34,7 +33,6 @@
<tbody>
{% for response, props in info.responses.items %}
<tr>
<!--http://stackoverflow.com/questions/11481499/django-iterate-number-in-for-loop-of-a-template-->
<td>"{{response}}"</td> <!-- response -->

<td class="text-right">
Expand All @@ -56,5 +54,3 @@

</body>
{% endblock %}

<!--http://stackoverflow.com/questions/346467/format-numbers-in-django-templates-->
1 change: 1 addition & 0 deletions api/ttio/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
url(r'^reward', reward, name="reward"),
url(r'^model', model, name="model"),
url(r'^delete', delete, name="delete"),
url(r'^clean', clean, name="clean"),
url(r'^nlp', nlp, name="nlp"),
url(r'^$', index, name="index"),
]
16 changes: 14 additions & 2 deletions api/ttio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,20 @@ def delete(request):


def clean(request):
# TODO clean up the database. Responses with very poor p(success) are removed.
# This will hopefully keep us from exponential blowup
# Clean up the database. Responses with poor p(success) are removed.
# This will hopefully keep us from exponential blowup in cross-pollination.
# right now it's exposed, so keep that in mind.

for conversation in Conversation.objects.all():
responses = {}
for response, data in conversation.responses.iteritems():
p_fail = data["failures"] / data["frequency"]
if p_fail < settings.FAILURE_THRESHOLD:
responses[response] = data

conversation.responses = responses
conversation.save();


return HttpResponse(status=201)

Expand Down
7 changes: 3 additions & 4 deletions chat/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1 class="text-center">TuringTest.io</h1>
<div class="container" id="messages">
<!--This is where the magic happens-->
<!--<div class='row message-bubble'>-->
<!-- <span><strong>Your Name: </strong></span>-->
<!-- <span><strong>Inquisitor: </strong> text</span>-->
<!--</div>-->
</div>
<div class="panel-footer">
Expand All @@ -38,8 +38,7 @@ <h1 class="text-center">TuringTest.io</h1>
</div>

<script>
// for c9
/*global io*/ /*global $*/ /*global location*/
/*global io*/ /*global $*/ /*global location*/ // for c9
var socket = io();

// TODO For now assuming unique usernames,
Expand Down Expand Up @@ -106,7 +105,7 @@ <h1 class="text-center">TuringTest.io</h1>
$('body').bind("enterKey", function(e) {
location.reload();
});
$('body').keyup(function(event) {
$('body').keydown(function(event) {
if (event.keyCode == 13) {
$(this).trigger("enterKey");
}
Expand Down
4 changes: 4 additions & 0 deletions citations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ http://stackoverflow.com/questions/18614301/keep-overflow-div-scrolled-to-bottom
http://stackoverflow.com/questions/6524288/jquery-event-for-user-pressing-enter-in-a-textbox
http://stackoverflow.com/questions/9232810/change-placeholder-text-using-jquery
http://stackoverflow.com/questions/21507133/how-do-you-get-exactly-50-odds
http://stackoverflow.com/questions/16616260/django-template-context-for-loop-traversal
http://stackoverflow.com/questions/22486402/html-bootstrap-table-title-caption-with-title-on-left-side-and-buttons-on-righ
http://stackoverflow.com/questions/11481499/django-iterate-number-in-for-loop-of-a-template
http://stackoverflow.com/questions/346467/format-numbers-in-django-templates

0 comments on commit 4888429

Please sign in to comment.