Example #1
0
 Meteor.publish("commonareas.details", function(commonareaId) {
   if (!this.userId) return null;
   let user = Meteor.users.findOne(this.userId);
   return [
     CommonAreas.find(commonareaId),
     CommonAreasSchedules.find({commonareaId: commonareaId, status: "open"}),
     Meteor.users.find({buildingId: user.buildingId}),
   ];
 });
  Meteor.publish( 'connectedMembers', function( memberNameArray ) {
    check( memberNameArray, Match.OneOf( Array, null, undefined ) );

    let projection = 
        {
          fields: 
          {
            name: 1,
            city: 1,
            "profile.description": 1,
            accountType: 1,
            lat: 1,
            lng: 1,
            network: 1,
          }
        };


    if (memberNameArray.length > 0)
    { 
      query = { name: 
        {
          $in: memberNameArray
        }
      }
      // example of finished query
      //{ city: { $in: ['San Luis Obispo', 'Avila'] } } 
    };
    
    return NetworkMembers.find( query, projection );
  });
  Meteor.publish( 'networkSearch', function( search ) {
    check( search, Match.OneOf( Array, null, undefined ) );

    let query      = {},
        projection = 
        {
          fields: 
          {
            name: 1,
            city: 1,
            "profile.description": 1,
            accountType: 1,
            lat: 1,
            lng: 1,
            network: 1,
          }
        };

    if (search.length > 0)
    { 
      query = { accountType: 
        {
          $in: search
        }
      }
      // example of finished query
      //{ city: { $in: ['San Luis Obispo', 'Avila'] } } 
    };
    
    return NetworkMembers.find( query, projection );
  });
Example #4
0
 Meteor.publish('tasks', function tasksPublication() {
   return Tasks.find({
     $or: [
       { private: { $ne: true } },
       { owner: this.userId },
     ],
   });
 });
Example #5
0
	Meteor.publish('lists', function listsPublication() {
		return Lists.find({
			$or: [
				{private: { $ne: true}},
				{owner: this.userId},
			],
		});
	});
Example #6
0
File: main.js Project: diepv/ds_hp
function setLinks(){
    //1. get node array
    console.log('setting nodelinks');

    var nodeArray = Nodes.find({totalViews:{$gt:5000}},{limit:300, sort:{totalViews:-1}});
    var rNodes = nodeArray.fetch();
    if(nodeArray.count()>1){
        RelevantNodes.remove({});
        rNodes.forEach(function(nodeEntry, index){
            RelevantNodes.insert(nodeEntry);
        });
        //2. get links :)
        var rNodes = RelevantNodes.find();
        getLinks(rNodes, function(done){
            console.log('finished getting links');
        });
    }

}
Example #7
0
  Meteor.publish('SubmissionsForCurrentUser', function() {
    if (!this.userId) {
      throw new Meteor.Error(403, 'User must be logged in.');
    }
    if (!Roles.userIsInRole(this.userId, 'contestant')) {
      throw new Meteor.Error(403, 'User is not a contestant.');
    }

    return Submissions.find({userId: this.userId},
        {fields: {submissionFileUri: false}});
  });
Example #8
0
Router.route('/nodeinfo', function () {
  var req = this.request;
  var res = this.response;
  if (Contract.find().count()==0){
    res.end("");
  }
  else{
    var enode = Enode.findOne().enode;
    res.end(enode);
  }
}, {where: 'server'});
Example #9
0
Router.route('/contractinfo', function () {
  var req = this.request;
  var res = this.response;
  if (Contract.find().count()==0){
    res.end("");
  }
  else{
    var contractaddress = Contract.findOne().address;
    res.end(contractaddress);
  }
}, {where: 'server'});
 find: function() {
   return Questions.find({}, {
     fields: {
       userId: 1,
       text: 1,
       likes: 1,
       commentsCount: 1,
       solvedAt: 1
     }
   });
 },
Example #11
0
 Meteor.publish( "attacker-details", function( attackerid ) {
     return attackers.find( { '_id': attackerid },
         {
             fields: {
                 events: { $slice: -20 },
                 alerts: { $slice: -10 }
             },
             sort: { 'events.documentsource.utctimestamp': -1 },
             reactive: false
         }
     );
 } );
	Meteor.publish("allLeitner", function () {
		if (this.userId) {
			if (Roles.userIsInRole(this.userId, [
				'admin',
				'editor'
			])) {
				return Leitner.find();
			}
		} else {
			this.ready();
		}
	});
