Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: getting tables columns #10

Merged
merged 3 commits into from Apr 6, 2022

Conversation

ondrajodas
Copy link
Collaborator

@ondrajodas ondrajodas changed the title refactoring getting tables columns Refactoring: getting tables columns Apr 6, 2022
@ondrajodas ondrajodas marked this pull request as ready for review April 6, 2022 08:06
@ondrajodas
Copy link
Collaborator Author

ondrajodas commented Apr 6, 2022

změnil jsem postup pro načítání názvů sloupečků a dat:

  • google nemusel vracet vždy pro všechny záznamy stejný počet sloupců (někdy pro to neměl data tak to prostě nevrátil)
  • teď načtu sloupečky přímo z query a těm postupně pro každý řádek přiřazuju data
  • pokud data nejsou tak dáme null (prázdnou hodnotu)
  • tím by mělo být zachované pořadí a stejný počet sloupců
  • zjednodušil jsem "base" metodu a vytváření manifestů jsem přesunul do příslušných metod (customers/campaigns/report)
  • testy zůstali stejné, takže základní funkcionalita zůstala stejná

@@ -21,7 +21,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& /tmp/composer-install.sh

# Install and configure the C implementation of Protobuf extension if needed.
RUN pecl install protobuf; echo 'extension=protobuf.so' >> $PHP_INI_DIR/conf.d/protobuf.ini;
RUN pecl install protobuf-3.19.4; echo 'extension=protobuf.so' >> $PHP_INI_DIR/conf.d/protobuf.ini;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je nová verze protobuf která ale nefunguje
protocolbuffers/protobuf#9724

private const USER_TABLES_STRUCTURE = [
self::CUSTOMER_TABLE => [
'primaryKeys' => ['id'],
'columns' => [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columns už nepotřebuju - stahuju z query

Comment on lines -86 to -87
$csvCustomer = new CsvWriter(sprintf('%s/out/tables/%s.csv', $this->dataDir, self::CUSTOMER_TABLE));
$csvCampaign = new CsvWriter(sprintf('%s/out/tables/%s.csv', $this->dataDir, self::CAMPAIGN_TABLE));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

přesunuto do vlastních metod customers/campaigns

@@ -120,47 +82,9 @@ public function extract(): void
));
}
}

// Create manifest for Customer
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

přesunuto do vlastních metod customers/campaigns

$columnData = $data;
foreach (explode('.', $columnKey) as $key) {
if (!array_key_exists($key, $columnData)) {
$output[$columnName] = null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data pro sloupeček neexistují => null

$column = implode('.', $column);
}
$columnKey = lcfirst(str_replace('_', '', ucwords($column, '_')));
$columnValue = lcfirst(str_replace(['.', '_'], '', ucwords($column, '._')));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

musíme nahradit customer.time_zone za customerTimeZone

Copy link
Collaborator

@michaljurecko michaljurecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Na ten mechanizmus nahradzovania chybajuceho stlpca s null by sa hodil nejaky unit test.
Tj, vstup s vynechanymi stlpcami, a v nahodnom poradi -> no spravny vystup.

@ondrajodas ondrajodas force-pushed the ondra-change-getting-columns branch from 3964280 to 13c61b0 Compare April 6, 2022 08:43
@ondrajodas ondrajodas merged commit 35b4675 into master Apr 6, 2022
@ondrajodas ondrajodas deleted the ondra-change-getting-columns branch April 6, 2022 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants