package com.apps.adrcotfas.goodtime.Database;

import com.apps.adrcotfas.goodtime.Session;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import static androidx.room.OnConflictStrategy.REPLACE;

@Dao
public interface SessionDao {

    @Query("select * from Session where id = :id")
    LiveData<Session> getSession(long id);

    @Query("select * from Session ORDER BY endTime DESC")
    LiveData<List<Session>> getAllSessionsByEndTime();

    @Query("select * from Session ORDER BY totalTime DESC")
    LiveData<List<Session>> getAllSessionsByDuration();

    @Insert(onConflict = REPLACE)
    void addSession(Session session);

    @Query("update Session SET endTime = :endTime, totalTime = :totalTime, label = :label WHERE id = :id")
    void editSession(long id, long endTime, long totalTime, String label);

    @Query("delete from Session where id = :id")
    void deleteSession(long id);

    @Query("delete from Session")
    void deleteAllSessions();
}

@@ -644,24 +644,159 @@
 uration();%0A%0A
+    @Query(%22select * from Session where label = :label ORDER BY endTime DESC%22)%0A    LiveData%3CList%3CSession%3E%3E getSessions(String label);%0A%0A
     @Insert(

add getSessions according to label