Example #13
0
File: main.js Project: diepv/ds_hp
        Fiber(function(){
            //filter stores the parameters for the find() on MongoCollection

            //1. get nodes according the filter
                var retrievedNodes = Nodes.find(filtera, filterb);
            var rNodes = retrievedNodes.fetch();
            if(retrievedNodes.count()>1) {
                console.log('retrieved nodes: ', retrievedNodes.count());
                RelevantNodes.remove({});
                retrievedNodes.forEach(function (n) {
                    RelevantNodes.insert(n);
                });
                console.log('reset nodes - complete');
                getLinks(RelevantNodes.find(), function (d) {
                    console.log('reset links- complete');
                });

                //2. get links wit hthe given nodeset
                //3. return data :D
            }
        }).run();
  PublishRelations(publish, function () {
    this.cursor(quotes.find(), function (id, doc) {
      this.cursor(products.find({quoteId: id}), function (prodId, prod) {
        var prodInfo = this.changeParentDoc(productsInfo.find({prodId: prodId}), function (prodInfoId, prodInfo) {
          return prodInfo;
        });

        prod.color = prodInfo.color;
        prod.info = prodInfo.info;
      });
    });
  });
Example #15
0
  blockRemove: function(blockId) {
    var blockToRemove = Blocks.findOne({
      _id: blockId
    });
    var parentBlock = Blocks.findOne({
      _id: blockToRemove.parentId
    });

    Blocks.find({
      parentId: parentBlock._id
    }).forEach(function(element) {
      if (element.index > blockToRemove.index) {
        Blocks.update({
          _id: element._id
        }, {
          $set: {
            index: element.index - 1
          }
        });
      }
    });

    if (blockToRemove.isParent) {
      Blocks.find({
        parentId: blockId
      }).forEach(function(element) {
        Blocks.remove({
          _id: element._id
        });
      });
    }

    Blocks.remove({
      _id: blockId
    });

    Meteor.call('estimationUpdate', blockToRemove.estimationId, {
      dateUpdated: new Date()
    });
  },
Example #16
0
 Meteor.publish( "attackers-summary", function() {
     //limit to the last 100 records by default
     //to ease the sync transfer to dc.js/crossfilter
     return attackers.find( {},
         {
             fields: {
                 events: 0,
                 alerts: 0,
             },
             sort: { lastseentimestamp: -1 },
             limit: 100
         } );
 } );
	Meteor.publish("repetitoriumCardsets", function () {
		if (this.userId && UserPermissions.isNotBlockedOrFirstLogin()) {
			if (UserPermissions.isAdmin()) {
				return Cardsets.find({shuffled: true});
			} else {
				return Cardsets.find({
					$or: [
						{owner: this.userId, shuffled: true},
						{kind: {$in: ['free', 'edu', 'pro']}, shuffled: true}
					]
				});
			}
		} else if (UserPermissions.isNotBlockedOrFirstLogin() && ServerStyle.isLoginEnabled("guest")) {
			if (ServerStyle.isLoginEnabled("pro")) {
				return Cardsets.find({kind: {$in: ['free', 'pro']}, shuffled: true});
			} else {
				return Cardsets.find({kind: {$in: ['free']}, shuffled: true});
			}
		} else {
			this.ready();
		}
	});
Example #18
0
      function(contestId, taskId) {
    if (!this.userId) {
      throw new Meteor.Error(403, 'User must be logged in.');
    }
    if (!Roles.userIsInRole(this.userId, 'contestant')) {
      throw new Meteor.Error(403, 'User is not a contestant.');
    }

    const counterName = `submission_counter_${contestId.valueOf()}_` +
        `${taskId.valueOf()}`;

    // Taken from http://docs.meteor.com/api/pubsub.html .
    var self = this;
    var count = 0;
    var initializing = true;

    // observeChanges only returns after the initial `added` callbacks
    // have run. Until then, we don't want to send a lot of
    // `self.changed()` messages - hence tracking the
    // `initializing` state.
    var handle = Submissions.find({
      userId: this.userId,
      contestId: contestId,
      taskId: taskId,
    }).observeChanges({
      added: function (id) {
        count++;
        if (!initializing)
          self.changed("counts", counterName, {count: count});
      },
      removed: function (id) {
        count--;
        self.changed("counts", counterName, {count: count});
      }
      // We don't care about changed.
    });

    // Instead, we'll send one `self.added()` message right after
    // observeChanges has returned, and mark the subscription as
    // ready.
    initializing = false;
    self.added("counts", counterName, {count: count});
    self.ready();

    // Stop observing the cursor when client unsubs.
    // Stopping a subscription automatically takes
    // care of sending the client any removed messages.
    self.onStop(function () {
      handle.stop();
    });
  });
