Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
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
AlekSIS®
Official
AlekSIS-Core
Merge requests
!86
Merge school-apps
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Merge school-apps
school-apps
into
master
Overview
1
Commits
951
Pipelines
1
Changes
95
Merged
mirabilos
requested to merge
school-apps
into
master
5 years ago
Overview
1
Commits
951
Pipelines
1
Changes
95
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
98421708
951 commits,
5 years ago
95 files
+
6464
−
17
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
95
Search (e.g. *.vue) (Ctrl+P)
biscuit/core/dashboard/management/commands/refresh_caches.py
0 → 100644
+
83
−
0
Options
import
datetime
from
django.core.management
import
BaseCommand
from
django.utils
import
timezone
from
dashboard.caches
import
BACKGROUND_CACHE_REFRESH
from
dashboard.models
import
Cache
from
util.network
import
get_newest_article_from_news
,
get_current_events_with_cal
from
timetable.views
import
get_next_weekday_with_time
,
get_calendar_week
from
untisconnect.drive
import
build_drive
,
TYPE_TEACHER
,
TYPE_CLASS
,
TYPE_ROOM
from
untisconnect.parse
import
parse
from
untisconnect.plan
import
get_plan
class
Command
(
BaseCommand
):
help
=
'
Refresh all var caches
'
def
start
(
self
,
s
):
self
.
stdout
.
write
(
s
)
def
finish
(
self
):
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Erledigt.
'
))
def
handle
(
self
,
*
args
,
**
options
):
self
.
start
(
"
Alte Caches löschen ...
"
)
for
cache
in
Cache
.
objects
.
filter
(
needed_until__isnull
=
False
):
if
not
cache
.
is_needed
():
print
(
"
Ist nicht mehr benötigt:
"
,
cache
,
"
, benötigt bis
"
,
cache
.
needed_until
)
cache
.
delete
()
self
.
finish
()
self
.
start
(
"
Aktualisiere Drive ...
"
)
drive
=
build_drive
(
force_update
=
True
)
print
(
drive
)
self
.
finish
()
self
.
start
(
"
Aktualisiered Lessons ...
"
)
parse
(
force_update
=
True
)
self
.
finish
()
self
.
start
(
"
Aktualisiere Pläne ...
"
)
days
=
[]
days
.
append
(
get_next_weekday_with_time
(
timezone
.
now
(),
timezone
.
now
().
time
()))
days
.
append
(
get_next_weekday_with_time
(
days
[
0
]
+
datetime
.
timedelta
(
days
=
1
),
datetime
.
time
(
0
)))
print
(
days
)
types
=
[
(
TYPE_TEACHER
,
"
teachers
"
),
(
TYPE_CLASS
,
"
classes
"
),
(
TYPE_ROOM
,
"
rooms
"
)
]
for
type_id
,
type_key
in
types
:
self
.
start
(
type_key
)
for
id
,
obj
in
drive
[
type_key
].
items
():
self
.
start
(
"
"
+
obj
.
name
if
obj
.
name
is
not
None
else
""
)
self
.
start
(
"
Regelplan
"
)
get_plan
(
type_id
,
id
,
force_update
=
True
)
for
day
in
days
:
calendar_week
=
day
.
isocalendar
()[
1
]
if
day
!=
days
[
0
]
and
days
[
0
].
isocalendar
()[
1
]
==
calendar_week
and
days
[
0
].
year
==
day
.
year
:
continue
monday_of_week
=
get_calendar_week
(
calendar_week
,
day
.
year
)[
"
first_day
"
]
self
.
start
(
"
"
+
str
(
monday_of_week
))
get_plan
(
type_id
,
id
,
smart
=
True
,
monday_of_week
=
monday_of_week
,
force_update
=
True
)
self
.
finish
()
self
.
start
(
"
Aktualisiere Artikel ...
"
)
get_newest_article_from_news
(
force_update
=
True
)
self
.
finish
()
self
.
start
(
"
Aktualisiere Termine ...
"
)
get_current_events_with_cal
(
force_update
=
True
)
self
.
finish
()
self
.
start
(
"
Aktualisierungszeitpunkt in der Datenbank speichern ...
"
)
BACKGROUND_CACHE_REFRESH
.
last_time_updated
=
timezone
.
now
()
BACKGROUND_CACHE_REFRESH
.
save
()
self
.
finish
()
Loading