<commit_before>import { Injectable } from '@angular/core';
import {ActivityList} from '../store'
import { ApiService } from './api';
import 'rxjs/Rx';
import { StoreHelper } from './store-helper';

@Injectable()
export class ActivityService {
  path: string = '/api/activities';
  constructor(
    private apiService: ApiService,
    private storeHelper: StoreHelper
  ) {}

  createActivity(activity) {
    return this.apiService.post(this.path, activity)
      .do(savedActivity => this.storeHelper.add('activities', savedActivity));
  }

  getActivities() {
    return this.apiService.get(this.path)
      .do(res => this.storeHelper.update('activities', res));
  }

  getUserActivities(userId) {
    return this.getActivities()
      .map(activities => activities.filter(d => d.author._id === userId))


  }

  getActivity(id) {
    return this.getActivities()
      .map(activities => activities.find(d => d._id === id));

  }
  completeActivity(activity: ActivityList) {
    return this.apiService.put(`${this.path}/${activity._id}`, activity)
      .do(res => this.storeHelper.findAndDelete('activities', res._id));

  }
  deleteActivity(activity: ActivityList) {
    return this.apiService.delete(`${this.path}/${activity._id}`)
      .do(res => this.storeHelper.findAndDelete('activities', res._id));

  }
}
<commit_msg>adds events() to activities service<commit_after>import { Injectable } from '@angular/core';
import {ActivityList} from '../store'
import { ApiService } from './api';
import 'rxjs/Rx';
import { StoreHelper } from './store-helper';

@Injectable()
export class ActivityService {
  path: string = '/api/activities';
  constructor(
    private apiService: ApiService,
    private storeHelper: StoreHelper
  ) {}

  createActivity(activity) {
    return this.apiService.post(this.path, activity)
      .do(savedActivity => this.storeHelper.add('activities', savedActivity));
  }

  getActivities() {
    return this.apiService.get(this.path)
      .do(res => this.storeHelper.update('activities', res));
  }

  getEvents() {
    return this.apiService.get(this.path)
      .do(res => this.storeHelper.update('activities', res));
  }

  getUserActivities(userId) {
    return this.getActivities()
      .map(activities => activities.filter(d => d.author._id === userId))


  }

  getActivity(id) {
    return this.getActivities()
      .map(activities => activities.find(d => d._id === id));

  }
  completeActivity(activity: ActivityList) {
    return this.apiService.put(`${this.path}/${activity._id}`, activity)
      .do(res => this.storeHelper.findAndDelete('activities', res._id));

  }
  deleteActivity(activity: ActivityList) {
    return this.apiService.delete(`${this.path}/${activity._id}`)
      .do(res => this.storeHelper.findAndDelete('activities', res._id));

  }
}

{'fraction_non_alphanumeric': 0.16042780748663102, 'fraction_numerical': 0.0, 'mean_word_length': 3.948853615520282, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '1769816', 'n_tokens_mistral': 878, 'n_tokens_neox': 868, 'n_words': 158}