Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pubsweet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Tremblay McLellan
pubsweet
Commits
6989dd6f
Commit
6989dd6f
authored
6 years ago
by
Alexandros Georgantas
Browse files
Options
Downloads
Patches
Plain Diff
fix: sync cache added
parent
491880f7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/components/Polling-server/PollingServer.js
+20
-5
20 additions, 5 deletions
packages/components/Polling-server/PollingServer.js
with
20 additions
and
5 deletions
packages/components/Polling-server/PollingServer.js
+
20
−
5
View file @
6989dd6f
...
@@ -2,7 +2,7 @@ const config = require('config')
...
@@ -2,7 +2,7 @@ const config = require('config')
const
logger
=
require
(
'
@pubsweet/logger
'
)
const
logger
=
require
(
'
@pubsweet/logger
'
)
cons
t
lockedFragments
=
{}
le
t
lockedFragments
=
{}
const
initCache
=
async
Fragment
=>
{
const
initCache
=
async
Fragment
=>
{
const
allFragments
=
await
Fragment
.
all
()
const
allFragments
=
await
Fragment
.
all
()
for
(
let
i
=
0
;
i
<
allFragments
.
length
;
i
+=
1
)
{
for
(
let
i
=
0
;
i
<
allFragments
.
length
;
i
+=
1
)
{
...
@@ -12,6 +12,21 @@ const initCache = async Fragment => {
...
@@ -12,6 +12,21 @@ const initCache = async Fragment => {
lockedFragments
[
id
]
=
currentFragment
.
lock
.
editor
.
userId
lockedFragments
[
id
]
=
currentFragment
.
lock
.
editor
.
userId
}
}
}
}
setInterval
(()
=>
cacheSync
(
Fragment
),
8000
)
}
const
cacheSync
=
async
Fragment
=>
{
logger
.
info
(
`Syncing cache`
)
const
syncedLockedFragments
=
{}
const
allFragments
=
await
Fragment
.
all
()
for
(
let
i
=
0
;
i
<
allFragments
.
length
;
i
+=
1
)
{
const
currentFragment
=
allFragments
[
i
]
if
(
currentFragment
.
lock
&&
currentFragment
.
lock
!==
null
)
{
const
{
id
}
=
currentFragment
syncedLockedFragments
[
id
]
=
currentFragment
.
lock
.
editor
.
userId
}
}
lockedFragments
=
syncedLockedFragments
}
}
const
PollingServer
=
app
=>
{
const
PollingServer
=
app
=>
{
...
@@ -119,6 +134,7 @@ const PollingServer = app => {
...
@@ -119,6 +134,7 @@ const PollingServer = app => {
async
(
req
,
res
,
next
)
=>
{
async
(
req
,
res
,
next
)
=>
{
const
{
collectionId
,
fragmentId
}
=
req
.
params
const
{
collectionId
,
fragmentId
}
=
req
.
params
const
{
username
}
=
req
.
query
const
{
username
}
=
req
.
query
logger
.
info
(
logger
.
info
(
`Initiating polling for fragment with id
${
fragmentId
}
of the collection with id
${
collectionId
}
for user
${
username
}
`
,
`Initiating polling for fragment with id
${
fragmentId
}
of the collection with id
${
collectionId
}
for user
${
username
}
`
,
)
)
...
@@ -208,11 +224,10 @@ const PollingServer = app => {
...
@@ -208,11 +224,10 @@ const PollingServer = app => {
res
.
sendStatus
(
403
)
res
.
sendStatus
(
403
)
}
}
}
}
logger
.
info
(
`Setting timmer for
${
pollingTime
}
ms`
)
setTimer
(
unlocker
,
pollingTime
,
opts
)
res
.
sendStatus
(
200
)
}
}
logger
.
info
(
`Setting timmer for
${
pollingTime
}
ms`
)
setTimer
(
unlocker
,
pollingTime
,
opts
)
res
.
sendStatus
(
200
)
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
logger
.
error
(
`In polling endpoint
${
e
}
`
)
logger
.
error
(
`In polling endpoint
${
e
}
`
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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