contributte / contributte/datagrid

Feature: Aggregate over Arrays / via ArrayDataSource

Open
#1,167 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T: Feature
Dominant language
PHP
Stars
296
Forks
215
PR merge metrics
No merged PRs in 30d

Description

Greetings,

is it possible to accept ArrayDataSource|array as another type in \Contributte\Datagrid\AggregationFunction\IAggregationFunction::processDataSource() ?

Then to \Contributte\Datagrid\DataSource\ArrayDataSource something like following:

	public function processAggregation(IAggregationFunction $function): void
	{
		$function->processDataSource($this);
	}

And then into \Contributte\Datagrid\AggregationFunction\FunctionSum::processDataSource following part:

		if ( $dataSource instanceof ArrayDataSource) {
			foreach( $dataSource->getData() as $item )
				$this->result += $item[$this->column];
		}

		if ( is_array($dataSource)) {
			foreach( $dataSource as $item )
				$this->result += $item[$this->column];
		}

Use case:

Due sheer completness of dataset we cannot access the data from it directly via SQL, so we pre-calculate it in parts and then use it with aggregation. That makes us dependent on arrays / ArrayDataSource. And due limitation of other parts of Datagrid we must store its affected files locally and overwrite them on deploy.

Do you want PR? Discuss.

Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading IAggregationFunction::processDataSource(), DataSource/ArrayDataSource, and AggregationFunction/FunctionSum, which are the entry points named in the issue. Trace how aggregation currently receives data and identify the related implementations that need to accept arrays or ArrayDataSource. Done means aggregation can process both inputs for the stated pre-calculated dataset use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.