Exemplo n.º 1
0
    def getInfo(self, service, date1, date2, span):

        #get the data
        data = SQLclient.getStats(self.cursor,service, date1, date2, span)

        #format data
        names = Plotter.plotCCinfo(data,date1,date2,span)
        return names
Exemplo n.º 2
0
    def getNewPie(self, span):

        #get the data from the DB
        data = SQLclient.getNewPieData(self.cursor, span)

        #format the data for Highcharts
        pie_gogn = Plotter.prepare_pie(data)
        return pie_gogn
Exemplo n.º 3
0
    def getInitialRealTime(self):

        #date for the query
        now = datetime.datetime.now()
        thenTemp = now - datetime.timedelta(hours = 10*24)
        then = thenTemp.strftime("%Y-%m-%d %H:%M")

        data = SQLclient.getInitialRealTime(self.cursor, then)

        self.initdata = data
Exemplo n.º 4
0
def general(service):

    global audit

    #get dates and the name of the function within 'service' in order to get the daitailed data for the detail graph default values for both is ''
    date = request.args.get('date', '')
    name = request.args.get('name', '')

    #gather data with the date and name variables
    DetailData = audit.getDetail(date, service, name )

    #if the default values for the date and name are apparent, i will not return json response, because then that would be the only thing that would be rendered on the site
    # however, if the values are not the default, then the page has been loaded before and someone has requested new data. in that case it is ok to only send the
    # json response since in that case you are answering a specific client request that wants a json response
    if date != '':

        #format data for Json with the data from DetailData
        data = {'number' : DetailData[1], 'hour': DetailData[0], 'date': date}
        return jsonify(data)

    #if the page gets a request like a button press etc... it will go into this if statement
    if request.method == 'POST':

        #get dates from the calendar 
        dags1 = request.form['datedate']
        dags2 = request.form['date']
        if not isinstance(dags1, datetime.date) or not isinstance(dags2, datetime.date):
            now = datetime.datetime.now().date()
            then = now - datetime.timedelta(days = 30.0)

            dates =[str(now),str(then)]
        else:
            #refactor dates to get the right format for the SQL query returns [date1,date2]
            dates = SQLclient.refactorDates(dags1,dags2)

        #get the span from site
        span = request.form['span']
        if  not span.isdigit():
            span = 1

        #functions is a data array that looks like this: [datapacket for speed of service, datapacket for the number of function calls, name of the functions for the service]
        # the data gathered is found through SQL with the parameters given
        functions = audit.getInfo(service,dates[0],dates[1],span)

        #get the names in a seperate array
        names = functions[-1]

        # then remove it from the functions array, leaving the functions array to look like this: [datapacket for speed of service, datapacket for the number of function calls]
        del functions[-1]

        #a little something in order to get the YYYY - MM - DD format into the site to be used in numerous places
        date1 = datetime.date(int(dates[0][:4]), int(dates[0][5:7]), int(dates[0][8:10])) - datetime.timedelta(int(span)*365/12)
        date2 = datetime.date(int(dates[1][:4]), int(dates[1][5:7]), int(dates[1][8:10])) - datetime.timedelta(int(span)*365/12)

        dags1y = date1.year
        dags2y = date2.year

        dags1m = date1.month
        dags2m = date2.month

        dags1d = date1.day
        dags2d = date2.day

        #render the page with all the gathered data
        return render_template('speedLogger.html', functions = names, name=service,dags1Y = dags1y, dags1M=dags1m, dags1D = dags1d, dags2Y=dags2y, dags2M = dags2m, dags2D = dags2d, data= functions, DD = DetailData[0])
    
    #get default dates for the page when it is being loaded for the first time
    now = datetime.datetime.now().date()
    then = now - datetime.timedelta(days = 30.0)

    #format the dates like in the if statement above to get the YYYY - MM - DD format into the site
    dags11 = str(now)
    dags22 = str(then)

    date1 = datetime.date(int(dags11[:4]), int(dags11[5:7]), int(dags11[8:10])) - datetime.timedelta(1*365/12)
    date2 = datetime.date(int(dags22[:4]), int(dags22[5:7]), int(dags22[8:10])) - datetime.timedelta(1*365/12)

    dags1y = date1.year
    dags2y = date2.year

    dags1m = date1.month
    dags2m = date2.month
    
    dags1d = date1.day
    dags2d = date2.day

    #get the data from the SQL connection with the default parameters -- same as above
    functions = audit.getInfo(service,dags11,dags22,1)
    names = functions[-1]
    del functions[-1]
    return render_template('speedLogger.html', functions = names, name=service,dags1Y = dags1y, dags1M=dags1m, dags1D = dags1d, dags2Y=dags2y, dags2M = dags2m, dags2D = dags2d, data= functions, DD = DetailData[0])
Exemplo n.º 5
0
 def getRealTime(self, date, service):
     data = SQLclient.getRealTimeData(self.cursor, date, service)
     return data
Exemplo n.º 6
0
 def getNumPie(self, span):
     data = SQLclient.getNumPie(self.cursor, span)
     return data
Exemplo n.º 7
0
    def getDetail(self, date, service, function):

        #gets data according to the service name, function name within that service and the date requested
        data = SQLclient.getDetails(self.cursor, date, service, function)
        return data
Exemplo n.º 8
0
 def getServices(self):
     services = SQLclient.getServices(self.cursor)
     return services
Exemplo n.º 9
0
    def loadNewDataIntoTable(self):
        SQLclient.loadNewData(self.cursor)

        self.data_gogn = SQLclient.data(self.cursor)
Exemplo n.º 10
0
 def updateAggTables(self):
     self.data_gogn = SQLclient.data(self.cursor)
Exemplo n.º 11
0
 def __init__(self):
     self.connection = SQLclient.connect_to_DB()
     self.cursor = self.connection.get_cursor()
     #self.connection.create_agg()
     #self.connection.create_agg_for_func_speed()
     self.data_gogn = SQLclient.data(self.cursor)