Skip to content

Commit

Permalink
Merge branch 'fix/nextcount' into 'main'
Browse files Browse the repository at this point in the history
fix apply count should update active counts

See merge request decidim/decidim-module-geo!166
  • Loading branch information
Hadrien Froger committed Nov 7, 2024
2 parents 62f4ece + b9c938e commit a73c8f8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
8 changes: 5 additions & 3 deletions app/jobs/decidim/geo/update_proposal_geo_index_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ def sync_proposal
resource_status: proposal.state,
component_id: proposal.decidim_component_id,
participatory_space_id: proposal.participatory_space.id,
participatory_space_type: proposal.participatory_space.manifest.name.to_s
participatory_space_type: proposal.participatory_space.manifest.name.to_s,
start_date: start_date,
end_date: end_date
)
))
true
rescue StandardError => e
Rails.logger.debug { "Can index #{e}" }
Rails.logger.warn { "ERROR: #{e}" }
false
end

Expand All @@ -51,7 +53,7 @@ def end_date
end

def space_wrapper
@space_wrapper ||= Decidim::Geo::ResourceWrapper.new(proposal.space)
@space_wrapper ||= Decidim::Geo::ResourceWrapper.new(proposal.participatory_space)
end

def remove_proposal
Expand Down
4 changes: 2 additions & 2 deletions app/packs/src/decidim/geo/stores/filterStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const onFilteredByScope = (filters) => {
if (selectedScope) selectScope(selectedScope);
else selectScope(null)
} else {
const toRepaintScope = scopeForId(previousScope.id)
const toRepaintScope = scopeForId(previousScope?.id)
selectScope(null);
if (toRepaintScope) {
toRepaintScope.repaint();
Expand Down Expand Up @@ -161,7 +161,7 @@ store.subscribe(

// Update active counters.
const { updateCurrentCountForFilters } = pointCounterStore.getState();
await updateCurrentCountForFilters(activeFilters);
const _count = await updateCurrentCountForFilters(activeFilters);
}
);

Expand Down
13 changes: 11 additions & 2 deletions lib/decidim/geo/generic_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ def image_url
end

def start_date
@start_date ||= (resource.start_time.to_date if resource.respond_to?(:start_time))
@start_date ||= if resource.respond_to?(:start_time)
resource.start_time.to_date
elsif resource.respond_to?(:start_date)
resource.start_date
end

end

def end_date
@end_date ||= (resource.end_time.to_date if resource.respond_to?(:end_time))
@end_date ||= if resource.respond_to?(:end_time)
resource.end_time.to_date
elsif resource.respond_to?(:end_date)
resource.end_date
end
end

def resource_url
Expand Down

0 comments on commit a73c8f8

Please sign in to comment.