CSGOWinBig icon indicating copy to clipboard operation
CSGOWinBig copied to clipboard

Updating prices

Open signedbydc opened this issue 9 years ago • 13 comments

Hello

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

signedbydc avatar Nov 20 '15 08:11 signedbydc

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

TheAnthonyNL avatar Nov 20 '15 08:11 TheAnthonyNL

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

signedbydc avatar Nov 20 '15 10:11 signedbydc

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

TheAnthonyNL avatar Nov 20 '15 12:11 TheAnthonyNL

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

Kiliso avatar Nov 20 '15 15:11 Kiliso

@Kiliso sweet maybe share it ?

TheAnthonyNL avatar Nov 20 '15 18:11 TheAnthonyNL

        $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.

Kiliso avatar Nov 20 '15 19:11 Kiliso

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

wwcam avatar Nov 21 '15 04:11 wwcam

He meant check-items.php i guess

TheAnthonyNL avatar Nov 21 '15 06:11 TheAnthonyNL

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

wwcam avatar Nov 21 '15 16:11 wwcam

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

^^

TheAnthonyNL avatar Nov 21 '15 16:11 TheAnthonyNL

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

andrewda avatar Nov 21 '15 16:11 andrewda

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

TheAnthonyNL avatar Nov 23 '15 08:11 TheAnthonyNL

@TheAnthonyNL ;)

andrewda avatar Nov 23 '15 09:11 andrewda