<commit_before>package main

import (
  apns "github.com/anachronistic/apns"

  "gopkg.in/mgo.v2"
  "gopkg.in/mgo.v2/bson"
)

func getiOSUsers(user string) []NotificationUser {
  session, _ := mgo.Dial("127.0.0.1")
  defer session.Close()
  session.SetMode(mgo.Monotonic, true)
  db := session.DB("insapp").C("notification_user")
  var result []NotificationUser
  if user == "" {
      db.Find(bson.M{"os": "iOS"}).All(&result)
  }else{
    db.Find(bson.M{"os": "iOS", "userid": user}).All(&result)
  }
  return result
}

func getOSForUser(user bson.ObjectId) string {
  session, _ := mgo.Dial("127.0.0.1")
  defer session.Close()
  session.SetMode(mgo.Monotonic, true)
  db := session.DB("insapp").C("notification_user")
  var result NotificationUser
  db.Find(bson.M{"userid": user}).One(&result)
  return result.Os
}

func TriggerNotificationForUser(sender bson.ObjectId, receiver bson.ObjectId, content bson.ObjectId, message string, comment Comment){
  notification := Notification{Sender: sender, Content: content, Message: message, Comment: comment, Type: "tag"}
  if getOSForUser(receiver) == "iOS"{
    user := getiOSUsers(receiver.Hex())
    triggeriOSNotification(notification, user)
  }
  // if getOSForUser(receiver) == "Android"{
  //   triggerAndroidNotification(notification)
  // }
}

func TriggerNotificationForEvent(sender bson.ObjectId, content bson.ObjectId, message string){<commit_msg>Fix bug with Notifications history<commit_after>package main

import (
  apns "github.com/anachronistic/apns"

  "gopkg.in/mgo.v2"
  "gopkg.in/mgo.v2/bson"
)

func getiOSUsers(user string) []NotificationUser {
  session, _ := mgo.Dial("127.0.0.1")
  defer session.Close()
  session.SetMode(mgo.Monotonic, true)
  db := session.DB("insapp").C("notification_user")
  var result []NotificationUser
  if user == "" {
      db.Find(bson.M{"os": "iOS"}).All(&result)
  }else{
    db.Find(bson.M{"os": "iOS", "userid": user}).All(&result)
  }
  return result
}

func getNotificationUserForUser(user bson.ObjectId) NotificationUser {
  session, _ := mgo.Dial("1192.168.3.11")
  defer session.Close()
  session.SetMode(mgo.Monotonic, true)
  db := session.DB("insapp").C("notification_user")
  var result NotificationUser
  db.Find(bson.M{"userid": user}).One(&result)
  return result
}

func TriggerNotificationForUser(sender bson.ObjectId, receiver bson.ObjectId, content bson.ObjectId, message string, comment Comment){
  notification := Notification{Sender: sender, Content: content, Message: message, Comment: comment, Type: "tag"}
  user := getNotificationUserForUser(receiver)
  if user.Os == "iOS" {
    triggeriOSNotification(notification, []NotificationUser{user})
  }
  // if getOSForUser(receiver) == "Android"{
  //   triggerAndroidNotification(notification)
  // }
}

func TriggerNotificationForEvent(sender bson.ObjectId, content bson.ObjectId, message string){
{'fraction_non_alphanumeric': 0.152, 'fraction_numerical': 0.011130434782608696, 'mean_word_length': 4.857433808553972, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1045755', 'n_tokens_mistral': 1019, 'n_tokens_neox': 983, 'n_words': 187}