Skip to content

Commit d29fdb8

Browse files
committed
start cleasing the mess
1 parent a393ba9 commit d29fdb8

File tree

11 files changed

+54
-39
lines changed

11 files changed

+54
-39
lines changed
181 Bytes
Binary file not shown.
7.35 KB
Binary file not shown.
Binary file not shown.

hierarchy-data/webapp/integration/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
urlpatterns = [
66
url(r'^phone?$', views.index, name='index'),
77
url(r'^phone/list/$', views.listing, name='list'),
8-
url(r'^phone/detail/$', views.detail, name='detail'),
9-
url(r'^freebase/matching/$', views.freebase, name='freebase')
8+
# url(r'^phone/detail/$', views.detail, name='detail'),
9+
# url(r'^freebase/matching/$', views.freebase, name='freebase')
1010
]
429 Bytes
Binary file not shown.

hierarchy-data/webapp/integration/views.py

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
from django.template import loader
44
import happybase
55
import sys,os
6-
import extract
6+
# import extract
77
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
88

99
pool = happybase.ConnectionPool(size=3, host='192.168.1.240')
1010
# pool = happybase.ConnectionPool(size=3, host='127.0.0.1')
11-
global_schema = extract.read_global_schema("integration/rules/global_schema.txt")
11+
# global_schema = extract.read_global_schema("integration/rules/global_schema.txt")
1212

1313

1414
# Create your views here.
@@ -29,10 +29,21 @@ def paginate(phones, page):
2929
return phones
3030

3131

32+
def _get_specs(columns, row_prefix, limit):
33+
with pool.connection() as connection:
34+
table = connection.table('phone_specs')
35+
try:
36+
for key, data in table.scan(row_prefix=bytes(row_prefix), limit=limit, columns=columns):
37+
print(key, data)
38+
except IOError:
39+
pass
40+
41+
3242
def listing(request):
3343
parameters = request.GET
44+
print parameters
3445
tables = parameters.getlist('table') if 'table' in parameters else ['phonearena', 'gsmarena']
35-
row_prefix = parameters['prefix'].upper() if 'prefix' in parameters else ''
46+
row_prefix = parameters['prefix'] if 'prefix' in parameters else ''
3647
try:
3748
limit = int(parameters.get('limit'))
3849
limit = limit if (limit <= 300) else 300
@@ -41,43 +52,47 @@ def listing(request):
4152
except TypeError:
4253
limit = 100
4354
page = request.GET.get('page')
55+
print row_prefix, tables, limit
4456

45-
with pool.connection() as connection:
46-
phone_data = {}
47-
for table in tables:
48-
phones, exit_code = extract.get_phone_models(connection, table, row_prefix=row_prefix, limit=limit)
49-
if exit_code == 0:
50-
# print str(phones)
51-
phone_data[table] = paginate(tuple(phones.items()), page)
52-
# phone_data[table] = phones
53-
54-
return render(request, 'list.html', {'phones': phone_data,
55-
'prefix': row_prefix, 'limit': limit})
57+
_get_specs(tables, row_prefix, limit)
5658

59+
# with pool.connection() as connection:
60+
# phone_data = {}
61+
# for table in tables:
62+
# phones, exit_code = extract.get_phone_models(connection, table, row_prefix=row_prefix, limit=limit)
63+
# if exit_code == 0:
64+
# # print str(phones)
65+
# phone_data[table] = paginate(tuple(phones.items()), page)
66+
# phone_data[table] = phones
5767

58-
def freebase(request):
5968
return HttpResponse('Hello Freebase')
69+
# return render(request, 'list.html', {'phones': phone_data,
70+
# 'prefix': row_prefix, 'limit': limit})
6071

6172

62-
def detail(request):
63-
print request.POST
64-
if 'phone' in request.POST:
65-
params = request.POST.getlist('phone')
66-
with pool.connection() as connection:
67-
phone_data = {}
68-
for param in params:
69-
tokens = param.split('###')
70-
table = tokens[0]
71-
row_key = tokens[1]
72-
data, exit_code = extract.get_phone(connection, table, row_key)
73-
phone_data[param] = sorted(data.items(), key=sortfn)
74-
return render(request, 'detail.html', {'phone_data': phone_data})
75-
else:
76-
return HttpResponseBadRequest('Bad request')
77-
78-
79-
def sortfn(item):
80-
if len(global_schema) == 0:
81-
return item[0]
82-
else:
83-
return global_schema[item[0].lower()]
73+
# def freebase(request):
74+
# return HttpResponse('Hello Freebase')
75+
#
76+
#
77+
# def detail(request):
78+
# print request.POST
79+
# if 'phone' in request.POST:
80+
# params = request.POST.getlist('phone')
81+
# with pool.connection() as connection:
82+
# phone_data = {}
83+
# for param in params:
84+
# tokens = param.split('###')
85+
# table = tokens[0]
86+
# row_key = tokens[1]
87+
# data, exit_code = extract.get_phone(connection, table, row_key)
88+
# phone_data[param] = sorted(data.items(), key=sortfn)
89+
# return render(request, 'detail.html', {'phone_data': phone_data})
90+
# else:
91+
# return HttpResponseBadRequest('Bad request')
92+
#
93+
#
94+
# def sortfn(item):
95+
# if len(global_schema) == 0:
96+
# return item[0]
97+
# else:
98+
# return global_schema[item[0].lower()]
2.4 KB
Binary file not shown.
176 Bytes
Binary file not shown.
2.73 KB
Binary file not shown.

hierarchy-data/webapp/mysite/urls.pyc

1.27 KB
Binary file not shown.

hierarchy-data/webapp/mysite/wsgi.pyc

631 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)