コード例 #1
0
def calculate_weightAvg_async(user):
    tracks = Track.objects.order_by('timestamp')
    times = []
    weights = []
    postRef = []

    #Loop through all tracks and create period object for each day
    for track in tracks:
        times.append(Period(track.timestamp, freq='D'))
        weights.append(track.weight)
        postRef.append(track.to_dbref())

    periods = PeriodIndex(times)

    ts = Series(weights, index=periods)
    mean = rolling_mean(ts, 10)

    print mean

    new_Analysis = Analysis(
        author = user
        )

    for i, entry in enumerate(mean):
        my_data = DailyAnalysis (
            weightAvg = entry,
            date = times[i].to_timestamp(),
            postRef = postRef[i]
            )
        new_Analysis.dailyAnalysis.append(my_data)

    new_Analysis.save()
コード例 #2
0
ファイル: views.py プロジェクト: daerwang/dashboard-1
def analyze(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    result_analysis = code_analysis(project)

    analysis = Analysis()
    analysis.project = project
    analysis.pep8 = result_analysis['pep8']['percentage_errors']
    analysis.pyflakes = result_analysis['pyflakes']['percentage_errors']
    analysis.clonedigger = result_analysis['clonedigger']['percentage_errors']
    analysis.jshint = result_analysis['jshint']['percentage_errors']
    analysis.csslint = result_analysis['csslint']['percentage_errors']
    analysis.result = result_analysis
    analysis.save()

    return HttpResponse('done')
コード例 #3
0
ファイル: views.py プロジェクト: zhalloran/DRFDemo
    def create(self, request):
        analysis = Analysis(**request.data)
        analysis.save()

        return HttpResponse(analysis.to_json())