FairEmail/app/src/main/java/eu/faircode/email/DaoLog.java

52 lines
1.6 KiB
Java
Raw Normal View History

2018-09-03 19:11:16 +00:00
package eu.faircode.email;
/*
This file is part of FairEmail.
FairEmail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2018-10-29 10:46:49 +00:00
FairEmail is distributed in the hope that it will be useful,
2018-09-03 19:11:16 +00:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
2018-10-29 10:46:49 +00:00
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
2018-09-03 19:11:16 +00:00
2024-01-01 07:50:49 +00:00
Copyright 2018-2024 by Marcel Bokhorst (M66B)
2018-09-03 19:11:16 +00:00
*/
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import java.util.List;
2018-09-03 19:11:16 +00:00
@Dao
public interface DaoLog {
2018-09-04 05:49:58 +00:00
@Query("SELECT * FROM log" +
" WHERE time > :from" +
2021-08-15 18:32:34 +00:00
" AND (:type IS NULL OR type = :type)" +
2021-03-16 07:09:58 +00:00
" ORDER BY time DESC" +
" LIMIT 2000")
2021-08-15 18:32:34 +00:00
LiveData<List<EntityLog>> liveLogs(long from, Integer type);
2018-09-04 05:49:58 +00:00
@Query("SELECT * FROM log" +
" WHERE time > :from" +
2021-08-15 18:32:34 +00:00
" AND (:type IS NULL OR type = :type)" +
2018-09-04 05:49:58 +00:00
" ORDER BY time DESC")
2021-08-15 18:32:34 +00:00
List<EntityLog> getLogs(long from, Integer type);
2018-09-03 19:11:16 +00:00
@Insert
long insertLog(EntityLog log);
2018-09-04 07:02:54 +00:00
@Query("DELETE FROM log" +
2021-01-17 11:27:28 +00:00
" WHERE id IN (SELECT id FROM log" +
" WHERE time < :before ORDER BY time LIMIT :limit)")
int deleteLogs(long before, int limit);
2018-09-03 19:11:16 +00:00
}