Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

add function to prune old files #8

Merged
merged 8 commits into from
May 29, 2018
Merged

Conversation

markysoft
Copy link
Contributor

No description provided.

@markysoft markysoft added the WIP label May 22, 2018
@markysoft markysoft changed the title ❌ add function to prune old files add function to prune old files May 29, 2018
@markysoft markysoft removed the WIP label May 29, 2018
@markysoft markysoft requested a review from st3v3nhunt May 29, 2018 09:51
Copy link
Contributor

@st3v3nhunt st3v3nhunt left a comment

Choose a reason for hiding this comment

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

A few small suggestions.

@@ -28,6 +23,11 @@ class AzureDataService {
validateConfig(this);
}

// eslint-disable-next-line class-methods-use-this
Copy link
Contributor

Choose a reason for hiding this comment

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

In order to avoid disabling eslint, if the format was set as a class level variable e.g. this.dateFormat = 'YYYYMMDD';, the variable could be used within the function e.g. return `-${startMoment.format(this.dateFormat)}.json`;. It could also be used in the following function and remove the duplication.
It might be worth moving the definition of dateFormat (should the suggestion above be followed) into lib/config.js so the other modules can access it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot, I'll move the dateFormat to a class member first, then see where else 'YYYYMMDD' is used for further improvements

await azureService.deleteFromAzure(containerName, `${azureDataService.seedIdFile}-20180314.json`);
});

it('should remove data files older than date', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given this test and the 2 following it execute the same function i.e pruneFilesOlderThan() and use some of the same functions to get the list of files in the blob. Could the setup be done for all 3 tests in one go and have the filters and expectations run separately? I know it is largely personal preference, the reason for changing would be to make it clear there is just one function being run that ends up prune all files.
It would also reduce the execution time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that makes sense, as that way there's a symmetry to the setup before and the teardown afterwards.

lib/filters.js Outdated
const regex = new RegExp(`^${outputFile}-(\\d{8})-${version}.json`);
return file => dateExpired(regex, file, oldestDate);
}
function createExpiredSummaryFilter(outputFile, summaryFile, version, oldestDate) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit finickity but could the inconsistent spacing be fixed please? Ideally to have a line between each function.

@st3v3nhunt st3v3nhunt merged commit 272784f into master May 29, 2018
@st3v3nhunt st3v3nhunt deleted the feature/prune-old-files branch May 29, 2018 14:13
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