Skip to content

Conversation

@mori-atsushi
Copy link
Collaborator

@mori-atsushi mori-atsushi commented Apr 29, 2019

/api/v1/chats にroom_keyと前回取得した最後のchat id(cursor)を指定することで、それより前の(cursor自体は含まない)過去チャットが取得できる。
cursorを指定しないときは最新のチャットを取得する

検討事項

  • websocketの方と合わせるため、並び順が普通と違うのですが、両方BFFで吸収する流れで大丈夫ですか?
  • IDでページングするため、ソートをIDに変更したが、問題ないか?

@codecov
Copy link

codecov bot commented Apr 29, 2019

Codecov Report

Merging #110 into development will increase coverage by 0.09%.
The diff coverage is 100%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #110      +/-   ##
===============================================
+ Coverage        97.59%   97.68%   +0.09%     
===============================================
  Files               33       34       +1     
  Lines              415      432      +17     
===============================================
+ Hits               405      422      +17     
  Misses              10       10
Impacted Files Coverage Δ
app/models/chat.rb 100% <100%> (ø) ⬆️
app/models/room.rb 100% <100%> (ø) ⬆️
app/controllers/api/v1/chats_controller.rb 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8eb25d8...e515c4a. Read the comment docs.

class Api::V1::ChatsController < ApplicationController
def index
room = Room.find_by(key: params[:room_key])
if room.blank?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI
こんな感じで毎回チェックするの面倒なので

ApiCommonにこんなの追加して

module ApiCommon
  included do
    rescue_from ActiveRecord::RecordNotFound do |_e|
      render json: { error: t("404 error") }, status: 404
    end
  end
end
class Api::V1::ChatsController < ApplicationController
  def index
    room = Room.find(key: params[:room_key])
    ...
  end
end

って書けた方が冗長な箇所がなくなって綺麗になると思う

return
end

if params[:cursor].present?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このifのチェックいらない気がする?
下のChat.find_byでnilが返るだけなので
https://github.com/cyder/SyncPod-server/pull/110/files#diff-95f5b6164012ab93315ecba597608414R17 は意味を為してない気がします

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants