Beispiel #1
0
 def __init__(self):
     self.central_widget = None
     self.scrollArea = None
     self.scrollAreaWidgetContents = None
     self.text_edit = None
     self.start_date = None
     self.analysis_tool_button = None
     self.label = None
     self.label_2 = None
     self.progressBar = None
     self.csv_button = None
     self.label_3 = None
     self.breadth_30 = None
     self.breadth_40 = None
     self.breadth_50 = None
     self.breadth_60 = None
     self.overall_breadth = None
     self.status_bar = None
     self.log_thread = None
     self.data_pull_thread = None
     self.pull_csv_thread = None
     self.check_boxes = None
     self.csv_thread = None
     self.local_path = const.local_desktop
     self.support = support.QuestionDashSupport()
    def change_dict_values(self):

        for question in cb.QuestionDashSupport().get_all_the_questions():
            question = question.replace("/",
                                        "_").replace(" ",
                                                     "_").replace("-", "_")
            self.numerator_dict[question] = {}
 def __init__(self):
     QtCore.QThread.__init__(self)
     self.log_path = c.Constants().log_path
     self.denominator_dict = {}
     self.xml_handler = None
     self.start_date = None
     self.numerator_dict = {}
     self.numerator_compare = None
     self.denominator_compare = None
     self.soc_map = cb.QuestionDashSupport().soc_code_map()
     self.zip_file_name = "Kayla Question Activation Counts.zip"
    def run(self):

        #print self.numerator_compare
        if int(self.numerator_compare) not in db.QuestionDashboardData(
        ).get_all_dates():
            if cb.QuestionDashSupport().future_date_check(self.start_date):
                self.post_analysis_tool_and_extract_data()
                self.run_log_file_data_extraction()
            else:
                self.update_string_progress.emit(
                    "You cannot run data for this month or for the future.")

        else:
            self.update_string_progress.emit(
                "This Data has been previously pulled.")
Beispiel #5
0
    def write_overall_to_file(self, writer):

        header = [
            'Date', 'Question', 'Active Profiles', 'Bailed 20', 'Saw 20',
            'Saw MyPayScale', 'Total Counts'
        ]
        writer.writerow(header)
        use_date = self.start_date.date().toPyDate().strftime("%Y%m")

        overall_dictionary = {}

        for question in cb.QuestionDashSupport().get_all_the_questions():

            data = db.QuestionDashboardData().pull_all_non_breadth_data(
                question, use_date)
            overall_dictionary[question] = {
                'Active Profile': 0,
                'Bailed 20': 0,
                'Saw 20': 0,
                'Saw MyPayScale': 0,
                'Total Counts': 0
            }
            date = None
            first = True
            for row in data:
                if first is True:
                    date = row[0]
                    overall_dictionary[question]['Active Profile'] += row[2]
                    overall_dictionary[question]['Bailed 20'] += row[3]
                    overall_dictionary[question]['Saw 20'] += row[4]
                    overall_dictionary[question]['Saw MyPayScale'] += row[5]
                    overall_dictionary[question]['Total Counts'] += row[6]
                    first = False
                else:
                    overall_dictionary[question]['Active Profile'] += row[2]
                    overall_dictionary[question]['Bailed 20'] += row[3]
                    overall_dictionary[question]['Saw 20'] += row[4]
                    overall_dictionary[question]['Saw MyPayScale'] += row[5]
                    overall_dictionary[question]['Total Counts'] += row[6]

            current = overall_dictionary[question]
            final = date, question, current['Active Profile'], current['Bailed 20'], current['Saw 20'], \
                current['Saw MyPayScale'], current['Total Counts']
            writer.writerow(final)
    def run_log_file_data_extraction(self):

        log_files = logs.CSVLogIterator(
            self.start_date.date().toPyDate(),
            self.last_datetime_day_of_month(self.start_date.date()))
        log_files.find_all_logs_survey()

        for current_file_number, log_file in enumerate(
                log_files.log_files_to_use):
            self.update_string_progress.emit("Working on " + log_file + "...")
            with open(self.log_path + log_file, 'rb') as R:
                reader = csv.reader(R, delimiter=',')
                header = reader.next()

                for row in reader:

                    saw_20 = row[header.index("Saw20")]
                    bailed_20 = row[header.index("Bailed20")]
                    saw_payscale = row[header.index("SawMyPayscale")]
                    profile_job = row[header.index("Profile job")]
                    try:
                        soc = self.soc_map[profile_job]
                    except KeyError:
                        soc = "N/A"
                    self.log_data_to_dictionary(row, header, saw_20, bailed_20,
                                                saw_payscale, soc)

            self.update_progress.emit(current_file_number + 1)

        self.update_string_progress.emit("Log File data completely gathered")
        self.update_string_progress.emit(
            "Placing log data and Analysis Tool data into database...")
        db.QuestionDashboardData().insert_data_from_dict_to_database(
            self.denominator_dict, self.numerator_dict,
            self.start_date.date().toPyDate().strftime("%Y%m"))

        self.update_string_progress.emit(
            "Filling up the different breadth x databases...")
        cb.QuestionDashSupport().fill_all_breadth_db(
            self.start_date.date().toPyDate().strftime("%Y%m"))

        self.update_string_progress.emit(
            "Log File and Analysis Tool work completed. Feel free to query away on the"
            "currently pulled months data.")
Beispiel #7
0
    def write_breadth_to_file(self, writer, breadth):

        header = [
            'Date', 'Question', breadth, 'Active Profiles', 'Bailed 20',
            'Saw 20', 'Saw MyPayScale', 'Total Counts'
        ]
        writer.writerow(header)

        for question in cb.QuestionDashSupport().get_all_the_questions():

            data = db.QuestionDashboardData().pull_breadth_x_data(
                question,
                self.start_date.date().toPyDate().strftime("%Y%m"), breadth)

            for row in data:
                final = row[0], question, row[1], row[2], row[3], row[4], row[
                    5], row[6]
                if row[1] != "":
                    writer.writerow(final)
    def log_data_to_dictionary(self, row, header, saw_20, bailed_20,
                               saw_payscale, soc):

        all_questions = cb.QuestionDashSupport().get_all_the_questions()

        for question in all_questions:
            try:
                field_shown = row[header.index(question)]
            except ValueError:
                field_shown = 'no_answer'

            if field_shown == 'Field Shown':
                self.data_to_dict(question, soc, 'total_shown')

            if saw_20.lower() == "true" and field_shown == 'Field Shown':
                self.data_to_dict(question, soc, 'saw_20')

            if bailed_20.lower() == 'true' and field_shown == 'Field Shown':
                self.data_to_dict(question, soc, 'bailed_20')

            if saw_payscale.lower() == 'true' and field_shown == 'Field Shown':
                self.data_to_dict(question, soc, 'saw_payscale')