aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/packages_controller.rb4
-rw-r--r--app/repositories/category_repository.rb9
-rw-r--r--app/repositories/change_repository.rb9
-rw-r--r--app/repositories/commit_repository.rb9
-rw-r--r--app/repositories/package_repository.rb9
-rw-r--r--app/repositories/useflag_repository.rb9
-rw-r--r--app/repositories/version_repository.rb9
7 files changed, 56 insertions, 2 deletions
diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb
index 9580752..80a9448 100644
--- a/app/controllers/packages_controller.rb
+++ b/app/controllers/packages_controller.rb
@@ -25,7 +25,7 @@ class PackagesController < ApplicationController
@package = PackageRepository.find_by(:atom, params[:id])
fail ActionController::RoutingError, 'No such package' unless @package
- fresh_when etag: Time.parse(@package.updated_at), last_modified: Time.parse(@package.updated_at), public: true
+ fresh_when etag: @package.updated_at, last_modified: @package.updated_at, public: true
# Enable this in 2024 (when we have full-color emojis on a Linux desktop)
# @title = ' &#x1F4E6; %s' % @package.atom
@@ -37,7 +37,7 @@ class PackagesController < ApplicationController
@package = PackageRepository.find_by(:atom, params[:id])
fail ActionController::RoutingError, 'No such package' unless @package
- if stale?(etag: Time.parse(@package.updated_at), last_modified: Time.parse(@package.updated_at), public: true)
+ if stale?(etag: @package.updated_at, last_modified: @package.updated_at, public: true)
@changelog = Rails.cache.fetch("changelog/#{@package.atom}") do
CommitRepository.find_sorted_by('packages', @package.category + '/'+ @package.name, "date", "desc", 5)
end
diff --git a/app/repositories/category_repository.rb b/app/repositories/category_repository.rb
index d707df9..5757633 100644
--- a/app/repositories/category_repository.rb
+++ b/app/repositories/category_repository.rb
@@ -18,4 +18,13 @@ class CategoryRepository < BaseRepository
indexes :updated_at, type: 'date'
end
+ # Parse the "created_at" and "updated_at" fields in the document
+ #
+ def deserialize(document)
+ hash = document['_source']
+ hash['created_at'] = Time.parse(hash['created_at']).utc if hash['created_at']
+ hash['updated_at'] = Time.parse(hash['updated_at']).utc if hash['updated_at']
+ Category.new hash
+ end
+
end
diff --git a/app/repositories/change_repository.rb b/app/repositories/change_repository.rb
index d0e5177..84dca92 100644
--- a/app/repositories/change_repository.rb
+++ b/app/repositories/change_repository.rb
@@ -21,4 +21,13 @@ class ChangeRepository < BaseRepository
indexes :updated_at, type: 'date'
end
+ # Parse the "created_at" and "updated_at" fields in the document
+ #
+ def deserialize(document)
+ hash = document['_source']
+ hash['created_at'] = Time.parse(hash['created_at']).utc if hash['created_at']
+ hash['updated_at'] = Time.parse(hash['updated_at']).utc if hash['updated_at']
+ Change.new hash
+ end
+
end
diff --git a/app/repositories/commit_repository.rb b/app/repositories/commit_repository.rb
index 79702d8..b2086be 100644
--- a/app/repositories/commit_repository.rb
+++ b/app/repositories/commit_repository.rb
@@ -25,4 +25,13 @@ class CommitRepository < BaseRepository
indexes :updated_at, type: 'date'
end
+ # Parse the "created_at" and "updated_at" fields in the document
+ #
+ def deserialize(document)
+ hash = document['_source']
+ hash['created_at'] = Time.parse(hash['created_at']).utc if hash['created_at']
+ hash['updated_at'] = Time.parse(hash['updated_at']).utc if hash['updated_at']
+ Commit.new hash
+ end
+
end
diff --git a/app/repositories/package_repository.rb b/app/repositories/package_repository.rb
index 06856aa..dd516e9 100644
--- a/app/repositories/package_repository.rb
+++ b/app/repositories/package_repository.rb
@@ -214,4 +214,13 @@ class PackageRepository < BaseRepository
]
end
+ # Parse the "created_at" and "updated_at" fields in the document
+ #
+ def deserialize(document)
+ hash = document['_source']
+ hash['created_at'] = Time.parse(hash['created_at']).utc if hash['created_at']
+ hash['updated_at'] = Time.parse(hash['updated_at']).utc if hash['updated_at']
+ Package.new hash
+ end
+
end
diff --git a/app/repositories/useflag_repository.rb b/app/repositories/useflag_repository.rb
index 632de48..1481ac6 100644
--- a/app/repositories/useflag_repository.rb
+++ b/app/repositories/useflag_repository.rb
@@ -85,6 +85,15 @@ class UseflagRepository < BaseRepository
map_by_name find_all_by(:scope, 'use_expand')
end
+ # Parse the "created_at" and "updated_at" fields in the document
+ #
+ def deserialize(document)
+ hash = document['_source']
+ hash['created_at'] = Time.parse(hash['created_at']).utc if hash['created_at']
+ hash['updated_at'] = Time.parse(hash['updated_at']).utc if hash['updated_at']
+ Useflag.new hash
+ end
+
private
def map_by_name(collection)
diff --git a/app/repositories/version_repository.rb b/app/repositories/version_repository.rb
index 2932677..337ce38 100644
--- a/app/repositories/version_repository.rb
+++ b/app/repositories/version_repository.rb
@@ -54,4 +54,13 @@ class VersionRepository < BaseRepository
).response.aggregations['group_by_flag'].buckets
end
+ # Parse the "created_at" and "updated_at" fields in the document
+ #
+ def deserialize(document)
+ hash = document['_source']
+ hash['created_at'] = Time.parse(hash['created_at']).utc if hash['created_at']
+ hash['updated_at'] = Time.parse(hash['updated_at']).utc if hash['updated_at']
+ Version.new hash
+ end
+
end