package com.github.stakkato95.sprint3.database;

import com.github.stakkato95.sprint3.database.table.Constant;
import com.github.stakkato95.sprint3.model.local.BaseModel;
import com.github.stakkato95.sprint3.model.local.Comment;
import com.github.stakkato95.sprint3.model.local.Favourite;
import com.github.stakkato95.sprint3.model.local.Post;
import com.github.stakkato95.sprint3.model.local.Rating;
import com.github.stakkato95.sprint3.model.local.XUser;

public class DatabaseFilter {

    public static String orderDescending() {
        return Constant.DATE_TIME_CAST + "(" + BaseModel.CREATED_AT + ")" + Constant.ORDER_DESC;
    }

    public static String whereForPostTime() {
        return BaseModel.CREATED_AT + ">=" + Constant.DATE_TIME_CAST + "(?)";
    }

    public static String whereForPostRating() {
        return Post.RATING + ">=?";
    }

    public static String whereForComments() {
        return Comment.POST_ID + "=?";
    }

    public static String whereForObjectId() {
        return Post.OBJECT_ID + "=?";
    }

    public static String whereForPostId() {
        return Favourite.POST_ID + "=?";
    }

    public static String whereForRating() {
        return Rating.VALUE + "=?";
    }

    public static String whereForSearch() {
        return Post.TITLE + Constant.LIKE + "?" + Constant.OR + Post.TEXT + Constant.LIKE + "?";
    }

    public static String whereForActiveUser() {
        return XUser.ACTIVE + "=?";
    }
}
