Annote the queryset with an 'is_active' property that's true iff that row is the most
        recently added row for that particular set of KEY_FIELDS values.
        Filter the queryset to show only is_active rows by default.
558100
def get_queryset(self, request):
        
        if request.GET.get(ShowHistoryFilter.parameter_name) == '1':
            queryset = self.model.objects.with_active_flag()
        else:
            # Show only the most recent row for each key.
            queryset = self.model.objects.current_set()
        ordering = self.get_ordering(request)
        if ordering:
            return queryset.order_by(*ordering)
        return queryset
1206803
def __check_existing(self, row):
        
        if self.__update_keys is not None:
            key = tuple(row[key] for key in self.__update_keys)
            if key in self.__bloom:
                return True
            self.__bloom.add(key)
            return False
        return False
386283
protected function checkActiveField()
    {
        //check product "active" field
        if (!$this->isFieldChanged('active')) {
            return;
        }

        ProductListStore::instance()->active->clear();

        $this->clearCategoryProductCount($this->obElement->category_id);

        //Get additional category ID list
        $arAdditionalCategoryIDList = $this->obElement->additional_category->lists('id');
        if (empty($arAdditionalCategoryIDList)) {
            return;
        }

        foreach ($arAdditionalCategoryIDList as $iCategoryID) {
            $this->clearCategoryProductCount($iCategoryID);
        }
    }
519445
def is_active(self):
    """"""
    if self._db_connection_provider:
      # The plugin is active if one relevant tag can be found in the database.
      db = self._db_connection_provider()
      cursor = db.execute('''
        SELECT
          1
        FROM Tags
        WHERE Tags.plugin_name = ?
        LIMIT 1
      ''', (metadata.PLUGIN_NAME,))
      return bool(list(cursor))

    return bool(self._multiplexer) and any(self.index_impl().values())
175706
def is_active(self, key, *instances, **kwargs):
        
        try:
            default = kwargs.pop('default', False)

            # Check all parents for a disabled state
            parts = key.split(':')
            if len(parts) > 1:
                child_kwargs = kwargs.copy()
                child_kwargs['default'] = None
                result = self.is_active(':'.join(parts[:-1]), *instances,
                                        **child_kwargs)

                if result is False:
                    return result
                elif result is True:
                    default = result

            try:
                switch = self[key]
            except KeyError:
                # switch is not defined, defer to parent
                return default

            if switch.status == GLOBAL:
                return True
            elif switch.status == DISABLED:
                return False
            elif switch.status == INHERIT:
                return default

            conditions = switch.value
            # If no conditions are set, we inherit from parents
            if not conditions:
                return default

            instances = list(instances) if instances else []
            instances.extend(self.context.values())

            # check each switch to see if it can execute
            return_value = False

            for namespace, condition in conditions.iteritems():
                condition_set = registry_by_namespace.get(namespace)
                if not condition_set:
                    continue
                result = condition_set.has_active_condition(condition,
                                                            instances)
                if result is False:
                    return False
                elif result is True:
                    return_value = True
        except:
            log.exception('Error checking if switch "%s" is active', key)
            return_value = False

        # there were no matching conditions, so it must not be enabled
        return return_value
1088743
def apply_filters(self, queryset, applicable_filters=None, applicable_exclusions=None):
        
        for field, options in applicable_filters["field_facets"].items():
            queryset = queryset.facet(field, **options)

        for field, options in applicable_filters["date_facets"].items():
            queryset = queryset.date_facet(field, **options)

        for field, options in applicable_filters["query_facets"].items():
            queryset = queryset.query_facet(field, **options)

        return queryset
1131705
def is_flagged(self, user=None, status=None):
        
        filter_kwargs = {
            'content_type': ContentType.objects.get_for_model(self),
            'object_id': self.id,
        }
        update_filter_dict(filter_kwargs, user, status)
        return self.flags.filter(**filter_kwargs).count()
846617
def _filter_rows_keys(self):
        
        return [
            row_key
            for row_key in self.message.rows.row_keys
            if row_key > self.last_scanned_key
        ]
82790
function queryIsActive(query, activeQuery) {
  if (activeQuery == null)
    return query == null

  if (query == null)
    return true

  return deepEqual(query, activeQuery)
}
1323012
def is_active(self):
    
    if not self._multiplexer:
      return False

    scalars_plugin_instance = self._get_scalars_plugin()
    if not (scalars_plugin_instance and
            scalars_plugin_instance.is_active()):
      return False

    # This plugin is active if any run has a layout.
    return bool(self._multiplexer.PluginRunToTagToContent(metadata.PLUGIN_NAME))
568498
def build_filtered_queryset(self, query, **kwargs):
        
        # Take the basic queryset
        qs = self.get_queryset()
        # filter it via the query conditions
        qs = qs.filter(self.get_queryset_filters(query))
        return self.build_extra_filtered_queryset(qs, **kwargs)
755117
def last_edited_by_column(self, obj):
        
        latest_logentry = admin.models.LogEntry.objects.filter(
            object_id=obj.pk,
            content_type_id=self._get_obj_ct(obj).pk,
            action_flag__in=[admin.models.ADDITION, admin.models.CHANGE],
        ).first()
        if latest_logentry:
            return latest_logentry.user
        else:
            return None
786923
void onCategorySelected(String columnId, int row) {
        Integer maxSelections = displayerSettings.isFilterSelfApplyEnabled() ? null : dataSet.getRowCount();
        filterUpdate(columnId, row, maxSelections);

        // Update the displayer in order to reflect the current selection
        // (only if not has already been redrawn in the previous filterUpdate() call)
        if (!displayerSettings.isFilterSelfApplyEnabled()) {
            updateVisualization();
        }
    }
589723
def most_recent(self):
        
        if not self.instance:
            raise TypeError(
                "Can't use most_recent() without a {} instance.".format(
                    self.model._meta.object_name
                )
            )
        tmp = []
        excluded_fields = getattr(self.model, "_history_excluded_fields", [])

        for field in self.instance._meta.fields:
            if field.name in excluded_fields:
                continue
            if isinstance(field, models.ForeignKey):
                tmp.append(field.name + "_id")
            else:
                tmp.append(field.name)
        fields = tuple(tmp)
        try:
            values = self.get_queryset().values_list(*fields)[0]
        except IndexError:
            raise self.instance.DoesNotExist(
                "%s has no historical record." % self.instance._meta.object_name
            )
        return self.instance.__class__(*values)
1023275
def filter(self, *args, **kwargs):
		""""""
		if 'pk' in kwargs or 'id' in kwargs:
			return self.all_with_deleted().filter(*args, **kwargs)
		return self.get_query_set().filter(*args, **kwargs)
331250
def index_queryset(self, using=None):
        """"""

        kwargs = {"active": True}

        # if permissions are enabled then we want only public pages
        # https://github.com/leonardo-modules/leonardo-module-pagepermissions
        if hasattr(Page(), 'permissions'):
            kwargs['permissions__isnull'] = True

        # https://github.com/leonardo-modules/leonardo-page-search
        if hasattr(Page(), 'search_exclude'):
            kwargs['search_exclude'] = False

        return self.get_model().objects.filter(**kwargs)
406005
def recent_articles(limit=10, exclude=None):
    """"""
    queryset = Article.objects.filter(published=True).order_by('-modified')
    if exclude:
        if hasattr(exclude, '__iter__'):
            queryset = queryset.exclude(pk__in=exclude)
        else:
            queryset = queryset.exclude(pk=exclude)
    return queryset