Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
insights
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
insights
Commits
95e8dada
Commit
95e8dada
authored
Apr 18, 2013
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up schema to fully replace probe. There should be only one
parent
9e39e0d5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
32 deletions
+36
-32
src/djanalytics/core/static/index.html
+1
-1
src/djanalytics/core/urls.py
+1
-1
src/djanalytics/core/views.py
+34
-30
No files found.
src/djanalytics/core/static/index.html
View file @
95e8dada
<html>
<html>
<h1>
Welcome to analytics!
</h1>
<h1>
Welcome to analytics!
</h1>
<ul>
<ul>
<li>
<a
href=
"/
probe?f=html"
>
Probe
</a>
will give a list of views and queries.
<li>
<a
href=
"/
schema?f=html"
>
schema
</a>
will give a list of views and queries.
<li>
<a
href=
"/event_properties"
>
Event properties
</a>
will give a list of event properties.
<li>
<a
href=
"/event_properties"
>
Event properties
</a>
will give a list of event properties.
</ul>
</ul>
Docs are on
<a
href=
https://github.com/MITx/djanalytics
>
github
</a>
.
Docs are on
<a
href=
https://github.com/MITx/djanalytics
>
github
</a>
.
...
...
src/djanalytics/core/urls.py
View file @
95e8dada
...
@@ -4,7 +4,7 @@ urlpatterns = patterns('',
...
@@ -4,7 +4,7 @@ urlpatterns = patterns('',
# Examples:
# Examples:
url
(
r'^view/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_view'
),
url
(
r'^view/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_view'
),
url
(
r'^query/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_query'
),
url
(
r'^query/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_query'
),
url
(
r'^schema$'
,
'djanalytics.core.views.
list_all_endpoints
'
),
url
(
r'^schema$'
,
'djanalytics.core.views.
schema
'
),
url
(
r'^probe$'
,
'djanalytics.core.views.handle_probe'
),
url
(
r'^probe$'
,
'djanalytics.core.views.handle_probe'
),
url
(
r'^probe/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_probe'
),
url
(
r'^probe/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_probe'
),
url
(
r'^probe/([A-Za-z_+]+)/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_probe'
),
url
(
r'^probe/([A-Za-z_+]+)/([A-Za-z_+]+)$'
,
'djanalytics.core.views.handle_probe'
),
...
...
src/djanalytics/core/views.py
View file @
95e8dada
...
@@ -36,44 +36,48 @@ def event_properties(request):
...
@@ -36,44 +36,48 @@ def event_properties(request):
items
.
append
(
"<di>{name}</di><dd>{doc}</dd>"
.
format
(
**
event_property_registry
[
key
]))
items
.
append
(
"<di>{name}</di><dd>{doc}</dd>"
.
format
(
**
event_property_registry
[
key
]))
return
HttpResponse
(
"<dl>"
+
"
\n
"
.
join
(
items
)
+
"</dl>"
)
return
HttpResponse
(
"<dl>"
+
"
\n
"
.
join
(
items
)
+
"</dl>"
)
@auth.auth
# We don't want to have two ways to get at this data
def
handle_probe
(
request
,
cls
=
None
,
name
=
None
):
# @auth.auth
''' Handles probes for what types of modules are available, and
# def handle_probe(request, cls=None, name = None):
what they do. Shown as, effectively, a big directory tree to the
# ''' Handles probes for what types of modules are available, and
caller.
# what they do. Shown as, effectively, a big directory tree to the
'''
# caller.
error_message
=
"{0} not found in {1}."
# '''
if
cls
==
None
:
# error_message = "{0} not found in {1}."
l
=
[
'view'
,
'query'
]
# if cls == None:
elif
name
==
None
:
# l = ['view','query']
if
cls
in
request_handlers
:
# elif name == None:
l
=
request_handlers
[
cls
]
.
keys
()
# if cls in request_handlers:
else
:
# l = request_handlers[cls].keys()
raise
Http404
(
error_message
.
format
(
cls
,
request_handlers
))
# else:
else
:
# raise Http404(error_message.format(cls,request_handlers))
if
cls
in
request_handlers
and
name
in
request_handlers
[
cls
]:
# else:
l
=
[
request_handlers
[
cls
][
name
][
'doc'
]]
# if cls in request_handlers and name in request_handlers[cls]:
else
:
# l = [request_handlers[cls][name]['doc']]
raise
Http404
(
error_message
.
format
(
cls
+
'/'
+
name
,
request_handlers
))
# else:
if
request
.
GET
.
get
(
"f"
,
""
)
==
"html"
:
# raise Http404(error_message.format(cls+'/'+name,request_handlers))
if
not
name
:
# if request.GET.get("f", "") == "html":
l
=
[
"<li><a href={a}?f=html>{b}</a></li>"
.
format
(
a
=
(
cls
or
"probe"
)
+
"/"
+
i
,
b
=
i
)
for
i
in
l
]
# if not name:
else
:
# l = ["<li><a href={a}?f=html>{b}</a></li>".format(a=(cls or "probe")+"/"+i, b=i) for i in l]
l
=
[
"<p>"
.
join
(
l
)]
# else:
return
HttpResponse
(
""
.
join
(
l
),
mimetype
=
'text/html'
)
# l = ["<p>".join(l)]
return
HttpResponse
(
"
\n
"
.
join
(
l
),
mimetype
=
'text/text'
)
# return HttpResponse("".join(l), mimetype='text/html')
# return HttpResponse("\n".join(l), mimetype='text/text')
@auth.auth
@auth.auth
def
list_all_endpoints
(
request
):
def
schema
(
request
):
''' Returns all available views and queries as a JSON
''' Returns all available views and queries as a JSON
object. Alternative to the probe hierarchy.
object.
'''
'''
endpoints
=
[]
endpoints
=
[]
for
cls
in
request_handlers
:
for
cls
in
request_handlers
:
for
name
in
request_handlers
[
cls
]:
for
name
in
request_handlers
[
cls
]:
endpoints
.
append
({
'type'
:
request_handlers
[
cls
][
name
][
'category'
],
'class'
:
cls
,
'name'
:
name
})
rh
=
request_handlers
[
cls
][
name
]
endpoints
.
append
({
'category'
:
rh
[
'category'
],
'class'
:
cls
,
'name'
:
name
,
'doc'
:
rh
[
'doc'
]})
if
request
.
GET
.
get
(
"f"
,
""
)
==
"html"
:
return
HttpResponse
(
"
\n
"
.
join
(
sorted
([
"<dt><p><b>{class}/{name}</b> <i>{category}</i></dt><dd>{doc}</dd>"
.
format
(
**
rh
)
for
rh
in
endpoints
])))
return
HttpResponse
(
json
.
dumps
(
endpoints
))
return
HttpResponse
(
json
.
dumps
(
endpoints
))
def
handle_request
(
cls
,
name
,
**
kwargs
):
def
handle_request
(
cls
,
name
,
**
kwargs
):
''' Generic code from handle_view and handle_query '''
''' Generic code from handle_view and handle_query '''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment