Skip to content

Commit

Permalink
Merge pull request #3535 from opensafely-core/evansd/database-name
Browse files Browse the repository at this point in the history
Move `workspace.db` API field to `database_name`
  • Loading branch information
evansd authored Sep 11, 2023
2 parents 38a9dcc + 6b80a62 commit 36a9661
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jobserver/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ class Meta:
"name",
"repo",
"branch",
"db",
"created_by",
"created_at",
]
Expand Down Expand Up @@ -257,6 +256,7 @@ class Meta:
"created_by",
"created_at",
"workspace",
"database_name",
"project",
"orgs",
]
Expand Down
7 changes: 7 additions & 0 deletions jobserver/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ def status(self):

return "unknown"

@property
def database_name(self):
# TODO: This is temporary code. We're going to remove the `workspace.db` column
# entirely and use different logic for decided which database a job runs
# against.
return self.workspace.db


class Org(models.Model):
"""An Organisation using the platform"""
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/jobserver/api/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,11 @@ def dictify(od):
"project": project.slug,
"requested_actions": ["frob", "wizzle"],
"sha": "",
"database_name": "full",
"workspace": {
"name": workspace.name,
"repo": workspace.repo.url,
"branch": "",
"db": "full",
"created_by": workspace.created_by.username,
"created_at": now_iso,
},
Expand All @@ -828,11 +828,11 @@ def dictify(od):
"project": project.slug,
"requested_actions": ["frobnicate", "wibble"],
"sha": "",
"database_name": "full",
"workspace": {
"name": workspace.name,
"repo": workspace.repo.url,
"branch": "",
"db": "full",
"created_by": workspace.created_by.username,
"created_at": now_iso,
},
Expand All @@ -848,11 +848,11 @@ def dictify(od):
"project": project.slug,
"requested_actions": ["analyse"],
"sha": "",
"database_name": "full",
"workspace": {
"name": workspace.name,
"repo": workspace.repo.url,
"branch": "",
"db": "full",
"created_by": workspace.created_by.username,
"created_at": now_iso,
},
Expand Down

0 comments on commit 36a9661

Please sign in to comment.