mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 14:03:42 -05:00
Merge pull request #22 from sharelatex/upgrade-sequelize
upgrade sequelize and mysql
This commit is contained in:
commit
5b81a9b12e
3 changed files with 19 additions and 21 deletions
|
@ -8,11 +8,11 @@ module.exports = ProjectPersistenceManager =
|
||||||
EXPIRY_TIMEOUT: oneDay = 24 * 60 * 60 * 1000 #ms
|
EXPIRY_TIMEOUT: oneDay = 24 * 60 * 60 * 1000 #ms
|
||||||
|
|
||||||
markProjectAsJustAccessed: (project_id, callback = (error) ->) ->
|
markProjectAsJustAccessed: (project_id, callback = (error) ->) ->
|
||||||
db.Project.findOrCreate(project_id: project_id)
|
db.Project.findOrCreate(where: {project_id: project_id})
|
||||||
.success(
|
.spread(
|
||||||
(project) ->
|
(project, created) ->
|
||||||
project.updateAttributes(lastAccessed: new Date())
|
project.updateAttributes(lastAccessed: new Date())
|
||||||
.success(() -> callback())
|
.then(() -> callback())
|
||||||
.error callback
|
.error callback
|
||||||
)
|
)
|
||||||
.error callback
|
.error callback
|
||||||
|
@ -41,14 +41,12 @@ module.exports = ProjectPersistenceManager =
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
_clearProjectFromDatabase: (project_id, callback = (error) ->) ->
|
_clearProjectFromDatabase: (project_id, callback = (error) ->) ->
|
||||||
db.Project.destroy(project_id: project_id)
|
db.Project.destroy(where: {project_id: project_id})
|
||||||
.success(() -> callback())
|
.then(() -> callback())
|
||||||
.error callback
|
.error callback
|
||||||
|
|
||||||
_findExpiredProjectIds: (callback = (error, project_ids) ->) ->
|
_findExpiredProjectIds: (callback = (error, project_ids) ->) ->
|
||||||
db.Project.findAll(where: ["lastAccessed < ?", new Date(Date.now() - ProjectPersistenceManager.EXPIRY_TIMEOUT)])
|
db.Project.findAll(where: ["lastAccessed < ?", new Date(Date.now() - ProjectPersistenceManager.EXPIRY_TIMEOUT)])
|
||||||
.success(
|
.then((projects) ->
|
||||||
(projects) ->
|
callback null, projects.map((project) -> project.project_id)
|
||||||
callback null, projects.map((project) -> project.project_id)
|
).error callback
|
||||||
)
|
|
||||||
.error callback
|
|
||||||
|
|
|
@ -91,27 +91,27 @@ module.exports = UrlCache =
|
||||||
|
|
||||||
_findUrlDetails: (project_id, url, callback = (error, urlDetails) ->) ->
|
_findUrlDetails: (project_id, url, callback = (error, urlDetails) ->) ->
|
||||||
db.UrlCache.find(where: { url: url, project_id: project_id })
|
db.UrlCache.find(where: { url: url, project_id: project_id })
|
||||||
.success((urlDetails) -> callback null, urlDetails)
|
.then((urlDetails) -> callback null, urlDetails)
|
||||||
.error callback
|
.error callback
|
||||||
|
|
||||||
_updateOrCreateUrlDetails: (project_id, url, lastModified, callback = (error) ->) ->
|
_updateOrCreateUrlDetails: (project_id, url, lastModified, callback = (error) ->) ->
|
||||||
db.UrlCache.findOrCreate(url: url, project_id: project_id)
|
db.UrlCache.findOrCreate(where: {url: url, project_id: project_id})
|
||||||
.success(
|
.spread(
|
||||||
(urlDetails) ->
|
(urlDetails, created) ->
|
||||||
urlDetails.updateAttributes(lastModified: lastModified)
|
urlDetails.updateAttributes(lastModified: lastModified)
|
||||||
.success(() -> callback())
|
.then(() -> callback())
|
||||||
.error(callback)
|
.error(callback)
|
||||||
)
|
)
|
||||||
.error callback
|
.error callback
|
||||||
|
|
||||||
_clearUrlDetails: (project_id, url, callback = (error) ->) ->
|
_clearUrlDetails: (project_id, url, callback = (error) ->) ->
|
||||||
db.UrlCache.destroy(url: url, project_id: project_id)
|
db.UrlCache.destroy(where: {url: url, project_id: project_id})
|
||||||
.success(() -> callback null)
|
.then(() -> callback null)
|
||||||
.error callback
|
.error callback
|
||||||
|
|
||||||
_findAllUrlsInProject: (project_id, callback = (error, urls) ->) ->
|
_findAllUrlsInProject: (project_id, callback = (error, urls) ->) ->
|
||||||
db.UrlCache.findAll(where: { project_id: project_id })
|
db.UrlCache.findAll(where: { project_id: project_id })
|
||||||
.success(
|
.then(
|
||||||
(urlEntries) ->
|
(urlEntries) ->
|
||||||
callback null, urlEntries.map((entry) -> entry.url)
|
callback null, urlEntries.map((entry) -> entry.url)
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
"async": "0.2.9",
|
"async": "0.2.9",
|
||||||
"lynx": "0.0.11",
|
"lynx": "0.0.11",
|
||||||
"mkdirp": "0.3.5",
|
"mkdirp": "0.3.5",
|
||||||
"mysql": "2.0.0-alpha7",
|
"mysql": "2.6.2",
|
||||||
"request": "~2.21.0",
|
"request": "~2.21.0",
|
||||||
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0",
|
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0",
|
||||||
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
|
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
|
||||||
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git",
|
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git",
|
||||||
"sequelize": "2.0.0-beta.2",
|
"sequelize": "^2.1.3",
|
||||||
"wrench": "~1.5.4",
|
"wrench": "~1.5.4",
|
||||||
"smoke-test-sharelatex": "git+https://github.com/sharelatex/smoke-test-sharelatex.git",
|
"smoke-test-sharelatex": "git+https://github.com/sharelatex/smoke-test-sharelatex.git",
|
||||||
"sqlite3": "~2.2.0",
|
"sqlite3": "~2.2.0",
|
||||||
|
|
Loading…
Reference in a new issue