Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
320f1b41
Commit
320f1b41
authored
Dec 21, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update schema for tracking sql logs - larger fields; add hostname
parent
ecc4d79f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
3 deletions
+107
-3
common/djangoapps/track/migrations/0001_initial.py
+49
-0
common/djangoapps/track/migrations/0002_auto__add_field_trackinglog_host__chg_field_trackinglog_event_type__ch.py
+52
-0
common/djangoapps/track/migrations/__init__.py
+0
-0
common/djangoapps/track/models.py
+3
-2
common/djangoapps/track/views.py
+3
-1
No files found.
common/djangoapps/track/migrations/0001_initial.py
0 → 100644
View file @
320f1b41
# -*- coding: utf-8 -*-
import
datetime
from
south.db
import
db
from
south.v2
import
SchemaMigration
from
django.db
import
models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding model 'TrackingLog'
db
.
create_table
(
'track_trackinglog'
,
(
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'dtcreated'
,
self
.
gf
(
'django.db.models.fields.DateTimeField'
)(
auto_now_add
=
True
,
blank
=
True
)),
(
'username'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
,
blank
=
True
)),
(
'ip'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
,
blank
=
True
)),
(
'event_source'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
)),
(
'event_type'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
,
blank
=
True
)),
(
'event'
,
self
.
gf
(
'django.db.models.fields.TextField'
)(
blank
=
True
)),
(
'agent'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
256
,
blank
=
True
)),
(
'page'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
,
null
=
True
,
blank
=
True
)),
(
'time'
,
self
.
gf
(
'django.db.models.fields.DateTimeField'
)()),
))
db
.
send_create_signal
(
'track'
,
[
'TrackingLog'
])
def
backwards
(
self
,
orm
):
# Deleting model 'TrackingLog'
db
.
delete_table
(
'track_trackinglog'
)
models
=
{
'track.trackinglog'
:
{
'Meta'
:
{
'object_name'
:
'TrackingLog'
},
'agent'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'256'
,
'blank'
:
'True'
}),
'dtcreated'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
'event'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'event_source'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
}),
'event_type'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
,
'blank'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'ip'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
,
'blank'
:
'True'
}),
'page'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'time'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{}),
'username'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
,
'blank'
:
'True'
})
}
}
complete_apps
=
[
'track'
]
\ No newline at end of file
common/djangoapps/track/migrations/0002_auto__add_field_trackinglog_host__chg_field_trackinglog_event_type__ch.py
0 → 100644
View file @
320f1b41
# -*- coding: utf-8 -*-
import
datetime
from
south.db
import
db
from
south.v2
import
SchemaMigration
from
django.db
import
models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding field 'TrackingLog.host'
db
.
add_column
(
'track_trackinglog'
,
'host'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
''
,
max_length
=
64
,
blank
=
True
),
keep_default
=
False
)
# Changing field 'TrackingLog.event_type'
db
.
alter_column
(
'track_trackinglog'
,
'event_type'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
512
))
# Changing field 'TrackingLog.page'
db
.
alter_column
(
'track_trackinglog'
,
'page'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
512
,
null
=
True
))
def
backwards
(
self
,
orm
):
# Deleting field 'TrackingLog.host'
db
.
delete_column
(
'track_trackinglog'
,
'host'
)
# Changing field 'TrackingLog.event_type'
db
.
alter_column
(
'track_trackinglog'
,
'event_type'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
))
# Changing field 'TrackingLog.page'
db
.
alter_column
(
'track_trackinglog'
,
'page'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
32
,
null
=
True
))
models
=
{
'track.trackinglog'
:
{
'Meta'
:
{
'object_name'
:
'TrackingLog'
},
'agent'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'256'
,
'blank'
:
'True'
}),
'dtcreated'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
'event'
:
(
'django.db.models.fields.TextField'
,
[],
{
'blank'
:
'True'
}),
'event_source'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
}),
'event_type'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'512'
,
'blank'
:
'True'
}),
'host'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'64'
,
'blank'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'ip'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
,
'blank'
:
'True'
}),
'page'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'512'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'time'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{}),
'username'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'32'
,
'blank'
:
'True'
})
}
}
complete_apps
=
[
'track'
]
\ No newline at end of file
common/djangoapps/track/migrations/__init__.py
0 → 100644
View file @
320f1b41
common/djangoapps/track/models.py
View file @
320f1b41
...
@@ -7,11 +7,12 @@ class TrackingLog(models.Model):
...
@@ -7,11 +7,12 @@ class TrackingLog(models.Model):
username
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
)
username
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
)
ip
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
)
ip
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
)
event_source
=
models
.
CharField
(
max_length
=
32
)
event_source
=
models
.
CharField
(
max_length
=
32
)
event_type
=
models
.
CharField
(
max_length
=
3
2
,
blank
=
True
)
event_type
=
models
.
CharField
(
max_length
=
51
2
,
blank
=
True
)
event
=
models
.
TextField
(
blank
=
True
)
event
=
models
.
TextField
(
blank
=
True
)
agent
=
models
.
CharField
(
max_length
=
256
,
blank
=
True
)
agent
=
models
.
CharField
(
max_length
=
256
,
blank
=
True
)
page
=
models
.
CharField
(
max_length
=
3
2
,
blank
=
True
,
null
=
True
)
page
=
models
.
CharField
(
max_length
=
51
2
,
blank
=
True
,
null
=
True
)
time
=
models
.
DateTimeField
(
'event time'
)
time
=
models
.
DateTimeField
(
'event time'
)
host
=
models
.
CharField
(
max_length
=
64
,
blank
=
True
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
s
=
"[
%
s]
%
s@
%
s:
%
s |
%
s |
%
s |
%
s"
%
(
self
.
time
,
self
.
username
,
self
.
ip
,
self
.
event_source
,
s
=
"[
%
s]
%
s@
%
s:
%
s |
%
s |
%
s |
%
s"
%
(
self
.
time
,
self
.
username
,
self
.
ip
,
self
.
event_source
,
...
...
common/djangoapps/track/views.py
View file @
320f1b41
...
@@ -17,7 +17,7 @@ from track.models import TrackingLog
...
@@ -17,7 +17,7 @@ from track.models import TrackingLog
log
=
logging
.
getLogger
(
"tracking"
)
log
=
logging
.
getLogger
(
"tracking"
)
LOGFIELDS
=
[
'username'
,
'ip'
,
'event_source'
,
'event_type'
,
'event'
,
'agent'
,
'page'
,
'time'
]
LOGFIELDS
=
[
'username'
,
'ip'
,
'event_source'
,
'event_type'
,
'event'
,
'agent'
,
'page'
,
'time'
,
'host'
]
def
log_event
(
event
):
def
log_event
(
event
):
event_str
=
json
.
dumps
(
event
)
event_str
=
json
.
dumps
(
event
)
...
@@ -58,6 +58,7 @@ def user_track(request):
...
@@ -58,6 +58,7 @@ def user_track(request):
"agent"
:
agent
,
"agent"
:
agent
,
"page"
:
request
.
GET
[
'page'
],
"page"
:
request
.
GET
[
'page'
],
"time"
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
"time"
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
"host"
:
request
.
META
[
'SERVER_NAME'
],
}
}
log_event
(
event
)
log_event
(
event
)
return
HttpResponse
(
'success'
)
return
HttpResponse
(
'success'
)
...
@@ -83,6 +84,7 @@ def server_track(request, event_type, event, page=None):
...
@@ -83,6 +84,7 @@ def server_track(request, event_type, event, page=None):
"agent"
:
agent
,
"agent"
:
agent
,
"page"
:
page
,
"page"
:
page
,
"time"
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
"time"
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
"host"
:
request
.
META
[
'SERVER_NAME'
],
}
}
if
event_type
.
startswith
(
"/event_logs"
)
and
request
.
user
.
is_staff
:
# don't log
if
event_type
.
startswith
(
"/event_logs"
)
and
request
.
user
.
is_staff
:
# don't log
...
...
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