Exemplo n.º 1
0
 def get_job_information_from_Statistic_table(self, selected_job):
     job_statistic = Statistic.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             '$match': {'relation.name': selected_job}
         },
     ])
     return list(job_statistic)[0]
Exemplo n.º 2
0
 def calculate_number_of_crashes_for_selected_job(self, selected_job):
     all_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             '$match': {'relation.name': selected_job}
         }
     ])
     return len(list(all_crashes))
Exemplo n.º 3
0
 def calculate_number_of_unique_and_exploitable_crashes_for_selected_job(self, selected_job):
     unique_exploitable_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             '$match': {'relation.name': selected_job, 'exploitability': 'EXPLOITABLE'}
         },
         {
             '$group': {'_id': '$crash_hash'}
         }
     ])
     return len(list(unique_exploitable_crashes))
Exemplo n.º 4
0
def get_crashes_of_date_for_selected_job(date, selected_job):
    return Crash.objects.aggregate(*[{
        '$lookup': {
            'from': Job._get_collection_name(),
            'localField': 'job_id',
            'foreignField': '_id',
            'as': 'relation'
        }
    }, {
        "$match": {
            "relation.name": selected_job,
            "date": {
                "$gte": date,
                "$lt": date + timedelta(days=1)
            }
        }
    }])
Exemplo n.º 5
0
 def calculate_number_of_unique_crashes_for_selected_job(self, selected_job):
     unique_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             "$match": {"relation.name": selected_job}
         },
         {
             "$group": {"_id": "$crash_hash"}
         }
     ])
     return len(list(unique_crashes))
Exemplo n.º 6
0
 def calculate_different_crash_signals_for_selected_job(self, selected_job):
     different_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             '$match': {'relation.name': selected_job}
         },
         {
             '$group': {'_id': '$crash_signal', 'quantity': {'$sum': 1}}
         }
     ])
     different_crashes_with_quantity = {}
     for different_crash in different_crashes:
         different_crashes_with_quantity[different_crash['_id']] = different_crash['quantity']
     return different_crashes_with_quantity
Exemplo n.º 7
0
 def calculate_different_crash_signals_for_selected_job(self, selected_job):
     different_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             "$match": {"relation.name": selected_job}
         },
         {
             "$group": {"_id": "$crash_signal", "quantity": {"$sum": 1}}
         }
     ])
     different_crashes_with_quantity = {}
     for different_crash in different_crashes:
         different_crashes_with_quantity[different_crash["_id"]] = different_crash["quantity"]
     return different_crashes_with_quantity
Exemplo n.º 8
0
 def calculate_all_crashes_per_time_interval_for_selected_job(self, selected_job):
     all_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             '$match': {'relation.name': selected_job}
         },
         {
             '$sort': {'date': 1}
         },
         {
             '$project': {'date': 1, 'iteration': 1}
         }
     ])
     all_crashes_per_time_interval, iterations_per_time_interval = self.calculate_crashes_and_iterations_per_time_interval_for_selected_job(list(all_crashes))
     return all_crashes_per_time_interval, iterations_per_time_interval
Exemplo n.º 9
0
 def calculate_all_unique_crashes_per_time_interval_for_selected_job(self, selected_job):
     all_unique_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             "$match": {"relation.name": selected_job}
         },
         {
             "$group": {"_id": "$crash_hash", "date": {"$min": "$date"}}
         },
         {
             "$sort": {"date": 1}
         }
     ])
     all_unique_crashes_per_time_interval = self.calculate_crashes_per_time_interval(list(all_unique_crashes))
     return all_unique_crashes_per_time_interval
Exemplo n.º 10
0
 def calculate_last_24_hours_crashes_per_time_interval_for_selected_job(self, selected_job):
     last_24_hours_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             '$match': {'relation.name': selected_job, 'date': {'$gte': self.date_now - timedelta(days=1)}}
         },
         {
             '$sort': {'date': 1}
         },
         {
             '$project': {'date': 1, 'iteration': 1}
         }
     ])
     last_24_hours_crashes = list(last_24_hours_crashes)
     self.crash_counter -= len(last_24_hours_crashes)
     last_24_hours_crashes_per_time_interval, last_24_hours_iterations_per_time_interval = self.calculate_crashes_and_iterations_per_time_interval_for_selected_job(last_24_hours_crashes)
     return last_24_hours_crashes_per_time_interval, last_24_hours_iterations_per_time_interval
Exemplo n.º 11
0
 def calculate_last_24_hours_unique_crashes_per_time_interval_for_selected_job(self, selected_job):
     last_24_hours_unique_crashes = Crash.objects.aggregate(*[
         {
             '$lookup':
                 {'from': Job._get_collection_name(),
                  'localField': 'job_id',
                  'foreignField': '_id',
                  'as': 'relation'}
         },
         {
             "$match": {"relation.name": selected_job, "date": {"$gte": self.date_now - timedelta(days=1)}}
         },
         {
             "$group": {"_id": "$crash_hash", "date": {"$min": "$date"}}
         },
         {
             "$sort": {"date": 1}
         }
     ])
     last_24_hours_unique_crashes = list(last_24_hours_unique_crashes)
     self.crash_counter -= len(last_24_hours_unique_crashes)
     last_24_hours_unique_crashes_per_time_interval = self.calculate_crashes_per_time_interval(last_24_hours_unique_crashes)
     return last_24_hours_unique_crashes_per_time_interval
Exemplo n.º 12
0
def get_unique_exploitable_crashes_of_date_for_selected_job(
        date, selected_job):
    unique_exploitable_crashes = Crash.objects.aggregate(*[{
        '$lookup': {
            'from': Job._get_collection_name(),
            'localField': 'job_id',
            'foreignField': '_id',
            'as': 'relation'
        }
    }, {
        "$match": {
            "relation.name": selected_job,
            "exploitability": "EXPLOITABLE",
            "date": {
                "$gte": date,
                "$lt": date + timedelta(days=1)
            }
        }
    }, {
        "$group": {
            "_id": "$crash_hash"
        }
    }])
    return unique_exploitable_crashes