Use random user agents
This commit is contained in:
@@ -12,18 +12,18 @@ var profileCacheTime = initDuration(minutes=10)
|
||||
proc outdated(profile: Profile): bool =
|
||||
getTime() - profile.updated > profileCacheTime
|
||||
|
||||
proc getCachedProfile*(username: string; force=false): Future[Profile] {.async.} =
|
||||
proc getCachedProfile*(username, agent: string; force=false): Future[Profile] {.async.} =
|
||||
withDb:
|
||||
try:
|
||||
result.getOne("username = ?", username)
|
||||
doAssert not result.outdated()
|
||||
except AssertionError:
|
||||
var profile = await getProfile(username)
|
||||
var profile = await getProfile(username, agent)
|
||||
profile.id = result.id
|
||||
result = profile
|
||||
result.update()
|
||||
except KeyError:
|
||||
result = await getProfile(username)
|
||||
result = await getProfile(username, agent)
|
||||
if result.username.len > 0:
|
||||
result.insert()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user