Skip to content

Commit

Permalink
Fix occasional race condition
Browse files Browse the repository at this point in the history
Signed-off-by: Walker Crouse <walkercrouse@hotmail.com>
  • Loading branch information
windy1 committed Feb 17, 2017
1 parent a9c1760 commit 609aa0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controllers
import javax.inject.Inject

import controllers.sugar.Requests.AuthRequest
import db.impl.OrePostgresDriver.api._
import db.impl.schema.ProjectSchema
import db.{ModelFilter, ModelService}
import models.project.{Flag, Project, Version}
Expand Down Expand Up @@ -63,7 +64,8 @@ final class Application @Inject()(data: DataHelper,

val searchFilter: ModelFilter[Project] = query.map(actions.searchFilter).getOrElse(ModelFilter.Empty)

val filter = visibleFilter +&& platformFilter +&& categoryFilter +&& searchFilter
val validFilter = ModelFilter[Project](_.recommendedVersionId =!= -1)
val filter = visibleFilter +&& platformFilter +&& categoryFilter +&& searchFilter +&& validFilter

// Get projects
val pageSize = this.config.projects.getInt("init-load").get
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/Users.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ class Users @Inject()(fakeUser: FakeUser,
val p = page.getOrElse(1)
val offset = (p - 1) * pageSize
this.users.withName(username).map { u =>
(u, u.projects.sorted(ordering = _.stars.desc, limit = pageSize, offset = offset))
(u, u.projects.sorted(
ordering = _.stars.desc,
filter = _.recommendedVersionId =!= -1,
limit = pageSize,
offset = offset))
} map {
case (user, projectSeq) => Ok(views.users.projects(user, projectSeq, p))
} getOrElse {
Expand Down
10 changes: 4 additions & 6 deletions app/discourse/OreDiscourseApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ trait OreDiscourseApi extends DiscourseApi {
s"Errors: ${errors.toString}"
)

def fail() = {
Logger.info(s"Couldn't update project topic for project ${project.url}. Rescheduling...")
def fail(message: String) = {
Logger.info(s"Couldn't update project topic for project ${project.url}: " + message)
resultPromise.success(false)
}

Expand Down Expand Up @@ -187,12 +187,12 @@ trait OreDiscourseApi extends DiscourseApi {
resultPromise.success(true)
}
case Failure(e) =>
fail()
fail(e.getMessage)
}
}
case Failure(e) =>
// Discourse never received our request!
fail()
fail(e.getMessage)
}

resultPromise.future
Expand Down Expand Up @@ -236,8 +236,6 @@ trait OreDiscourseApi extends DiscourseApi {
checkArgument(project.id.isDefined, "undefined project", "")
checkArgument(version.id.isDefined, "undefined version", "")
checkArgument(version.projectId == project.id.get, "invalid version project pair", "")
// TODO: Handle failure
// TODO: Need to be able to edit description before release so you can change the post content
val cont = if (content.isEmpty) None else Some(content)
postDiscussionReply(
project = project,
Expand Down

0 comments on commit 609aa0b

Please sign in to comment.