Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
onTime
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
onTime InnoLab
onTime
Commits
91ebf683
Commit
91ebf683
authored
1 year ago
by
doodlezucc
Browse files
Options
Downloads
Patches
Plain Diff
generalize cacheable timetable
parent
60b958be
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/fetching/timetable.dart
+11
-5
11 additions, 5 deletions
lib/fetching/timetable.dart
lib/main.dart
+9
-2
9 additions, 2 deletions
lib/main.dart
lib/untis/fetch.dart
+9
-3
9 additions, 3 deletions
lib/untis/fetch.dart
test/untis_test.dart
+9
-1
9 additions, 1 deletion
test/untis_test.dart
with
38 additions
and
11 deletions
lib/fetching/timetable.dart
+
11
−
5
View file @
91ebf683
...
...
@@ -9,21 +9,27 @@ import '../untis/teacher.dart';
import
'../untis/timetable.dart'
;
import
'cacheable.dart'
;
typedef
TimetableOptions
=
(
int
class
Id
,
DateTime
date
);
typedef
TimetableOptions
=
(
ElementType
type
,
int
element
Id
,
DateTime
date
);
class
CacheableTimetable
extends
Cacheable
<
TimetableData
>
{
final
DateTime
date
;
final
int
classId
;
final
ElementType
type
;
final
int
elementId
;
CacheableTimetable
(
super
.
untis
,
{
required
this
.
date
,
required
this
.
classId
});
CacheableTimetable
(
super
.
untis
,
{
required
this
.
date
,
required
this
.
type
,
required
this
.
elementId
,
});
@override
RequestOptions
get
request
=
>
(
'timetable/weekly/data'
,
'GET'
,
{
'elementType'
:
'
${
ElementType.classGroup
.id}
'
,
'elementId'
:
'
$
class
Id
'
,
'elementType'
:
'
${
type
.id}
'
,
'elementId'
:
'
$
element
Id
'
,
'date'
:
date
.
toUntisDate
(),
'formatId'
:
'2'
,
'filter.departmentId'
:
'-1'
,
...
...
This diff is collapsed.
Click to expand it.
lib/main.dart
+
9
−
2
View file @
91ebf683
...
...
@@ -9,6 +9,7 @@ import 'dialogs/error_dialog.dart';
import
'drawer/drawer.dart'
;
import
'timetable/timetable.dart'
;
import
'toolbar/toolbar.dart'
;
import
'untis/element_type.dart'
;
import
'untis/fetch.dart'
;
import
'untis/timetable.dart'
;
import
'user/save_state.dart'
;
...
...
@@ -108,8 +109,14 @@ class _MyHomePageState extends State<MyHomePage> {
final
profile
=
await
appContext
.
profile
.
firstNotNull
;
final
selectedClasses
=
profile
.
selectedClasses
;
final
allTimetables
=
await
Future
.
wait
(
selectedClasses
.
map
((
classid
)
{
return
Future
(()
=
>
untis
.
timetableOf
(
classid
,
date
)
.
fetched
);
final
allTimetables
=
await
Future
.
wait
(
selectedClasses
.
map
((
classId
)
{
final
cacheable
=
untis
.
timetableOf
(
type:
ElementType
.
classGroup
,
elementId:
classId
,
date:
date
,
);
return
Future
(()
=
>
cacheable
.
fetched
);
}));
setState
(()
{
...
...
This diff is collapsed.
Click to expand it.
lib/untis/fetch.dart
+
9
−
3
View file @
91ebf683
...
...
@@ -40,10 +40,16 @@ class UntisFetch {
final
Map
<
TimetableOptions
,
CacheableTimetable
>
_timetables
=
{};
CacheableTimetable
timetableOf
(
int
classId
,
DateTime
date
)
{
final
TimetableOptions
options
=
(
classId
,
date
);
CacheableTimetable
timetableOf
({
required
ElementType
type
,
required
int
elementId
,
required
DateTime
date
,
})
{
final
TimetableOptions
options
=
(
type
,
elementId
,
date
);
return
_timetables
.
putIfAbsent
(
options
,
()
=
>
CacheableTimetable
(
this
,
date:
date
,
classId:
classId
));
options
,
()
=
>
CacheableTimetable
(
this
,
date:
date
,
type:
type
,
elementId:
elementId
));
}
Uri
_makeUri
(
RequestOptions
options
)
{
...
...
This diff is collapsed.
Click to expand it.
test/untis_test.dart
+
9
−
1
View file @
91ebf683
import
'package:better_untis/untis/element_type.dart'
;
import
'package:better_untis/untis/fetch.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
()
{
test
(
'Basic Untis call'
,
()
async
{
final
untis
=
UntisFetch
();
final
timetable
=
await
untis
.
timetableOf
(
20000
,
DateTime
.
now
())
.
fetched
;
final
cacheable
=
untis
.
timetableOf
(
type:
ElementType
.
classGroup
,
elementId:
20000
,
date:
DateTime
.
now
(),
);
final
timetable
=
await
cacheable
.
fetched
;
print
(
timetable
.
lessons
);
});
...
...
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