ztizzlegaming / CSGOWinBig

Open-source Counter-Strike: Global Offensive jackpot betting website.
MIT License
175 stars 105 forks source link

Updating prices #76

Open signedbydc opened 9 years ago

signedbydc commented 9 years ago

Hello

What is the best way to update items prices, in the database?

TheAnthonyNL commented 9 years ago

Ehm remove all items in database and script will take them from market :). Allthough it wont save in database.

signedbydc commented 9 years ago

Okay sound cool, but what kind of script are you talking about? Something you will share?

TheAnthonyNL commented 9 years ago

I mean the CSGOWinBig site itself already has functions which grabs the price from steam market :D. So no extra script needed.

Kiliso commented 9 years ago

I modified the script a bit stating that if it had to pull the price I make it update in the DB.

TheAnthonyNL commented 9 years ago

@Kiliso sweet maybe share it ?

Kiliso commented 9 years ago
        $marketObj = json_decode(file_get_contents("http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=$hash"), true);

            $medianPrice = $marketObj['median_price'];
            $lowestPrice = $marketObj['lowest_price'];

            if (isset($medianPrice)) {
                    $price = doubleval(substr($medianPrice, 1)) * 100;
                            $stmt = $db->prepare("UPDATE items SET currentPrice='$price', suggestedPriceMin='0' where marketName = '$name'");
                            $stmt->execute();

            } else {
                    $price = doubleval(substr($lowestPrice, 1)) * 100;
                            $stmt = $db->prepare("UPDATE items SET currentPrice='$price', suggestedPriceMin='0' where marketName = '$name'");
                            $stmt->execute();

            }

Just add that to the search-items.php file.

wwcam commented 9 years ago

@Kiliso Can you post the whole search-items code for reference?

TheAnthonyNL commented 9 years ago

He meant check-items.php i guess

wwcam commented 9 years ago

@TheAnthonyNL Still not 100% sure what to change in the php though, which is my point.

TheAnthonyNL commented 9 years ago

https://github.com/ztizzlegaming/CSGOWinBig/blob/master/src/php/check-items.php#L128

^^

andrewda commented 9 years ago

pro github tip: you can do a range for the line numbers https://github.com/ztizzlegaming/CSGOWinBig/blob/master/src/php/check-items.php#L128-L146

TheAnthonyNL commented 9 years ago

@andrewda i know but its not that hard to figure it out right ;).

andrewda commented 9 years ago

@TheAnthonyNL ;)