This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(matomo): add monthly download stats (#36)
- Loading branch information
Showing
13 changed files
with
158 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { parseISO } from "date-fns"; | ||
|
||
import { getLastMonthsRanges } from "./date"; | ||
|
||
describe("date", () => { | ||
describe("getLastMonthsRanges", () => { | ||
it("should compute the last months ranges", () => { | ||
const startDate = parseISO("2021-02-10"); | ||
expect(getLastMonthsRanges(3)(startDate)).toEqual([ | ||
["2021-02-01", "2021-02-10"], | ||
["2021-01-01", "2021-01-31"], | ||
["2020-12-01", "2020-12-31"], | ||
]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { endOfMonth, formatISO, startOfMonth, subMonths } from "date-fns"; | ||
import { range } from "lodash"; | ||
|
||
export const getLastMonthsRanges = (monthCount: number) => ( | ||
now: Date | ||
): [string, string][] => | ||
range(monthCount) | ||
.map((index) => subMonths(now, index)) | ||
.map((date, index): [Date, Date] => [ | ||
startOfMonth(date), | ||
index === 0 ? date : endOfMonth(date), | ||
]) | ||
.map( | ||
(dates): [string, string] => | ||
dates.map((date) => formatISO(date, { representation: "date" })) as [ | ||
string, | ||
string | ||
] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Lift method for promise | ||
* @param method | ||
*/ | ||
export const liftPromise = <TInput, TOutput>( | ||
method: (input: TInput) => TOutput | ||
) => async (promise: Promise<TInput>): Promise<TOutput> => promise.then(method); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters