Sign In Register

How can we help you today?

Start a new topic
Answered

How to erase Challenges expired in the server

Hi,


I want to clean the server and erase those challenges who expired and do automatically but I dont find any Cloud Coud APi to do that.


Any help ? thanks.


Best Answer

Hi Guys,


Currently there is no way to remove Expired Challenges from the ChallengeInstanceID collection, they will always remain in that collection in an "EXPIRED" state. The above example “var collection = Spark.runtimeCollection('challengeinstance');” won't work as the ChallengeInstance Collection is a System Collection and not a Runtime one. System collections are read only and not accessed like a normal collection. You can use SparkChallenge in Cloud Code to access the details of a particular challenge.


You can also use a ListChallengeRequest to list all of the challenges that exist in a particular state. A FindChallengeRequest will return a list of challenges that the current player is eligible to join.


Thanks,

Liam


Hi, 

     After seeing your question, I went ahead and wrote a system script to delete some entries from collection.

Here, just for checking, I tried with RUNNING games state.


var collection = Spark.runtimeCollection('challengeinstance');

var result = collection.remove({"state":"RUNNING"});

Spark.getLog().error("Removed Running Event" + collection + " success ? "+ result);


Its returning success but, once i go to NO SQL section, it still shows the running challenge.


Any one from GameSparks can help on this?

mmmmm interesting

I inly can remove my own Challengue? 


Any GameSparks guest?

Do you mean , you can remove only the one created by you?

Sorry my bad. 

Yes, I dont know why its not working.


I try:

 

var collection = Spark.runtimeCollection("challengeinstance");
var result = collection.remove({"state":"COMPLETE"});
Spark.getLog().error("Removed COMPLETE Event" + collection + " success ? "+ result);

 And the Log I recieved:


 

{
 "_id": {
  "$oid": "551d74dce4b0e4d9398f2b2f"
 },
 "level": "ERROR",
 "log": "Removed COMPLETE Eventcom.gamesparks.scripting.mongo.impl.SparkMongoCollectionReadWriteImpl@cb00e4c success ? true",
 "ts": 1427993820102
}

 But I my NOSQL I still have Challenge Completed 


Yes luis. Im seeing same thing. Its returning sucess in cloud script but in db it still exists. Any one from GameSparks pls look into this?

1 person likes this

. Any one from GameSparks pls look into this?

Hi Luis, 


We are looking in to this at the moment.


Will update you here.


THanks,


Oisin

was there any solution to this?


Thanks

Answer

Hi Guys,


Currently there is no way to remove Expired Challenges from the ChallengeInstanceID collection, they will always remain in that collection in an "EXPIRED" state. The above example “var collection = Spark.runtimeCollection('challengeinstance');” won't work as the ChallengeInstance Collection is a System Collection and not a Runtime one. System collections are read only and not accessed like a normal collection. You can use SparkChallenge in Cloud Code to access the details of a particular challenge.


You can also use a ListChallengeRequest to list all of the challenges that exist in a particular state. A FindChallengeRequest will return a list of challenges that the current player is eligible to join.


Thanks,

Liam

Hi Liam,

what do you suggest to avoid loading several challenges? In my case, completed challenges with winner aren't important for user to load. So I tried to remove all challenge players, I got an error but it seems to work well for me.


It should be great to have a function to delete challenge.


Thanks 


Hi guys,


To remove all the expired challenges just go to the NOSQL tab and then inside it go to the "Remove" tab. Write this query:

{ "state" : "EXPIRED" }

and submit. All the EXPIRED challenged will be deleted.



1 person likes this
Login to post a comment