Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soitool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bachelor-paa-bittet
soitool
Commits
adae365b
Commit
adae365b
authored
5 years ago
by
morkolai
Browse files
Options
Downloads
Patches
Plain Diff
#52 Laget funskjon som bergner tid i sek til neste oppdatering
parent
21f3ac13
No related branches found
Branches containing commit
No related tags found
1 merge request
!27
#52 Automatisk oppdatering av kodebok basert på tid
Pipeline
#73875
passed
5 years ago
Stage: lint
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
soitool/database.py
+19
-0
19 additions, 0 deletions
soitool/database.py
with
19 additions
and
0 deletions
soitool/database.py
+
19
−
0
View file @
adae365b
...
...
@@ -203,6 +203,25 @@ class Database:
print
(
"
Code in CodeBook updated
"
)
def
seconds_to_next_update
(
self
):
"""
Rerturns time to next updated of Codebook in seconds.
Returns
-------
time_diff : float
Time to next update in seconds
"""
stmt
=
"
SELECT Timestamp FROM LastUpdated
"
last_updated
=
self
.
conn
.
execute
(
stmt
).
fetchall
()[
0
][
0
]
# Convert datetime string to datetime object
last_updated
=
datetime
.
strptime
(
last_updated
,
"
%Y-%m-%d %H:%M:%S.%f
"
)
date_and_time_now
=
datetime
.
now
()
time_diff
=
date_and_time_now
-
last_updated
# Time difference in seconds
time_diff
=
time_diff
.
total_seconds
()
return
time_diff
def
add_code_to
(
self
,
word
,
mode
=
"
ascii
"
):
"""
Generate and insert a code for the new word in DB-table CodeBook.
...
...
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