Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ build
dist
MANIFEST
_build
venv
.tox
24 changes: 14 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
language: python
python:
- "2.6"
- "2.7"
- "3.8"
- "3.7"
- "3.6"
services:
- redis-server
before_install:
- export PIP_USE_MIRRORS=true
- sudo apt-get update
- sudo apt-get install redis-server
matrix:
fast_finish: true
include:
- python: "3.5"
env: DJANGO=2.2
install:
- pip install -e .
- pip install -r requirements/tests.txt Django==$DJANGO
- pip install tox tox-venv tox-travis
script:
- django-admin.py test --settings=app_metrics.tests.settings app_metrics
- tox
env:
- DJANGO=1.3.7
- DJANGO=1.4.5
- DJANGO=1.5
- DJANGO=2.2
- DJANGO=3.0
10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ settings and it will behave as if Celery was not configured.
.. _Celery: http://celeryproject.org/
.. _`django-celery`: http://ask.github.com/django-celery/

Django 1.2 and above
Django 2.2 and above
Python 3.5 and above

Support for older Django and Python
-----------------------------------

Django App Metrics v0.8.0 supports older versions of Django and Python if you still need it.

``$ pip install django-app-metrics==0.8.0``

Usage
=====
Expand Down
8 changes: 4 additions & 4 deletions app_metrics/management/commands/metrics_aggregate.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import datetime
from django.core.management.base import NoArgsCommand
from django.core.management import BaseCommand

from app_metrics.models import Metric, MetricItem, MetricDay, MetricWeek, MetricMonth, MetricYear

from app_metrics.utils import week_for_date, month_for_date, year_for_date, get_backend

class Command(NoArgsCommand):
class Command(BaseCommand):
help = "Aggregate Application Metrics"

requires_model_validation = True

def handle_noargs(self, **options):
def handle(self, **options):
""" Aggregate Application Metrics """

backend = get_backend()

# If using Mixpanel this command is a NOOP
if backend == 'app_metrics.backends.mixpanel':
print "Useless use of metrics_aggregate when using Mixpanel backend"
print("Useless use of metrics_aggregate when using Mixpanel backend")
return

# Aggregate Items
Expand Down
8 changes: 4 additions & 4 deletions app_metrics/management/commands/metrics_send_mail.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import string

from django.core.management.base import NoArgsCommand
from django.core.management import BaseCommand
from django.conf import settings
from django.db.models import Q
from django.utils import translation
Expand All @@ -11,12 +11,12 @@
from app_metrics.models import MetricSet, Metric
from app_metrics.utils import get_backend

class Command(NoArgsCommand):
class Command(BaseCommand):
help = "Send Report E-mails"
requires_model_validation = True
can_import_settings = True

def handle_noargs(self, **options):
def handle(self, **options):
""" Send Report E-mails """

from django.conf import settings
Expand All @@ -26,7 +26,7 @@ def handle_noargs(self, **options):

# This command is a NOOP if using the Mixpanel backend
if backend == 'app_metrics.backends.mixpanel':
print "Useless use of metrics_send_email when using Mixpanel backend."
print("Useless use of metrics_send_email when using Mixpanel backend.")
return

# Determine if we should also send any weekly or monthly reports
Expand Down
13 changes: 7 additions & 6 deletions app_metrics/management/commands/move_to_mixpanel.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
from django.core.management.base import NoArgsCommand
from django.core.management import BaseCommand

from app_metrics.models import MetricItem
from app_metrics.backends.mixpanel import metric
from app_metrics.utils import get_backend
from app_metrics.utils import get_backend, get_timestamp

class Command(NoArgsCommand):

class Command(BaseCommand):
help = "Move MetricItems from the db backend to MixPanel"

requires_model_validation = True

def handle_noargs(self, **options):
def handle(self, **options):
""" Move MetricItems from the db backend to MixPanel" """

backend = get_backend()

# If not using Mixpanel this command is a NOOP
if backend != 'app_metrics.backends.mixpanel':
print "You need to set the backend to MixPanel"
print("You need to set the backend to MixPanel")
return

items = MetricItem.objects.all()

for i in items:
properties = {
'time': i.created.strftime('%s'),
'time': int(get_timestamp(i.created)),
}
metric(i.metric.slug, num=i.num, properties=properties)

Expand Down
6 changes: 3 additions & 3 deletions app_metrics/management/commands/move_to_statsd.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys
from django.core.management.base import NoArgsCommand
from django.core.management import BaseCommand
from app_metrics.models import MetricItem
from app_metrics.backends.statsd_backend import metric


class Command(NoArgsCommand):
class Command(BaseCommand):
help = "Move MetricItems from the db backend to statsd"
requires_model_validation = True

def handle_noargs(self, **options):
def handle(self, **options):
"""Move MetricItems from the db backend to statsd"""
backend = get_backend()

Expand Down
Loading