Skip to content

Commit 9f27266

Browse files
author
Lakshmi Bodapati
committed
2 parents b0af48e + 4c686cc commit 9f27266

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

webapp/askalma/templates/askalma/listing.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{% extends 'askalma/headerfooter.html' %}{% block title %}Question Listing - AskAlma{% endblock %}{% load staticfiles %}{% block body %} <!-- =-=-=-=-=-=-= Latest Questions =-=-=-=-=-=-= --> <section class="section-padding-80 white" id="questions"> <div class="container"> <!-- Row --> <div class="row"> <div class="col-md-12 col-sm-12"> <div class="listing"> <!-- Question Area Panel --> <div class="listing-area"> <!-- Question Listing --> <!--one question= one listing grid--> {% for question in questions %} <div class="listing-grid "> <div class="row"> <div class="col-md-7 col-sm-8 col-xs-12"> <h3><a href="/question-detail/{{ question.qid }}" id="q1"> {{ question.title }} </a></h3> <div class="listing-meta"> </div> </div> <div class="col-md-3 col-sm-2 col-xs-12"> <ul class="question-statistic"> <li class="active"> <a data-toggle="tooltip" data-placement="bottom" data-original-title="Answers" id= "ac1"> </li> <li> <a data-toggle="tooltip" data-placement="bottom" data-original-title="Votes" id= "vc1"></a> </li> </ul> </div> <div class="col-md-10 col-sm-10 col-xs-12"> <p id= "a1">{{ question.details }}</p> {% for tag in question.taglist %} <div class="pull-right tagcloud"> <a href="" id="tg1.1">{{ tag }}</a> </div> {% endfor %} </div> </div> </div> <!-- Question Listing End --> {% endfor %} <!-- Pagination View More --> <div class="text-center clearfix"> <ul class="pagination "> <li> <a aria-label="Previous" href="#"> <span aria-hidden="true">&lt;</span> </a> </li> <li class="active"><a href="#">1</a> </li> <li><a href="#">2</a> </li> <li><a href="#">3</a> </li> <li> <a aria-label="Next" href="#"> <span aria-hidden="true">&gt;</span> </a> </li> </ul> </div> <!-- Pagination View More End --> </div> <!-- Question Area Panel End --> </div> </div> <!-- end container -->, </section> <script type="text/javascript"> function fetchdata() { print ("inside fetchdata"); $.ajax({ // use ajax to pass the obtained value from searchbox url : "/f/", method : "GET", dataType: "json", data: { request: frontend }, //close data success: function(result) { questions= result.questions; for (var i=0; i<questions.length; i++) { var question= questions[i]; title= question['title']; taglist= question['taglist']; details= question['details']; document.getElementById("q1").innerHTML= title; document.getElementById("tg1.1").innerHTML= taglist[0]; document.getElementById("a1").innerHTML= details; } }, error: function (textStatus, errorThrown) { //start error part console.log("Text status "+textStatus+" Error is "+errorThrown) //if error is found, print it }//end error part }); } windows.onload= fetchdata(); </script> <!-- =-=-=-=-=-=-= Latest Questions End =-=-=-=-=-=-= -->{% endblock %}
1+
{% extends 'askalma/headerfooter.html' %}{% block title %}Question Listing - AskAlma{% endblock %}{% load staticfiles %}{% block body %} <!-- =-=-=-=-=-=-= Latest Questions =-=-=-=-=-=-= --> <section class="section-padding-80 white" id="questions"> <div class="container"> <!-- Row --> <div class="row"> <div class="col-md-12 col-sm-12"> <div class="listing"> <!-- Question Area Panel --> <div class="listing-area"> <!-- Question Listing --> <!--one question= one listing grid--> {% for question in questions %} <div class="listing-grid "> <div class="row"> <div class="col-md-7 col-sm-8 col-xs-12"> <h3><a href="/question-detail/{{ question.qid }}" id="q1"> {{ question.title }} </a></h3> <div class="listing-meta"> </div> </div> <div class="col-md-3 col-sm-2 col-xs-12"> <ul class="question-statistic"> <li class="active"> <a data-toggle="tooltip" data-placement="bottom" data-original-title="Answers" id= "ac1"> </li> <li> <a data-toggle="tooltip" data-placement="bottom" data-original-title="Votes" id= "vc1"></a> </li> </ul> </div> <div class="col-md-10 col-sm-10 col-xs-12"> <p id= "a1" color= "">{{ question.details }}</p> {% for tag in question.taglist %} <div class="pull-right tagcloud"> <a href="" id="tg1.1">{{ tag }}</a> </div> {% endfor %} <div class= "col-md-4 col-sm-4 col-xs-4"> <p><i><b>{{ question.sentiment }}</b></i></p> </div> </div> </div> </div> <!-- Question Listing End --> {% endfor %} <!-- Pagination View More --> <div class="text-center clearfix"> <ul class="pagination "> <li> <a aria-label="Previous" href="#"> <span aria-hidden="true">&lt;</span> </a> </li> <li class="active"><a href="#">1</a> </li> <li><a href="#">2</a> </li> <li><a href="#">3</a> </li> <li> <a aria-label="Next" href="#"> <span aria-hidden="true">&gt;</span> </a> </li> </ul> </div> <!-- Pagination View More End --> </div> <!-- Question Area Panel End --> </div> </div> <!-- end container -->, </section> <script type="text/javascript"> function fetchdata() { print ("inside fetchdata"); $.ajax({ // use ajax to pass the obtained value from searchbox url : "/f/", method : "GET", dataType: "json", data: { request: frontend }, //close data success: function(result) { questions= result.questions; for (var i=0; i<questions.length; i++) { var question= questions[i]; title= question['title']; taglist= question['taglist']; details= question['details']; document.getElementById("q1").innerHTML= title; document.getElementById("tg1.1").innerHTML= taglist[0]; document.getElementById("a1").innerHTML= details; } }, error: function (textStatus, errorThrown) { //start error part console.log("Text status "+textStatus+" Error is "+errorThrown) //if error is found, print it }//end error part }); } windows.onload= fetchdata(); </script> <!-- =-=-=-=-=-=-= Latest Questions End =-=-=-=-=-=-= -->{% endblock %}

webapp/askalma/templates/askalma/question_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ <h4>About</h4>
247247
}
248248
},
249249
error: function (textStatus, errorThrown)
250-
{
250+
251251
console.log("Text status "+textStatus+" Error is "+errorThrown);
252252
}
253253
});

webapp/askalma/views.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,33 @@ def getquestions(request):
8888
def listing(request):
8989
result = _isLoggedIn(request)
9090
if result != None: return result
91-
# sentimentOutput = nlu.analyze(text=question['_source']['title'], features=[features.Sentiment()])
92-
# sentiment = sentimentOutput['sentiment']['document']['label']
9391
response = searchquestion(request)
9492
print(response)
9593
return render(request, 'askalma/listing.html' , context = response)
9694

9795
def searchquestion(request):
98-
try:
99-
#print "taking questions from elasticsearch"
100-
result=es.search(index='questions1', body={"from" : 0, "size" : 1000, "query":{"match_all": {}}})
101-
#print result
102-
questions= result['hits']['hits']
96+
try:
97+
result=es.search(index='questions1', body={"from" : 0, "size" : 1000, "query":{"match_all": {}}})
98+
print result
99+
questions= result['hits']['hits']
103100
#print questions
104-
b= []
105-
for question in questions:
106-
#print question
107-
tags= question['_source']['tags']
108-
taglist= [s.strip() for s in tags.split(',')]
109-
a = {
101+
b= []
102+
for question in questions:
103+
tags= question['_source']['tags']
104+
taglist= [s.strip() for s in tags.split(',')]
105+
sentimentOutput = nlu.analyze(text=question['_source']['title'], features=[features.Sentiment()])
106+
sentiment = sentimentOutput['sentiment']['document']['label']
107+
a = {
110108
"title": question['_source']['title'],
111109
"taglist": taglist,
112110
"details": question['_source']["details"],
113-
"qid" : question['_id']
111+
"qid" : question['_id'],
112+
"sentiment": sentiment
114113
}
115-
b.append(a)
116-
#print b
117-
return {'questions': b }
118-
except KeyError:
114+
b.append(a)
115+
print b
116+
return {'questions': b }
117+
except KeyError:
119118
return {'questions': "nothing"}
120119

121120
@csrf_exempt
@@ -145,7 +144,7 @@ def pullquestion(request):
145144
tags = categoryOutput['categories'][0]['label']
146145
keywordOutput = nlu.analyze(text=title, features=[features.Keywords()])
147146
if len(keywordOutput['keywords']) != 0:
148-
tags = tags + ", " + keywordOutput['keywords'][0]['text']
147+
tags = tags + ", " + keywordOutput['keywords'][0]['text']
149148
conceptOutput = nlu.analyze(text=title, features=[features.Concepts()])
150149
if len(conceptOutput['concepts']) != 0:
151150
tags = tags + ", " + conceptOutput['concepts'][0]['text']
@@ -247,9 +246,9 @@ def _getStats ():
247246
stats = {}
248247
stats['views'] = 7812
249248
stats['questions'] = es.search(index='questions1', body={"size": 0,})['hits']['total']
250-
# stats['answersed_questions'] = es.search(index='questions', body={"size": 0,"query":{ "query_string": { "query": 1, "default_field": 'answered' }}})['hits']['total']
249+
stats['answersed_questions'] = es.search(index='questions1', body={"size": 0,"query":{ "query_string": { "query": 1, "default_field": 'answered' }}})['hits']['total']
251250
stats['users'] = es.search(index='users', body={"size": 0,})['hits']['total']
252-
stats['answered_questions'] = 147
251+
stats['answered_questions'] = 24
253252

254253
return stats
255254

webapp/askalma/views.pyc

374 Bytes
Binary file not shown.

webapp/db.sqlite3

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)