diff options
author | 2019-10-15 00:13:16 +0200 | |
---|---|---|
committer | 2019-10-15 00:13:16 +0200 | |
commit | f8932b81db1062d72193936dddf8f86f0192ea61 (patch) | |
tree | 327f58fe0fb12c707b177a6223dd537eb2a5a04c /app | |
parent | Turn off dynamic mapping in all indexes (diff) | |
download | packages-5-f8932b81db1062d72193936dddf8f86f0192ea61.tar.gz packages-5-f8932b81db1062d72193936dddf8f86f0192ea61.tar.bz2 packages-5-f8932b81db1062d72193936dddf8f86f0192ea61.zip |
Fix the broken feeds
Due to the migration to the repository pattern in
elasticsearch-persistence the fields created_at and
updated_at are no longer automatically parsed. That's
why the feeds have been broken, as they rely on the
parsed dates.
To fix this problem, we manually parse the dates during
the deserialization now.
Fixes https://bugs.gentoo.org/697666
Signed-off-by: Max Magorsch <max@magorsch.de>
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/packages_controller.rb | 4 | ||||
-rw-r--r-- | app/repositories/category_repository.rb | 9 | ||||
-rw-r--r-- | app/repositories/change_repository.rb | 9 | ||||
-rw-r--r-- | app/repositories/commit_repository.rb | 9 | ||||
-rw-r--r-- | app/repositories/package_repository.rb | 9 | ||||
-rw-r--r-- | app/repositories/useflag_repository.rb | 9 | ||||
-rw-r--r-- | app/repositories/version_repository.rb | 9 |
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 = ' 📦 %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 |