Hebe: add subjects
This commit is contained in:
parent
f297e64731
commit
f484b1da90
6 changed files with 58 additions and 9 deletions
|
@ -3,8 +3,8 @@ public final class io/github/wulkanowy/sdk/hebe/Hebe {
|
|||
public final fun addInterceptor (Lokhttp3/Interceptor;Z)V
|
||||
public static synthetic fun addInterceptor$default (Lio/github/wulkanowy/sdk/hebe/Hebe;Lokhttp3/Interceptor;ZILjava/lang/Object;)V
|
||||
public final fun getAttendance (ILjava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getAttendanceSummary (ILjava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getAttendanceSummaryForWholeYear (ILjava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getAttendanceSummary (ILjava/time/LocalDate;Ljava/time/LocalDate;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getAttendanceSummaryForWholeYear (ILjava/time/LocalDate;Ljava/time/LocalDate;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getBaseUrl ()Ljava/lang/String;
|
||||
public final fun getDeviceModel ()Ljava/lang/String;
|
||||
public final fun getExams (Ljava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
|
@ -24,6 +24,7 @@ public final class io/github/wulkanowy/sdk/hebe/Hebe {
|
|||
public final fun getSchedule (ILjava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getSchoolId ()Ljava/lang/String;
|
||||
public final fun getStudents (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getSubjects (IILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getTeachers (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun register (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun register$default (Lio/github/wulkanowy/sdk/hebe/Hebe;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
|
@ -2241,6 +2242,19 @@ public final class io/github/wulkanowy/sdk/hebe/models/SetMessageStatusRequest$C
|
|||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class io/github/wulkanowy/sdk/hebe/models/Subject {
|
||||
public fun <init> (ILjava/lang/String;)V
|
||||
public final fun component1 ()I
|
||||
public final fun component2 ()Ljava/lang/String;
|
||||
public final fun copy (ILjava/lang/String;)Lio/github/wulkanowy/sdk/hebe/models/Subject;
|
||||
public static synthetic fun copy$default (Lio/github/wulkanowy/sdk/hebe/models/Subject;ILjava/lang/String;ILjava/lang/Object;)Lio/github/wulkanowy/sdk/hebe/models/Subject;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getId ()I
|
||||
public final fun getName ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class io/github/wulkanowy/sdk/hebe/models/Teacher {
|
||||
public static final field Companion Lio/github/wulkanowy/sdk/hebe/models/Teacher$Companion;
|
||||
public fun <init> (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.github.wulkanowy.sdk.hebe.models.Lesson
|
|||
import io.github.wulkanowy.sdk.hebe.models.Mailbox
|
||||
import io.github.wulkanowy.sdk.hebe.models.Meeting
|
||||
import io.github.wulkanowy.sdk.hebe.models.Message
|
||||
import io.github.wulkanowy.sdk.hebe.models.Subject
|
||||
import io.github.wulkanowy.sdk.hebe.models.Teacher
|
||||
import io.github.wulkanowy.sdk.hebe.models.TimetableFull
|
||||
import io.github.wulkanowy.sdk.hebe.models.TimetableHeader
|
||||
|
@ -221,8 +222,13 @@ class Hebe {
|
|||
)
|
||||
}
|
||||
|
||||
suspend fun getAttendanceSummary(pupilId: Int, startDate: LocalDate, endDate: LocalDate): AttendanceSummary {
|
||||
val completedLessons = studentRepository.getCompletedLessons(pupilId, startDate, endDate)
|
||||
suspend fun getAttendanceSummary(pupilId: Int, startDate: LocalDate, endDate: LocalDate, subjectId: Int): AttendanceSummary {
|
||||
var completedLessons = studentRepository.getCompletedLessons(pupilId, startDate, endDate)
|
||||
if (subjectId != -1) {
|
||||
completedLessons = completedLessons.filter {
|
||||
it.subject?.id == subjectId
|
||||
}
|
||||
}
|
||||
var presences = 0
|
||||
var absences = 0
|
||||
var legalAbsences = 0
|
||||
|
@ -257,7 +263,7 @@ class Hebe {
|
|||
)
|
||||
}
|
||||
|
||||
suspend fun getAttendanceSummaryForWholeYear(pupilId: Int, startDate: LocalDate, endDate: LocalDate): List<AttendanceSummary> {
|
||||
suspend fun getAttendanceSummaryForWholeYear(pupilId: Int, startDate: LocalDate, endDate: LocalDate, subjectId: Int): List<AttendanceSummary> {
|
||||
val months = ChronoUnit.MONTHS.between(startDate, endDate)
|
||||
val summaries = arrayListOf<AttendanceSummary>()
|
||||
|
||||
|
@ -267,6 +273,7 @@ class Hebe {
|
|||
pupilId,
|
||||
startDate.plusMonths(i).minusDays(startDate.dayOfMonth.toLong() - 1),
|
||||
startDate.plusMonths(i + 1).minusDays(startDate.dayOfMonth.toLong() - 1),
|
||||
subjectId,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -284,6 +291,17 @@ class Hebe {
|
|||
suspend fun getNotes(pupilId: Int) = studentRepository
|
||||
.getNotes(pupilId = pupilId)
|
||||
|
||||
suspend fun getSubjects(pupilId: Int, periodId: Int): List<Subject> = studentRepository
|
||||
.getGrades(
|
||||
pupilId = pupilId,
|
||||
periodId = periodId,
|
||||
).map {
|
||||
Subject(
|
||||
id = it.column.subject.id,
|
||||
name = it.column.subject.name,
|
||||
)
|
||||
}.distinctBy { it.id }
|
||||
|
||||
suspend fun setMessageStatus(pupilId: Int?, boxKey: String, messageKey: String, status: Int): Boolean? = studentRepository.setMessageStatus(
|
||||
pupilId = pupilId,
|
||||
boxKey = boxKey,
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package io.github.wulkanowy.sdk.hebe.models
|
||||
|
||||
data class Subject(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
)
|
|
@ -82,7 +82,7 @@ public final class io/github/wulkanowy/sdk/Sdk {
|
|||
public final fun getStudentsHybrid (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun getStudentsHybrid$default (Lio/github/wulkanowy/sdk/Sdk;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public final fun getStudentsTrips (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getSubjects (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getSubjects (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getSymbol ()Ljava/lang/String;
|
||||
public final fun getTeachers (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun getTimetable (Ljava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
|
|
|
@ -450,6 +450,7 @@ class Sdk {
|
|||
pupilId = studentId,
|
||||
startDate = startDate,
|
||||
endDate = endDate,
|
||||
subjectId = subjectId ?: -1,
|
||||
).mapAttendanceSummary()
|
||||
}
|
||||
}
|
||||
|
@ -461,10 +462,10 @@ class Sdk {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getSubjects(): List<Subject> = withContext(Dispatchers.IO) {
|
||||
suspend fun getSubjects(periodId: Int): List<Subject> = withContext(Dispatchers.IO) {
|
||||
when (mode) {
|
||||
Mode.HYBRID, Mode.SCRAPPER -> scrapper.getSubjects().mapSubjects()
|
||||
Mode.HEBE -> throw NotImplementedError("Not available in HEBE mode")
|
||||
Mode.SCRAPPER -> scrapper.getSubjects().mapSubjects()
|
||||
Mode.HYBRID, Mode.HEBE -> hebe.getSubjects(studentId, periodId).mapSubjects()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
package io.github.wulkanowy.sdk.mapper
|
||||
|
||||
import io.github.wulkanowy.sdk.pojo.Subject
|
||||
import io.github.wulkanowy.sdk.hebe.models.Subject as HebeSubject
|
||||
import io.github.wulkanowy.sdk.scrapper.attendance.Subject as ScrapperSubject
|
||||
|
||||
@JvmName("mapScrapperSubject")
|
||||
internal fun List<ScrapperSubject>.mapSubjects(): List<Subject> = map {
|
||||
Subject(
|
||||
id = it.value,
|
||||
name = it.name,
|
||||
)
|
||||
}
|
||||
|
||||
@JvmName("mapHebeSubject")
|
||||
internal fun List<HebeSubject>.mapSubjects(): List<Subject> = map {
|
||||
Subject(
|
||||
id = it.id,
|
||||
name = it.name,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue