-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging Feature #72
Open
sgrewal12
wants to merge
11
commits into
master
Choose a base branch
from
sg--logging
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Logging Feature #72
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
68f4129
Data Logger App
sgrewal12 fc0e35c
Merge branch 'master' of https://github.com/ucladevx/BQuest-Backend
sgrewal12 4af0810
Final Logging Changes
sgrewal12 2fb72cf
Removed Unnecessary Comment
sgrewal12 21beeef
Added App to settings
sgrewal12 0cf3eb2
Changed helper function details
sgrewal12 d66ecbe
Updated Time Log
sgrewal12 d846abb
Merge remote-tracking branch 'origin/master' into sg--logging
Cscotttaakan 3134170
Merged master
Cscotttaakan 1c9ef6c
Removed hanging merge text
Cscotttaakan a949d49
Deleting extra text
Cscotttaakan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.contrib import admin | ||
from . import models | ||
|
||
# Register your models here. | ||
|
||
@admin.register(models.Data) | ||
class DataAdmin(admin.ModelAdmin): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DataCollectionConfig(AppConfig): | ||
name = 'data_collection' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import factory | ||
from . import models | ||
|
||
|
||
class DataFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = models.Data | ||
|
||
date_created = factory.LazyFunction(datetime.datetime.now) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.conf import settings | ||
from django.db.models import Q | ||
from rest_framework.response import Response | ||
from .models import Data | ||
|
||
def log(data_type, data): | ||
new_data = Data(data_type=data_type, log=data) | ||
new_data.save() | ||
return new_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.7 on 2018-03-14 02:32 | ||
from __future__ import unicode_literals | ||
|
||
import django.contrib.postgres.fields.jsonb | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Data', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('data_type', models.CharField(max_length=100)), | ||
('date_created', models.DateTimeField(auto_now_add=True)), | ||
('log', django.contrib.postgres.fields.jsonb.JSONField()), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.db import models | ||
from django.contrib.postgres.fields import JSONField | ||
from datetime import datetime | ||
import pytz | ||
|
||
# Create your models here. | ||
|
||
class Data(models.Model): | ||
data_type = models.CharField(max_length=100, null=False) | ||
date_created = models.DateTimeField(auto_now_add=True) | ||
log = JSONField() | ||
|
||
def __str__(self): | ||
return '%s: %s %s' % (self.data_type, self.log, datetime.now(pytz.timezone('US/Pacific'))) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from rest_framework import serializers | ||
from drf_writable_nested import WritableNestedModelSerializer | ||
|
||
from .models import Data | ||
|
||
class DataSerializer(WritableNestedModelSerializer): | ||
class Meta: | ||
model = Data | ||
fields = ('data_type', 'date_created', 'log',) | ||
read_only_fields = ('data_ type', 'date_created', 'log',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import url | ||
|
||
from . import views | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^log/$', views.DataLogView.as_view(), name='log_data'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.conf import settings | ||
from django.db.models import Q | ||
from rest_framework.response import Response | ||
from .models import Data | ||
from .serializers import DataSerializer | ||
from rest_framework import generics | ||
from . import helpers | ||
|
||
# Create your views here. | ||
class DataLogView(generics.CreateAPIView): | ||
serializer_class = DataSerializer | ||
|
||
def post (self,request): | ||
result = helpers.log(request.data['data_type'], request.data['log']) | ||
|
||
new_data = Data( | ||
data_type = request.data['data_type'], | ||
log = request.data['log'], | ||
) | ||
new_data.save() | ||
|
||
return Response(DataSerializer(result).data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i meant
date_created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I figured that out later.. Changed it