Skip to content

Commit

Permalink
DEV: Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-brennan committed Oct 14, 2024
1 parent 6458350 commit 424a72e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/discourse_data_explorer/result_to_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module ::DiscourseDataExplorer
class ResultToMarkdown
def self.convert(pg_result, opts = {})
def self.convert(pg_result, render_url_columns = false)
relations, colrender = DataExplorer.add_extra_data(pg_result)
result_data = []

Expand Down Expand Up @@ -33,7 +33,7 @@ def self.convert(pg_result, opts = {})
else
row_data[col_index] = "#{related_row[column]} (#{col})"
end
elsif col_render == "url" && opts[:render_url_columns]
elsif col_render == "url" && render_url_columns
url, text = guess_url(col)
row_data[col_index] = "[#{text}](#{url})"
else
Expand All @@ -51,12 +51,7 @@ def self.convert(pg_result, opts = {})
end

def self.guess_url(column_value)
split = column_value.split(/,(.+)/)

if split.length > 1
text = split[0]
url = split[1]
end
text, url = column_value.split(/,(.+)/)

[url || column_value, text || column_value]
end
Expand Down

0 comments on commit 424a72e

Please sign in to comment.