[add] heavy query caching, [add] wpm leaderboard
This commit is contained in:
@@ -72,7 +72,8 @@ end
|
||||
-------------- New Functions -------------
|
||||
------------------------------------------
|
||||
|
||||
function SyncNinjaClient:check_activity(username, password, device_id, callback)
|
||||
function SyncNinjaClient:check_activity(username, password, device_id, device,
|
||||
callback)
|
||||
self.client:reset_middlewares()
|
||||
self.client:enable("Format.JSON")
|
||||
self.client:enable("GinClient")
|
||||
@@ -82,7 +83,10 @@ function SyncNinjaClient:check_activity(username, password, device_id, callback)
|
||||
socketutil:set_timeout(SYNC_TIMEOUTS[1], SYNC_TIMEOUTS[2])
|
||||
local co = coroutine.create(function()
|
||||
local ok, res = pcall(function()
|
||||
return self.client:check_activity({device_id = device_id})
|
||||
return self.client:check_activity({
|
||||
device_id = device_id,
|
||||
device = device
|
||||
})
|
||||
end)
|
||||
if ok then
|
||||
callback(res.status == 200, res.body)
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
"check_activity": {
|
||||
"path": "/api/ko/syncs/activity",
|
||||
"method": "POST",
|
||||
"required_params": ["device_id"],
|
||||
"payload": ["device_id"],
|
||||
"required_params": ["device_id", "device"],
|
||||
"payload": ["device_id", "device"],
|
||||
"expected_status": [200, 401]
|
||||
},
|
||||
"download_document": {
|
||||
|
||||
@@ -75,7 +75,7 @@ local STATISTICS_ACTIVITY_SINCE_QUERY = [[
|
||||
JOIN book AS b
|
||||
ON b.id = psd.id_book
|
||||
WHERE start_time > %d
|
||||
ORDER BY start_time ASC LIMIT 1000;
|
||||
ORDER BY start_time ASC LIMIT 5000;
|
||||
]]
|
||||
|
||||
local STATISTICS_BOOK_QUERY = [[
|
||||
@@ -615,7 +615,8 @@ function SyncNinja:checkActivity(interactive)
|
||||
service_spec = self.path .. "/api.json"
|
||||
}
|
||||
local ok, err = pcall(client.check_activity, client, self.settings.username,
|
||||
self.settings.password, self.device_id, callback_func)
|
||||
self.settings.password, self.device_id, Device.model,
|
||||
callback_func)
|
||||
end
|
||||
|
||||
function SyncNinja:uploadActivity(activity_data, interactive)
|
||||
@@ -907,7 +908,7 @@ function SyncNinja:getStatisticsActivity(timestamp)
|
||||
local conn = SQ3.open(statistics_db)
|
||||
local stmt = conn:prepare(string.format(STATISTICS_ACTIVITY_SINCE_QUERY,
|
||||
timestamp))
|
||||
local rows = stmt:resultset("i", 1000)
|
||||
local rows = stmt:resultset("i", 5000)
|
||||
conn:close()
|
||||
|
||||
-- No Results
|
||||
|
||||
Reference in New Issue
Block a user