override fun findForUpdate()

in core/scm-owner/src/main/java/io/klibs/core/owner/ScmOwnerRepositoryJdbc.kt [138:165]


    override fun findForUpdate(): ScmOwnerEntity? {
        val sql = """
            SELECT id,
                   updated_at,
                   login,
                   id_native,
                   followers,
                   type,
                   name,
                   description,
                   homepage,
                   twitter_handle,
                   email,
                   location,
                   company
            FROM scm_owner
            WHERE updated_at < (current_timestamp - interval '23 hours')
            ORDER BY random()
            LIMIT 1
            FOR UPDATE
            SKIP LOCKED
        """.trimIndent()

        return jdbcClient.sql(sql)
            .query(SCM_OWNER_ENTITY_ROW_MAPPER)
            .optional()
            .getOrNull()
    }