Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nitter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TeDomum
Nitter
Commits
384b0a20
Commit
384b0a20
authored
4 years ago
by
Zed
Browse files
Options
Downloads
Patches
Plain Diff
Fix profile caching logic to ignore empty profiles
parent
cd484036
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/redis_cache.nim
+2
-4
2 additions, 4 deletions
src/redis_cache.nim
src/routes/timeline.nim
+6
-2
6 additions, 2 deletions
src/routes/timeline.nim
with
8 additions
and
6 deletions
src/redis_cache.nim
+
2
−
4
View file @
384b0a20
...
...
@@ -63,7 +63,7 @@ proc cache*(data: PhotoRail; name: string) {.async.} =
await
setex
(
"pr:"
&
name
,
baseCacheTime
,
compress
(
freeze
(
data
)))
proc
cache
*
(
data
:
Profile
)
{.
async
.}
=
if
data
.
username
.
len
==
0
:
return
if
data
.
username
.
len
==
0
or
data
.
id
.
len
==
0
:
return
let
name
=
toLower
(
data
.
username
)
pool
.
withAcquire
(
r
):
r
.
startPipelining
()
...
...
@@ -93,14 +93,12 @@ proc getProfileId*(username: string): Future[string] {.async.} =
if
result
==
redisNil
:
result
.
setLen
(
0
)
proc
getCachedProfile
*
(
username
:
string
;
fetch
=
true
;
cache
=
false
):
Future
[
Profile
]
{.
async
.}
=
proc
getCachedProfile
*
(
username
:
string
;
fetch
=
true
):
Future
[
Profile
]
{.
async
.}
=
let
prof
=
await
get
(
"p:"
&
toLower
(
username
))
if
prof
!=
redisNil
:
uncompress
(
prof
).
thaw
(
result
)
elif
fetch
:
result
=
await
getProfile
(
username
)
if
cache
:
await
cache
(
result
)
proc
getCachedPhotoRail
*
(
name
:
string
):
Future
[
PhotoRail
]
{.
async
.}
=
if
name
.
len
==
0
:
return
...
...
This diff is collapsed.
Click to expand it.
src/routes/timeline.nim
+
6
−
2
View file @
384b0a20
...
...
@@ -31,7 +31,10 @@ proc fetchSingleTimeline*(after: string; query: Query; skipRail=false):
profile
=
await
getCachedProfile
(
name
)
profileId
=
if
profile
.
suspended
:
"s"
else
:
profile
.
id
await
cacheProfileId
(
profile
.
username
,
profileId
)
if
profileId
.
len
>
0
:
await
cacheProfileId
(
profile
.
username
,
profileId
)
fetched
=
true
if
profileId
.
len
==
0
or
profile
.
protected
:
...
...
@@ -66,7 +69,8 @@ proc fetchSingleTimeline*(after: string; query: Query; skipRail=false):
break
if
profile
.
username
.
len
==
0
:
profile
=
await
getCachedProfile
(
name
,
cache
=
true
)
profile
=
await
getCachedProfile
(
name
)
fetched
=
true
if
fetched
and
not
found
:
await
cache
(
profile
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment