<commit_before>package com.satsumasoftware.timetable.db.util

import android.app.Application
import android.content.ContentValues
import android.content.Context
import android.util.Log
import com.satsumasoftware.timetable.DateUtils
import com.satsumasoftware.timetable.TimetableApplication
import com.satsumasoftware.timetable.db.ExamsSchema
import com.satsumasoftware.timetable.db.TimetableDbHelper
import com.satsumasoftware.timetable.framework.Exam
import com.satsumasoftware.timetable.receiver.AlarmReceiver
import java.util.*

class ExamUtils {

    companion object {

        const val LOG_TAG = "ExamUtils"

        @JvmStatic fun getExams(context: Context, application: Application): ArrayList<Exam> {
            val exams = ArrayList<Exam>()

            val timetable = (application as TimetableApplication).currentTimetable!!

            val dbHelper = TimetableDbHelper.getInstance(context)
            val cursor = dbHelper.readableDatabase.query(
                    ExamsSchema.TABLE_NAME,
                    null,
                    "${ExamsSchema.COL_TIMETABLE_ID}=?",
                    arrayOf(timetable.id.toString()),
                    null, null, null)
            cursor.moveToFirst()
            while (!cursor.isAfterLast) {
                exams.add(Exam(cursor))
                cursor.moveToNext()
            }
            cursor.close()
            return exams
        }

        @JvmStatic fun getAllExams(context: Context): ArrayList<Exam> {
            val exams = ArrayList<Exam>()
            val dbHelper = TimetableDbHelper.getInstance(context)
            val cursor = dbHelper.readableDatabase.query(
                    ExamsSchema.TABLE_NAME, null, null, null, null, null, null)
            cursor.moveToFirst()
            while (!cursor.isAfterLast) {
                exams.add(Exam(cursor))
                cursor.moveToNext()
            }
            cursor.close()
            return exams
        }

        @JvmStatic fun getExamWithId(context: Context, examId: Int): Exam? {
            val db = TimetableDbHelper.getInstance(context).readableDatabase
            val cursor = db.query(
                    ExamsSchema.TABLE_NAME,
                    null,
                    "${ExamsSchema._ID}=?",
                    arrayOf(examId.toString()),
                    null, null, null)
            cursor.moveToFirst()
            if (cursor.count == 0) {
                cursor.close()
                return null
            }
            val exam = Exam(cursor)
            cursor.close()
            return exam
        }

        @JvmStatic fun getExamsForSubject(context: Context, subjectId: Int): ArrayList<Exam> {
            val exams = ArrayList<Exam>()
            val dbHelper = TimetableDbHelper.getInstance(context)
            val cursor = dbHelper.readableDatabase.query(
                    ExamsSchema.TABLE_NAME,
                    null,
                    "${ExamsSchema.COL_SUBJECT_ID}=?",
                    arrayOf(subjectId.toString()),
                    null, null, null)
            cursor.moveToFirst()
            while (!cursor.isAfterLast) {
                exams.add(Exam(cursor))
                cursor.moveToNext()<commit_msg>Remember to delete the redundant function<commit_after>package com.satsumasoftware.timetable.db.util

import android.app.Application
import android.content.ContentValues
import android.content.Context
import android.util.Log
import com.satsumasoftware.timetable.DateUtils
import com.satsumasoftware.timetable.TimetableApplication
import com.satsumasoftware.timetable.db.ExamsSchema
import com.satsumasoftware.timetable.db.TimetableDbHelper
import com.satsumasoftware.timetable.framework.Exam
import com.satsumasoftware.timetable.receiver.AlarmReceiver
import java.util.*

class ExamUtils {

    companion object {

        const val LOG_TAG = "ExamUtils"

        @JvmStatic fun getExams(context: Context, application: Application): ArrayList<Exam> {
            val exams = ArrayList<Exam>()

            val timetable = (application as TimetableApplication).currentTimetable!!

            val dbHelper = TimetableDbHelper.getInstance(context)
            val cursor = dbHelper.readableDatabase.query(
                    ExamsSchema.TABLE_NAME,
                    null,
                    "${ExamsSchema.COL_TIMETABLE_ID}=?",
                    arrayOf(timetable.id.toString()),
                    null, null, null)
            cursor.moveToFirst()
            while (!cursor.isAfterLast) {
                exams.add(Exam(cursor))
                cursor.moveToNext()
            }
            cursor.close()
            return exams
        }

        @JvmStatic fun getAllExams(context: Context): ArrayList<Exam> {
            val exams = ArrayList<Exam>()
            val dbHelper = TimetableDbHelper.getInstance(context)
            val cursor = dbHelper.readableDatabase.query(
                    ExamsSchema.TABLE_NAME, null, null, null, null, null, null)
            cursor.moveToFirst()
            while (!cursor.isAfterLast) {
                exams.add(Exam(cursor))
                cursor.moveToNext()
            }
            cursor.close()
            return exams
        }

        @JvmStatic fun getExamsForSubject(context: Context, subjectId: Int): ArrayList<Exam> {
            val exams = ArrayList<Exam>()
            val dbHelper = TimetableDbHelper.getInstance(context)
            val cursor = dbHelper.readableDatabase.query(
                    ExamsSchema.TABLE_NAME,
                    null,
                    "${ExamsSchema.COL_SUBJECT_ID}=?",
                    arrayOf(subjectId.toString()),
                    null, null, null)
            cursor.moveToFirst()
            while (!cursor.isAfterLast) {
                exams.add(Exam(cursor))
                cursor.moveToNext()
{'fraction_non_alphanumeric': 0.08758125213821416, 'fraction_numerical': 0.00017105713308244953, 'mean_word_length': 1.9031777557100298, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2769978', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1485, 'n_words': 287}