• Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums
L

larrybiely

@larrybiely
About
Posts
7
Topics
3
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

    Scheduled Script Proxy API Calls
  • L larrybiely

    Here it is in its entirety:

    "use strict";
    
    function main() {
    
        //Schedule Nightly
        var scriptProxy = bridge.getScriptServiceProxy();
        var scriptName = "tournaments/SeedDailyLeaderboard";
        var scriptData = {};
        var midnightPSTinUTC = 1759561200000; // Calculate for your target date
        scriptProxy.scheduleRunScriptUTC(scriptName, scriptData, midnightPSTinUTC);
        //end schedule
    
        const profileIds = [
            "b7d353e8-3bef-4e01-9d42-a92e31d076c1",
            "4bfd2215-45bb-4ad0-96f9-97fa487926a7",
            "841abac7-86a5-4f31-8e33-0da986e42216",
            "75d97f20-fd76-46a9-aae1-70398bdc590e",
            "655d7882-5bee-44b0-aeb9-3a9cf404858e",
            "ef5061f7-2086-465e-bfb2-8df8bdc30b0d",
            "817560b6-6a87-454d-aef9-c7c3f7eb7963",
            "56570e93-8912-4d24-8289-9046faa6fdb2",
            "4180d878-256f-4ea1-a26b-65ff757d962b",
            "84d5509c-14c7-4e1f-8fd0-6a3ba432af17",
            "2bc2dd6b-3e0f-45d0-bea6-13bfc01bbbc4",
            "b6ad5fa9-ccf5-43be-ab6b-b44eeec02d90",
            "792712e6-efc0-4310-9f12-7abbcdab1bb1"
        ];
    
        function generateRandomScore() {
            const min = 300;
            const max = 1250;
            const randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
            return randomNum * 100;
        }
    
        let results = {
            success: [],
            errors: []
        };
    
        // Process one profile at a time
        let currentIndex = 0;
    
        function processNextProfile() {
            if (currentIndex >= profileIds.length) {
                return results;
            }
    
            const profileId = profileIds[currentIndex];
            const score = generateRandomScore(); // Generate new score for each profile
    
            try {
                const otherSession = bridge.getSessionForProfile(profileId);
                //const lbProxy = bridge.getLeaderboardServiceProxy(otherSession);
                const tournamentProxy = bridge.getTournamentServiceProxy(otherSession);
                
                var postResult = tournamentProxy.joinTournament("DailyHighScore", "DailyHighScore", score);
    
                
                // lbProxy.postScoreToLeaderboard(
                //     "WeeklyHighScore",
                //     score,
                //     {}
                // );
    
                // Wait for the first operation to complete before starting the next
                //bridge.callAPI("Leaderboard", "POST_SCORE", {
                //    leaderboardId: "WeeklyHighScore",
                //    score: score,
                //    data: {}
                //});
    
                results.success.push({
                    profileId: profileId,
                    score: score
                });
    
            } catch (error) {
                results.errors.push({
                    profileId: profileId,
                    error: error.message || "Unknown error"
                });
            }
    
            currentIndex++;
            return processNextProfile();
        }
    
        return processNextProfile();
    }
    
    main();
    

  • Scheduled Script Proxy API Calls
  • L larrybiely

    The only change I made to the script was to add this so it will run every night, and API usage went from about 3,400 API calls per month to ~350k per month. var scriptProxy = bridge.getScriptServiceProxy();
    var scriptName = "tournaments/SeedDailyLeaderboard";
    var scriptData = {};
    var midnightPSTinUTC = 1759561200000;
    scriptProxy.scheduleRunScriptUTC(scriptName, scriptData, midnightPSTinUTC);


  • Scheduled Script Proxy API Calls
  • L larrybiely

    Hi--I added a scriptProxy that calls scheduleRunScriptUTC. It's working fine but it's generating over 12k API calls per day. Is there a more efficient way to schedule a daily or weekly script execution?


  • PostTournamentScoreUTC DateTime or ulong?
  • L larrybiely

    Thanks, that's all I needed to know.


  • PostTournamentScoreUTC DateTime or ulong?
  • L larrybiely

    In your docs for the tournament service PostTournamentScoreUTC, you show that we should send a DateTime as the roundStartedTime. However, in the function signature it expects a ulong. Can you share an example of what it is expected in the ulong version?


  • Recurring scheduled tasks?
  • L larrybiely

    Thanks. So I create the script and it just runs? Do I need to do any other configuration or set up?


  • Recurring scheduled tasks?
  • L larrybiely

    I have a scheduled job that I set up in the Job Queue and it runs as expected, but is there a way to schedule it so that it runs weekly? Or tie it to a tournament so that it runs when the tournament starts?

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users