<commit_before>'use strict'
const Firebase = require('firebase')
const ref = new Firebase("https://jelybean.firebaseio.com")
const postRef = new Firebase("https://jelybean.firebaseio.com/posts")
import React, {
  AsyncStorage,
} from 'react-native'

export default class JelyApi{
  // create a post
  static createPost(date, photo, location, activity){
    let userId = getUserId()
  	postRef.push().set({
  		date: date, 
  		location: location,
  		activity: activity,
  		userId: userId,
  	})
  }


  // retrieve all posts by a user
  static retrieveLatestPosts(){


  }

  static async retrieveMyPosts(){
    let userId = undefined
    try {
      userId = await JelyApi.getUserId()
    } catch (error) { alert(JSON.stringify(error)) }
    // alert(userId)
    //var ref = new Firebase("https://dinosaur-facts.firebaseio.com/dinosaurs");
postRef.orderByChild("userid").equalTo(userId).on("value", function(snapshot) {
  return snapshot.val()
})

  }

  // facebook login
  static storeUserInfo(token, userId){
    alert(token + ' : ' + userId)
    AsyncStorage.setItem("fbToken", token)
    AsyncStorage.setItem("fbUserId", userId)

  }

  static async getUserId(){
    const userId = await AsyncStorage.getItem('fbUserId')
    // alert(userId)
    return userId
  }

  static async getToken(){
    const token = await AsyncStorage.getItem('fbToken')
    alert(token)
    return token
  }

}
<commit_msg>retrieving posts<commit_after>'use strict'
const Firebase = require('firebase')
const ref = new Firebase("https://jelybean.firebaseio.com")
const postRef = new Firebase("https://jelybean.firebaseio.com/posts")
import React, {
  AsyncStorage,
} from 'react-native'

export default class JelyApi{
  // create a post
  static async createPost(actDate, photo, location, activity){
    let userId = await JelyApi.getUserId()
  	postRef.push({
  		activityDate: actDate, 
  		location: location,
  		activity: activity,
  		userId: userId,
      postDate: Date.now(),
      photo: photo
  	})
  }

  // Retrieve top 10 posts
  static retrieveLatestPosts(){
    let promise = new Promise((resolve) => {
      postRef.orderByChild("postDate").limitToLast(10).on("value", (snapshot)=>{
        resolve(snapshot.val())
      })
    })
    return promise
  }

  // Retrieve top 10 posts by a user
  static retrieveMyPosts(){
    let promise = new Promise((resolve) => {
      JelyApi.getUserId().then((userId)=>{
        postRef.orderByChild("userId").equalTo(userId).limitToLast(10).on("value", (snapshot)=> {
          resolve(snapshot.val())
        })
      })
    })
    return promise
  }

  static storeUserInfo(token, userId){
    alert(token + ' : ' + userId)
    AsyncStorage.setItem("fbToken", token)
    AsyncStorage.setItem("fbUserId", userId)
  }

  static async getUserId(){
    const userId = await AsyncStorage.getItem('fbUserId')
    return userId
  }

  static async getToken(){
    const token = await AsyncStorage.getItem('fbToken')
    return token
  }
}

{'fraction_non_alphanumeric': 0.1334453781512605, 'fraction_numerical': 0.002689075630252101, 'mean_word_length': 3.3700440528634363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 5, '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': '4861542', 'n_tokens_mistral': 947, 'n_tokens_neox': 956, 'n_words': 213}