fossasia / open-event-server

Consider using in PYL-R1714
Performance
Major
5 months ago4 years old
Consider merging these comparisons with 'in' by using 'order.status in ('completed', 'placed')'. Use a set instead if elements are hashable.
103        count = 0
104        for order_ticket in order_tickets:
105            order = Order.query.filter_by(id=order_ticket.order_id).first()
106            if order.status == "completed" or order.status == "placed":107                count += 1
108
109        return bool(count > 0)
Consider merging these comparisons with 'in' by using 'name in ('short_biography', 'long_biography', 'speaking_experience', 'sponsorship_required')'. Use a set instead if elements are hashable.
61
62    def __setattr__(self, name, value):
63        if (
64            name == 'short_biography'65            or name == 'long_biography'
66            or name == 'speaking_experience'
67            or name == 'sponsorship_required'
Consider merging these comparisons with 'in' by using 'name in ('short_abstract', 'long_abstract', 'comments')'. Use a set instead if elements are hashable.
135        return '<Session %r>' % self.title
136
137    def __setattr__(self, name, value):
138        if name == 'short_abstract' or name == 'long_abstract' or name == 'comments':139            super().__setattr__(name, clean_html(clean_up_string(value), allow_link=True))
140        else:
141            super().__setattr__(name, value)
Consider merging these comparisons with 'in' by using 'name in ('owner_description', 'description', 'code_of_conduct', 'after_order_message')'. Use a set instead if elements are hashable.
285    def __setattr__(self, name, value):
286        allow_link = name == 'description' or 'owner_description' or 'after_order_message'
287        if (
288            name == 'owner_description'289            or name == 'description'
290            or name == 'code_of_conduct'
291            or name == 'after_order_message'
Consider merging these comparisons with 'in' by using 'ticket.type in ('paid', 'donation')'. Use a set instead if elements are hashable.
250        :param view_kwargs:
251        :return:
252        """
253        if ticket.type == 'paid' or ticket.type == 'donation':254            try:
255                event = (
256                    db.session.query(Event)