Advertisement
Guest User

Untitled

a guest
Sep 16th, 2015
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Array.prototype.random = function(size, max) {
  2.     for (var i = 0; i < size; i++) {
  3.         var r = Math.floor((Math.random() * max) + 1);
  4.         this.push(r);
  5.     }
  6.  
  7.     return this;
  8. };
  9.  
  10. Parse.Cloud.define("firstTimeQuery", function(request, response)  {
  11.  
  12. var maxIndex = 91811;
  13. var maxWomenIndex = 135354;
  14. var maxMenIndex = 105357;
  15. var arrayOfRandomNumbers;
  16. var gender = request.params.gender;
  17. var query = new Parse.Query("garmentsAPI");
  18.  
  19.     if (gender === 'Female' || gender === 'women') {
  20.         arrayOfRandomNumbers = [].random(35, maxWomenIndex);
  21.  
  22.         query.containedIn("womenIndex", arrayOfRandomNumbers);
  23.         query.containedIn('gender', ['Female', 'women']);
  24.         query.notEqualTo("viewers", request.params.user);
  25.  
  26.         console.log('female');
  27.  
  28.     }else if (gender === 'Male' || gender === 'men') {
  29.         arrayOfRandomNumbers = [].random(35, maxMenIndex);
  30.  
  31.         query.containedIn("menIndex", arrayOfRandomNumbers);
  32.         query.containedIn('gender', ['Male', 'men']);
  33.         query.notEqualTo("viewers", request.params.user);
  34.  
  35.         console.log('male');
  36.  
  37.     }else{
Advertisement
RAW Paste Data Copied
Advertisement