コード例 #1
0
 def fill_log(self):
     self.list_log.clear()
     with open(self.app.LOG_ADMIN_FILENAME, 'r') as f:
         for i in f.readlines():
             dt = QDateTime.fromString(i.strip('\n'), date_time_format())
             if dt.isValid():
                 self.list_log.addItem(
                     QListWidgetItem(dt.toString(date_time_format())))
コード例 #2
0
    def update_list(self):
        que = self.w1.update()
        rows = self.cur.execute(que).fetchmany(self.count_rows_spin.value())
        self.list_order.clear()
        self.list_order_2.clear()
        for i in rows:
            dish_time_s = self.cur.execute(f'''select cooktime from dish 
                                                    where id = (select dishid from orderdish
                                                    where id = ({i[0]}))''').fetchone()[0]
            date_time_s = self.cur.execute(f'''select datetime from orderclient
                                              where id = {i[1]}''').fetchone()[0]
            dish_count = int(i[4])
            date_time = QDateTime.fromString(date_time_s, date_time_format())
            dish_time = QTime.fromString(dish_time_s, time_format())
            dish_time_minutes = dish_time.hour() * 60 + dish_time.minute() * dish_count
            dish_time = QTime(dish_time_minutes // 60, dish_time_minutes % 60)

            secs_passed = date_time.secsTo(QDateTime.currentDateTime())
            hms = [dish_time.hour() - secs_passed // 3600,
                   dish_time.minute() - secs_passed // 60 % 60,
                   59 - secs_passed % 60]
            time_last = QTime(*hms)
            if time_last.isValid():
                order = [time_last.toString(time_format() + ':ss'), *i[2:]]
            else:
                order = ['Done', *i[2:]]
            item = QListWidgetItem(' - '.join(map(str, order)))
            if not time_last.isValid():
                item.setBackground(QColor(255, 220, 220))
                self.list_order_2.addItem(item)
            else:
                self.list_order.addItem(item)
コード例 #3
0
def jsonify_admin_orders(data_dict):
    item_collection_id = data_dict['item_collection'].id
    order_dicts = []
    for order in data_dict['orders']:
        if (order.is_confirmed):
            order_dicts.append({
                'invoice_no': order.invoice_no,
                'id': order.id,
                'order_date': date_time_format(order.paid_at),
                'buyer_fullname': order.buyer_fullname,
                'buyer_email': order.buyer_email,
                'buyer_phone': order.buyer_phone,
                'currency': CURRENCY_SYMBOL['INR'],
                'amount': order.get_amounts(LINE_ITEM_STATUS.CONFIRMED).confirmed_amount,
                'url': '/ic/' + unicode(item_collection_id) + '/' + unicode(order.id),
                'receipt': url_for('receipt', access_token=order.access_token),
                'assignee': url_for('line_items', access_token=order.access_token)
            })
    return jsonify(org_name=data_dict['item_collection'].organization.name, title=data_dict['item_collection'].title, orders=order_dicts)
コード例 #4
0
def format_line_items(line_items):
    line_item_dicts = []
    for line_item in line_items:
        line_item_dicts.append({
            'title': line_item.item.title,
            'seq': line_item.line_item_seq,
            'id': line_item.id,
            'category': line_item.item.category.title,
            'description': line_item.item.description.text,
            'currency': CURRENCY_SYMBOL['INR'],
            'base_amount': line_item.base_amount,
            'discounted_amount': line_item.discounted_amount,
            'final_amount': line_item.final_amount,
            'discount_policy': line_item.discount_policy.title if line_item.discount_policy else "",
            'discount_coupon': line_item.discount_coupon.code if line_item.discount_coupon else "",
            'cancelled_at': date_time_format(line_item.cancelled_at) if line_item.cancelled_at else "",
            'assignee_details': format_assignee(line_item.current_assignee),
            'cancel_ticket_url': url_for('cancel_line_item', line_item_id=line_item.id) if line_item.is_cancellable() else ""
        })
    return line_item_dicts
コード例 #5
0
    }

    model_user_embeddings, model_item_embeddings = sess.run(
        [model.user_emb, model.item_emb], feed_dict=feed_dict)

    train_embs = []
    train_labels = []
    for user_node, item_node in zip(u_list_train, i_list_train):
        train_embs.append(
            np.multiply(model_user_embeddings[user_node],
                        model_item_embeddings[item_node]))
    train_labels = y_list_train
    classifier = LogisticRegression(solver='liblinear',
                                    n_jobs=-1,
                                    verbose=1,
                                    tol=1e-7)
    classifier.fit(train_embs, train_labels)

    f1, acc, auc_roc, auc_pr, precision, recall, tp, fp, tn, fn = link_prediction(
        sess, model, u_list_test, i_list_test, y_list_test)
    print('{}|{}|{}|{}|{}|{}|{}|{}|{}|{}'.format(
        str(utils.round_up_4(float(f1))), str(utils.round_up_4(float(acc))),
        str(utils.round_up_4(float(auc_roc))),
        str(utils.round_up_4(float(auc_pr))),
        str(utils.round_up_4(float(precision))),
        str(utils.round_up_4(float(recall))), tp, fp, tn, fn))
    print(
        '{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}'.format(
            f1, acc, auc_roc, auc_pr, precision, recall, tp, fp, tn, fn),
        utils.date_time_format())
    sess.close()
コード例 #6
0
 def __init__(self, name, correct=None, enabled=True, default=None):
     super().__init__(name, QDateTimeEdit, correct, enabled, default)
     self.format = date_time_format()
コード例 #7
0
 def add_log(self):
     with open(self.app.LOG_ADMIN_FILENAME, 'a') as f:
         f.write(QDateTime.currentDateTime().toString(date_time_format()))
         f.write('\n')
     self.fill_log()