Example #19
0
      'SubmissionsForCurrentParticipationAndTask', function(contestId, taskId) {
    if (!this.userId) {
      throw new Meteor.Error(403, 'User must be logged in.');
    }
    if (!Roles.userIsInRole(this.userId, 'contestant')) {
      throw new Meteor.Error(403, 'User is not a contestant.');
    }

    return Submissions.find({
      userId: this.userId,
      contestId: contestId,
      taskId: taskId,
    }, {fields: {submissionFileUri: false}});
  });
 Meteor.publish('CarnageArena', function carnageArenaPublication() {
   return CarnageArena.find({}, { fields: {
     matchId: 1,
     player: 1,
     totalKills: 1,
     totalAssists: 1,
     totalDeaths: 1,
     totalShotsLanded: 1,
     totalShotsFired: 1,
     totalPowerWeaponGrabs: 1,
     killedOpponentDetails: 1,
     killedByOpponentDetails: 1,
   } });
 });
	Meteor.publish("tags", function () {
		let universityFilter = null;
		if (Meteor.settings.public.university.singleUniversity) {
			universityFilter = Meteor.settings.public.university.default;
		}
		return Cardsets.find({college: {$ifNull: [universityFilter, {$exists: true}]}}, {
			fields: {
				_id: 1,
				name: 1,
				quantity: 1,
				kind: 1
			}
		});
	});
	Meteor.publish("editShuffleCardsets", function (cardset_id) {
		if (this.userId && UserPermissions.isNotBlockedOrFirstLogin()) {
			if (UserPermissions.isAdmin()) {
				return Cardsets.find({
					$or: [
						{_id: cardset_id},
						{shuffled: false}
					]
				});
			} else {
				return Cardsets.find(
					{
						$or: [
							{_id: cardset_id},
							{owner: this.userId, shuffled: false},
							{kind: {$in: ['free', 'edu', 'pro']}, shuffled: false}
						]
					});
			}
		} else {
			this.ready();
		}
	});
Example #23
0
 Meteor.publish('messages', function () {
     return Messages.find(
         {},
         { fields: {
             avatar: 1,
             body: 1,
             created: 1,
             email: 1,
             screenName: 1,
             userId: 1,
             userName: 1
         }}
     );
 })
Example #24
0
 Meteor.publish('tours', function toursPublication(search) {
     let query = {},
     projection = {limit: 10, sort: {tourName: 1}};
     if (search) {
         let reges = new RegExp(search, 'i');
         
         query = {
             $or: [
                 {tourName: regex}
             ]
         };
         projection.limit = 20;
     }
     return Tours.find(query, projection);
 });
    this.cursor(quotes.find(), function (id, doc) {
      var productsCursor = products.find({quoteId: id});

      this.observe(productsCursor, {
        added: function (doc) {
          test.equal(doc.name, names[doc.price / 1000]);
        }
      });

      this.observeChanges(productsCursor, {
        added: function (prodId, doc) {
          test.equal(doc.name, names[doc.price / 1000]);
        }
      });
    });
	Meteor.publish("userCardsetLeitner", function (cardset_id, user_id) {
		if (this.userId) {
			if (this.userId === user_id || Roles.userIsInRole(this.userId, [
				'admin',
				'editor',
				'lecturer'
			])) {
				return Leitner.find({cardset_id: cardset_id, user_id: user_id});
			} else {
				this.ready();
			}
		} else {
			this.ready();
		}
	});
	Meteor.publish("cardsetWorkload", function (cardset_id) {
		if (this.userId) {
			if (Roles.userIsInRole(this.userId, [
				'admin',
				'editor',
				'lecturer'
			])) {
				return Workload.find({
					cardset_id: cardset_id,
					$or: [
						{user_id: this.userId},
						{'leitner.bonus': true}
					]
				});
			} else {
				return Workload.find({
					cardset_id: cardset_id,
					user_id: this.userId
				});
			}
		} else {
			this.ready();
		}
	});
Example #28
0
    function playerPublication(playerID) {
      check(playerID, Match.Maybe(String));

      // let restrictedFields = {
      //   "_id": 0,
      // };

      return Players.find(
        {
          _id: playerID,
        },
        // {
        //   fields: restrictedFields,
        // }
      );
    }
Example #29
0
 Meteor.publish('profiles', function () {
     return Profiles.find(
         {},
         { fields: {
             userId: 1,
             address: 1, city: 1, state: 1, zipcode: 1,
             admin: 1,
             avatar: 1,
             screenName: 1, fullName: 1,
             phone: 1,
             offerNotify: 1, requestNotify: 1,
             offerNotifySMS: 1, requestNotifySMS: 1,
             emailVisible: 1
         }}
     );
 })
Example #30
0
File: log.js Project: schuel/hmmm
Log.findFilter = function(filter, limit) {
	check(filter,
		{ start: Match.Optional(Date)
		, rel: Match.Optional([String])
		, tr: Match.Optional([String])
		}
	);
	check(limit, Number);

	const query = {};
	if (filter.start) query.ts = { $lte: filter.start };
	if (filter.rel) query.$or = [ { _id: { $in: filter.rel} }, { rel: { $in: filter.rel } } ];
	if (filter.tr) query.tr = { $in: filter.tr };

	return Log.find(query, { sort: { ts: -1 }, limit: limit });
};