トピックIDの配列によるトピック一覧の表示

In our company we use discourse for everyday business.
Discourse is deeply integrated in our erp software.
For better organization of topics,our erp holds many kind of topics ids and posts ids.
In some parts of our app we want to show user list of specific topics in discource. (filtered by our citiera).
In our app there is form which users fills and our app has array of filtered topics.

Is there a way to send query string or formdata to discource endpoint among with array of wanted topics ids and to get list of topics in discource. (ideally with predefined order or ordered as array was)

Same needs we have for getting specific lists of posts by providing array of topics ids.

「いいね!」 1

この機能も必要です。現在は以下のように実装していますが、非常に時間がかかりすぎます。

    const selectedTopics = this.selectedTopics
     // トピックID を受け取り、実際のトピックを返す
     this.selectedTopicsID.forEach(function(tid,index){
       Topic.find(tid,{}).then(results => {
         selectedTopics.pushObject(results)
       })
     });

plugin.rb で listcontroller を再オープンして新しいエンドポイントを追加し、フロントエンドのイニシャライザーで topic-list を再オープンして、以下のような処理を追加しようとしています。

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/models/topic-list.js.es6#L129

しかし、もっと簡単な方法があるはずです。ID 単位でトピックをまとめて取得するエンドポイントは本当に存在しないのでしょうか?

お手伝いいただければ大変助かります :smiley:

編集:この問題を自分で解決する方法は以下の通りです。

使い方は以下の通りです。

import TopicList from 'discourse/models/topic-list';
    const selectedTopics = this.selectedTopics
    // トピックID を受け取る
    TopicList.topics_array(this.selectedTopicsID).then(results => selectedTopics.pushObjects(results.topic_list.topics))

現状では「実際の」Topic オブジェクトを返さないという欠点がありますが、以下のような行を追加すれば修正できると思います。

これが正しい方法かどうか、セキュリティ上の問題がないかどうかはまだ確信が持てません。

別のアプローチとして、まずストアでレコードが存在するか確認し、存在しないものだけを fromMap を使って読み込む方法もあります。以下を参考にしてください。

とにかく、ここまでは長くなりすぎましたね :smiley:

これが私の最終的な解決策です。これで一区切りつけます。

「いいね!」 2