summaryrefslogtreecommitdiff
path: root/lib/bitbucket_server
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-28 21:48:37 -0700
committerStan Hu <stanhu@gmail.com>2018-07-28 21:48:37 -0700
commitdd937377cf4cb8cfd2c4af713347d83c67278456 (patch)
tree13853af9a2be020cd36a49804311aa5c1c505b34 /lib/bitbucket_server
parentae6b48d20fe559a354ffd27bb07e4e09be2382da (diff)
downloadgitlab-ce-dd937377cf4cb8cfd2c4af713347d83c67278456.tar.gz
Use a class method to consolidate timestamp conversion
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r--lib/bitbucket_server/representation/activity.rb4
-rw-r--r--lib/bitbucket_server/representation/base.rb4
-rw-r--r--lib/bitbucket_server/representation/comment.rb4
-rw-r--r--lib/bitbucket_server/representation/pull_request.rb4
4 files changed, 10 insertions, 6 deletions
diff --git a/lib/bitbucket_server/representation/activity.rb b/lib/bitbucket_server/representation/activity.rb
index 2e6082bea87..a594b0881f6 100644
--- a/lib/bitbucket_server/representation/activity.rb
+++ b/lib/bitbucket_server/representation/activity.rb
@@ -38,11 +38,11 @@ module BitbucketServer
def merge_timestamp
timestamp = raw.dig('commit', 'committerTimestamp')
- Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer)
+ self.class.convert_timestamp(timestamp)
end
def created_at
- Time.at(created_date / 1000) if created_date.is_a?(Integer)
+ self.class.convert_timestamp(created_date)
end
private
diff --git a/lib/bitbucket_server/representation/base.rb b/lib/bitbucket_server/representation/base.rb
index 0f3f2b60f5a..a1961bae6ef 100644
--- a/lib/bitbucket_server/representation/base.rb
+++ b/lib/bitbucket_server/representation/base.rb
@@ -12,6 +12,10 @@ module BitbucketServer
def self.decorate(entries)
entries.map { |entry| new(entry)}
end
+
+ def self.convert_timestamp(time_usec)
+ Time.at(time_usec / 1000) if time_usec.is_a?(Integer)
+ end
end
end
end
diff --git a/lib/bitbucket_server/representation/comment.rb b/lib/bitbucket_server/representation/comment.rb
index 7a25ac8aed1..59c44589aae 100644
--- a/lib/bitbucket_server/representation/comment.rb
+++ b/lib/bitbucket_server/representation/comment.rb
@@ -40,11 +40,11 @@ module BitbucketServer
end
def created_at
- Time.at(created_date / 1000) if created_date.is_a?(Integer)
+ self.class.convert_timestamp(created_date)
end
def updated_at
- Time.at(updated_date / 1000) if updated_date.is_a?(Integer)
+ self.class.convert_timestamp(created_date)
end
# Bitbucket Server supports the ability to reply to any comment
diff --git a/lib/bitbucket_server/representation/pull_request.rb b/lib/bitbucket_server/representation/pull_request.rb
index 43f61683ddd..4bb00d22b0c 100644
--- a/lib/bitbucket_server/representation/pull_request.rb
+++ b/lib/bitbucket_server/representation/pull_request.rb
@@ -34,11 +34,11 @@ module BitbucketServer
end
def created_at
- Time.at(created_date / 1000) if created_date.is_a?(Integer)
+ self.class.convert_timestamp(created_date)
end
def updated_at
- Time.at(updated_date / 1000) if created_date.is_a?(Integer)
+ self.class.convert_timestamp(updated_date)
end
def title