Sfoglia il codice sorgente

re-added and fixed 'reset ratings'

Akira Laine 9 anni fa
parent
commit
91c544e775
3 ha cambiato i file con 8 aggiunte e 11 eliminazioni
  1. 3 0
      app/client/scripts/events.js
  2. 3 0
      app/client/templates/admin.html
  3. 2 11
      app/server/server.js

+ 3 - 0
app/client/scripts/events.js

@@ -210,6 +210,9 @@ Template.admin.events({
         var target = $(e.target);
         var id = $(e.target).data("id") || target.parent().data("id");
         Meteor.call("deleteAlert", id);
+    },
+    "click #rrating": function(){
+        Meteor.call("resetRating");
     }
 });
 

+ 3 - 0
app/client/templates/admin.html

@@ -35,6 +35,9 @@
                         Add Room
                     </a>
                 </div>
+                <div class="row">
+                    <a class="waves-effect waves-light btn col m12 s12 l12 red" id="rrating">Reset All Ratings</a>
+                </div>
             </div>
             <div class="col s12 m10 l3 offset-m1 offset-l1 card-panel teal accent-3 white-text" style="height: 80%;">
                 <div>

+ 2 - 11
app/server/server.js

@@ -757,17 +757,8 @@ Meteor.methods({
         }
     },
     resetRating: function () {
-        if (isAdmin() && !isBanned()) {
-            stations.forEach(function (station) {
-                var type = station.type;
-                var temp_songs = Playlists.findOne({type: type}).songs;
-                Playlists.update({type: type}, {$set: {"songs": []}});
-                temp_songs.forEach(function (song) {
-                    song.likes = 0;
-                    song.dislikes = 0;
-                    Playlists.update({type: type}, {$push: {"songs": song}});
-                });
-            });
+        if (isAdmin() && !isBanned()){
+            Songs.update({}, {$set: {"likes": 0, "dislikes": 0}}, {multi: true});
             Meteor.users.update({}, {$set: {"profile.liked": [], "profile.disliked": []}}, {multi: true});
         } else {
             throw Meteor.Error(403, "Invalid permissions.");