コード例 #1
0
 def __activities__(self):
     Activity = Activate.get_activity()
     query_filter = self.join_self_activities()
     return InstrumentedList(Activity.query.filter(query_filter) \
                                           .order_by(Activity.dateCreated) \
                                           .order_by(Activity.id) \
                                           .all())
コード例 #2
0
 def __lastActivity__(self):
     Activity = Activate.get_activity()
     query_filter = (self.join_self_activities()) & \
                    (Activity.verb == 'update')
     return Activity.query.filter(query_filter) \
                          .order_by(desc(Activity.id)) \
                          .limit(1) \
                          .one()
コード例 #3
0
    def just_before_activity_from(self, activity):
        Activity = Activate.get_activity()
        query_filter = (self.join_self_activities()) & \
                       (Activity.dateCreated < activity.dateCreated)

        before_activity = Activity.query.filter(query_filter) \
                                  .order_by(desc(Activity.dateCreated)) \
                                  .first()
        if before_activity is None:
            raise JustBeforeActivityNotFound(
                f'Failed to find an activity just before that one {vars(activity)}'
            )
        return before_activity
コード例 #4
0
 def _get_activity_join_by_entity_id_filter(self):
     Activity = Activate.get_activity()
     id_key = self.__class__.id.property.key
     id_value = getattr(self, id_key)
     if id_value is None:
         errors = IdNoneError()
         errors.add_error(
             '_get_activity_join_by_entity_id_filter',
             f'tried to filter with a None id value for a {self.__class__.__name__} entity'
         )
         raise errors
     return ((Activity.old_data[id_key].astext.cast(BigInteger) == id_value) | \
             (Activity.changed_data[id_key].astext.cast(BigInteger) == id_value))
コード例 #5
0
 def __insertActivity__(self):
     Activity = Activate.get_activity()
     query_filter = (self.join_self_activities()) & \
                    (Activity.verb == 'insert')
     return Activity.query.filter(query_filter).one()
コード例 #6
0
 def __deleteActivity__(self):
     Activity = Activate.get_activity()
     query_filter = ((self.join_self_activities()) & \
                     (Activity.verb == 'delete'))
     return Activity.query.filter(query_filter).one()
コード例 #7
0
 def join_self_activities(self):
     Activity = Activate.get_activity()
     return ((Activity.table_name == self.__tablename__) & \
             (self._get_activity_join_by_entity_id_filter()))