<commit_before>import {
  Component,
  ComponentFactoryResolver,
  ViewRef,
  ChangeDetectorRef,
  Input,
  ViewChild,
  ViewContainerRef,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { FeedsService } from '../../../../common/services/feeds.service';
import { BoostConsoleType } from '../console.component';
import { Client } from '../../../../services/api';
import { Session } from '../../../../services/session';
import { BehaviorSubject, Observable } from 'rxjs';

/**
 * The component for the boost console.
 */
@Component({
  selector: 'm-boost-console-booster',
  templateUrl: 'booster.component.html',
})
export class BoostConsoleBooster {
  /* type of the feed to display */
  @Input('type') type: BoostConsoleType;

  /* poster component */
  @ViewChild('poster', { read: ViewContainerRef })
  poster: ViewContainerRef;

  feed$: Observable<BehaviorSubject<Object>[]>;
  componentRef;
  inProgress = true;
  loaded = false;
  noContent = true;

  constructor(
    public client: Client,
    public session: Session,
    private route: ActivatedRoute,
    public feedsService: FeedsService,
    private cd: ChangeDetectorRef,
    private componentFactoryResolver: ComponentFactoryResolver
  ) {}

  /**
   * subscribes to route parent url and loads component.
   */
  ngOnInit() {
    this.loaded = false;
    this.route.parent.url.subscribe(segments => {
      this.type = <BoostConsoleType>segments[0].path;
      this.load(true);
      this.loaded = true;
    });
  }

  /**
   * Loads the infinite feed for the respective parent route.
   * @param { boolean } refresh - is the state refreshing?
   */
  load(refresh?: boolean) {
    if (!refresh) {
      return;
    }

    if (refresh) {
      this.feedsService.clear();
    }

    this.inProgress = true;
    this.feedsService
      .setEndpoint(
        this.type === 'content'
          ? `api/v2/feeds/container/${this.session.getLoggedInUser().guid}/all`
          : `api/v2/feeds/container/${
              this.session.getLoggedInUser().guid
            }/activities`
      )
      .setParams({ sync: true })
      .setLimit(12)
      .fetch();
    this.feed$ = this.feedsService.feed;
    this.inProgress = false;
    this.loaded = true;
    this.feed$.subscribe(feed => (this.noContent = feed.length > 0));
  }

  /**
   * Loads next data in feed.
   * @param feed - the feed to reload.
   */
  loadNext() {
    if (
      this.feedsService.canFetchMore &&
      !this.feedsService.inProgress.getValue() &&
      this.feedsService.offset.getValue()<commit_msg>Request only objects for sidebar boost suggestions #4879<commit_after>import {
  Component,
  ComponentFactoryResolver,
  ViewRef,
  ChangeDetectorRef,
  Input,
  ViewChild,
  ViewContainerRef,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { FeedsService } from '../../../../common/services/feeds.service';
import { BoostConsoleType } from '../console.component';
import { Client } from '../../../../services/api';
import { Session } from '../../../../services/session';
import { BehaviorSubject, Observable } from 'rxjs';

/**
 * The component for the boost console.
 */
@Component({
  selector: 'm-boost-console-booster',
  templateUrl: 'booster.component.html',
})
export class BoostConsoleBooster {
  /* type of the feed to display */
  @Input('type') type: BoostConsoleType;

  /* poster component */
  @ViewChild('poster', { read: ViewContainerRef })
  poster: ViewContainerRef;

  feed$: Observable<BehaviorSubject<Object>[]>;
  componentRef;
  inProgress = true;
  loaded = false;
  noContent = true;

  constructor(
    public client: Client,
    public session: Session,
    private route: ActivatedRoute,
    public feedsService: FeedsService,
    private cd: ChangeDetectorRef,
    private componentFactoryResolver: ComponentFactoryResolver
  ) {}

  /**
   * subscribes to route parent url and loads component.
   */
  ngOnInit() {
    this.loaded = false;
    this.route.parent.url.subscribe(segments => {
      this.type = <BoostConsoleType>segments[0].path;
      this.load(true);
      this.loaded = true;
    });
  }

  /**
   * Loads the infinite feed for the respective parent route.
   * @param { boolean } refresh - is the state refreshing?
   */
  load(refresh?: boolean) {
    if (!refresh) {
      return;
    }

    if (refresh) {
      this.feedsService.clear();
    }

    this.inProgress = true;
    this.feedsService
      .setEndpoint(
        this.type === 'content'
          ? `api/v2/feeds/container/${
              this.session.getLoggedInUser().guid
            }/objects`
          : `api/v2/feeds/container/${
              this.session.getLoggedInUser().guid
            }/activities`
      )
      .setParams({ sync: true })
      .setLimit(12)
      .fetch();
    this.feed$ = this.feedsService.feed;
    this.inProgress = false;
    this.loaded = true;
    this.feed$.subscribe(feed => (this.noContent = feed.length > 0));
  }

  /**
   * Loads next data in feed.
   * @param feed - the feed to reload.
   */
  loadNext() {
    if (
      this.feedsService.canFetchMore &&
      !this.feedsService.inProgress.getValue() &&
      this.feedsService.offset.getValue()
{'fraction_non_alphanumeric': 0.14143158702744196, 'fraction_numerical': 0.003070427940894262, 'mean_word_length': 2.755043227665706, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2889477', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1555, 'n_words': 358}