Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
webclient
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
retribute.me
webclient
Commits
0d72c67d
Verified
Commit
0d72c67d
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Improved caching
parent
734f8f8c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/Suggestions.vue
+64
-1
64 additions, 1 deletion
src/components/Suggestions.vue
src/sources/mastodon.js
+1
-1
1 addition, 1 deletion
src/sources/mastodon.js
src/store.js
+2
-1
2 additions, 1 deletion
src/store.js
with
67 additions
and
3 deletions
src/components/Suggestions.vue
+
64
−
1
View file @
0d72c67d
...
@@ -35,6 +35,23 @@
...
@@ -35,6 +35,23 @@
<img
v-if=
"suggestion.avatar"
:src=
"suggestion.avatar"
alt=
""
class=
"circle"
>
<img
v-if=
"suggestion.avatar"
:src=
"suggestion.avatar"
alt=
""
class=
"circle"
>
<a
target=
"_blank"
rel=
"noopener noreferrer"
:href=
"suggestion.url"
class=
"title"
>
{{
suggestion
.
name
}}
</a>
<a
target=
"_blank"
rel=
"noopener noreferrer"
:href=
"suggestion.url"
class=
"title"
>
{{
suggestion
.
name
}}
</a>
<p>
Score:
{{
suggestion
.
weight
}}
</p>
<p>
Score:
{{
suggestion
.
weight
}}
</p>
<a
v-if=
"retributeProfiles[suggestion.fullId] === undefined"
@
click=
"lookup(suggestion.fullId)"
class=
"secondary-content"
><i
class=
"material-icons"
>
search
</i></a>
<div
v-else-if=
"retributeProfiles[suggestion.fullId]"
>
<h6>
Donation platforms
</h6>
<!--
{{
retributeProfiles
[
suggestion
.
fullId
]
}}
-->
<template
v-for=
"mean in retributeProfiles[suggestion.fullId].means"
>
<a
:href=
"mean.url"
:key=
"mean.id"
target=
"_blank"
rel=
"noopener noreferrer"
:class=
"['waves-effect', 'waves-light', 'btn-small']"
>
<span
:title=
"mean.summary"
>
{{
mean
.
provider
}}
</span>
</a>
</
template
>
</div>
<div
v-else
>
No retribute information found for this account
</div>
</li>
</li>
</ul>
</ul>
</div>
</div>
...
@@ -44,13 +61,16 @@
...
@@ -44,13 +61,16 @@
<
script
>
<
script
>
import
sources
from
'
@/sources
'
import
sources
from
'
@/sources
'
import
orderBy
from
'
lodash/orderBy
'
import
orderBy
from
'
lodash/orderBy
'
import
chunk
from
'
lodash/chunk
'
import
axios
from
'
axios
'
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
isLoading
:
false
,
isLoading
:
false
,
results
:
{},
results
:
{},
aggregatedSuggestions
:
{}
aggregatedSuggestions
:
this
.
$store
.
state
.
cache
.
aggregatedSuggestions
||
{},
retributeProfiles
:
this
.
$store
.
state
.
cache
.
retributeProfiles
||
{},
}
}
},
},
computed
:
{
computed
:
{
...
@@ -103,15 +123,58 @@ export default {
...
@@ -103,15 +123,58 @@ export default {
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
){
await
this
.
results
[
keys
[
i
]].
promise
await
this
.
results
[
keys
[
i
]].
promise
}
}
await
this
.
lookupAll
()
this
.
isLoading
=
false
this
.
isLoading
=
false
},
async
lookupAll
()
{
const
toLookup
=
this
.
filteredSuggestions
.
filter
((
s
)
=>
{
return
this
.
retributeProfiles
[
s
.
fullId
]
===
undefined
})
const
chunkSize
=
5
const
chunks
=
chunk
(
toLookup
,
chunkSize
)
for
(
let
i
=
0
;
i
<
chunks
.
length
;
i
++
){
let
chunk
=
chunks
[
i
]
let
ids
=
chunk
.
map
((
s
)
=>
{
return
s
.
fullId
})
await
this
.
lookups
(
ids
)
}
},
async
lookups
(
ids
)
{
const
tasks
=
ids
.
map
((
i
)
=>
{
return
this
.
lookup
(
i
)
})
for
(
let
i
=
0
;
i
<
tasks
.
length
;
i
++
){
await
tasks
[
i
]
}
},
async
lookup
(
id
)
{
const
client
=
axios
.
create
({
timeout
:
5000
})
let
url
=
`http://localhost:8000/api/v1/search/
${
id
}
`
try
{
const
response
=
await
client
.
get
(
url
)
this
.
$set
(
this
.
retributeProfiles
,
id
,
response
.
data
)
}
catch
{
this
.
$set
(
this
.
retributeProfiles
,
id
,
null
)
return
}
}
}
},
},
watch
:
{
watch
:
{
results
:
{
results
:
{
handler
(
v
)
{
handler
(
v
)
{
this
.
aggregatedSuggestions
=
this
.
aggregateSuggestions
(
v
)
this
.
aggregatedSuggestions
=
this
.
aggregateSuggestions
(
v
)
this
.
$store
.
commit
(
'
setRecursiveState
'
,
{
key
:
'
cache.aggregatedSuggestions
'
,
value
:
this
.
aggregatedSuggestions
})
},
},
deep
:
true
,
deep
:
true
,
},
retributeProfiles
:
{
handler
(
v
)
{
this
.
$store
.
commit
(
'
setRecursiveState
'
,
{
key
:
'
cache.retributeProfiles
'
,
value
:
this
.
retributeProfiles
})
},
deep
:
true
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/sources/mastodon.js
+
1
−
1
View file @
0d72c67d
...
@@ -89,7 +89,7 @@ export default {
...
@@ -89,7 +89,7 @@ export default {
baseURL
:
`https://
${
account
.
domain
}
`
,
baseURL
:
`https://
${
account
.
domain
}
`
,
headers
:
{
'
Authorization
'
:
`Bearer
${
token
}
`
},
headers
:
{
'
Authorization
'
:
`Bearer
${
token
}
`
},
})
})
const
maxFavorites
=
5
00
const
maxFavorites
=
1
00
let
url
=
'
/api/v1/favourites
'
let
url
=
'
/api/v1/favourites
'
let
handledFavorites
=
0
let
handledFavorites
=
0
results
.
progress
=
0
results
.
progress
=
0
...
...
This diff is collapsed.
Click to expand it.
src/store.js
+
2
−
1
View file @
0d72c67d
...
@@ -13,7 +13,8 @@ export const storeConfig = {
...
@@ -13,7 +13,8 @@ export const storeConfig = {
state
:
{
state
:
{
accounts
:
{},
accounts
:
{},
sources
:
{}
sources
:
{},
cache
:
{}
},
},
mutations
:
{
mutations
:
{
addAccount
(
state
,
payload
)
{
addAccount
(
state
,
payload
)
{
...
...
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