Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Commits
fcda6f68
Commit
fcda6f68
authored
3 years ago
by
Josef Olsson
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation for dbc.utils
parent
a0af056a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#41254
passed with warnings
3 years ago
Stage: setup
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/app/database/controller/utils.py
+12
-0
12 additions, 0 deletions
server/app/database/controller/utils.py
with
12 additions
and
0 deletions
server/app/database/controller/utils.py
+
12
−
0
View file @
fcda6f68
"""
This file contains some miscellaneous functionality.
"""
from
app.core
import
db
from
app.core.codes
import
generate_code_string
from
app.database.models
import
Code
def
generate_unique_code
():
"""
Generates a unique competition code.
"""
code
=
generate_code_string
()
while
db
.
session
.
query
(
Code
).
filter
(
Code
.
code
==
code
).
count
():
code
=
generate_code_string
()
...
...
@@ -11,13 +17,19 @@ def generate_unique_code():
def
commit_and_refresh
(
item
):
"""
Commits and refreshes the provided item.
"""
db
.
session
.
commit
()
db
.
session
.
refresh
(
item
)
def
refresh
(
item
):
"""
Refreshes the provided item.
"""
db
.
session
.
refresh
(
item
)
def
commit
(
item
):
"""
Commits.
"""
db
.
session
.
commit
()
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