Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Shaharsol/eco 1574/tranlations csv by title#370

Open
shaharsol wants to merge 12 commits intomasterfrom
shaharsol/ECO-1574/tranlations_csv_by_title
Open

Shaharsol/eco 1574/tranlations csv by title#370
shaharsol wants to merge 12 commits intomasterfrom
shaharsol/ECO-1574/tranlations_csv_by_title

Conversation

@shaharsol
Copy link
Copy Markdown
Contributor

partial implementation of the suggested in the ticket. Didn't go as far as changing the db schema, just made sure template file read/write with be with offer.name as part of the key instead of offer.id. db offer_content and offer_content_translation still use offer_id

@shaharsol shaharsol requested a review from a team July 31, 2019 12:53
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 1, 2019

Codecov Report

Merging #370 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #370   +/-   ##
=======================================
  Coverage   58.05%   58.05%           
=======================================
  Files          50       50           
  Lines        3011     3011           
  Branches      444      444           
=======================================
  Hits         1748     1748           
  Misses       1258     1258           
  Partials        5        5

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c88cba...720d583. Read the comment docs.


function constructRow(contentType: ContentType, key: string, str: string) {
const path = `${ contentType }:${ key.replace(KEY_TO_PATH_REGEX, "$1") }`;
const path = `${ contentType }:${ key.replace(/:(.*?):/, ":").replace(/\[.\]/g, "") }`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move it out to a constant, it helps document your code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added a comment instead, much more useful

function constructRow(contentType: ContentType, key: string, str: string) {
const path = `${ contentType }:${ key.replace(KEY_TO_PATH_REGEX, "$1") }`;
const path = `${ contentType }:${ key.replace(/:(.*?):/, ":").replace(/\[.\]/g, "") }`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extra line is extra

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

allOffers.forEach(offer => {
const offerId = offer.id;
const offerName = offer.name;
const offerContent: OfferContent = allContent.filter(obj => obj.offerId === offerId)[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can change this to check for name and remove the offerId var completely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

much more clear to use offerId as pkey

import { OfferTranslation } from "../models/translations";
import { path } from "../utils/path";

import * as _ from "lodash";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really don't see why you need this, please reconsider.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

console.error("content eval failed: \neval string: %s\n error message: %s", evalString, e);
// const [table, offerId, column, jsonPath] = getCsvKeyElements(csvKey);
const [table, offerName, column, jsonPath] = getCsvKeyElements(csvKey);
const currentOffer = _.find(allOffers, function(offer: Offer) {
Copy link
Copy Markdown
Contributor

@liorama liorama Aug 12, 2019

Choose a reason for hiding this comment

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

Why lodash and not just allOffers.find()?

If you are doing this just to get the offer id in order to get to the offer content, you can just do one query and join the two tables together.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also use arrow functions instead of function definistions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

using js find instead. hard to get used to not using _

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants