@glissandoo/lib 1.10.1 → 1.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/functions/groupRepertory.d.ts +6 -0
- package/functions/index.d.ts +1 -0
- package/functions/index.js +1 -0
- package/functions/regions.js +1 -0
- package/helpers/rates.d.ts +12 -0
- package/helpers/rates.js +31 -0
- package/models/Group/Repertory/index.d.ts +1 -0
- package/models/Group/Repertory/index.js +5 -3
- package/package.json +1 -1
|
@@ -52,5 +52,11 @@ export declare namespace GroupRepertoryFbFunctionsTypes {
|
|
|
52
52
|
score?: number;
|
|
53
53
|
}
|
|
54
54
|
export type IdentifyInstrumentsResult = IdentifyInstrumentItem[];
|
|
55
|
+
export interface RateParams {
|
|
56
|
+
groupId: string;
|
|
57
|
+
themeId: string;
|
|
58
|
+
value: number;
|
|
59
|
+
}
|
|
60
|
+
export type RateResult = void;
|
|
55
61
|
export {};
|
|
56
62
|
}
|
package/functions/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare enum FbFunctionName {
|
|
|
57
57
|
GroupRepertoryOnUpdate = "groupRepertory-onUpdate",
|
|
58
58
|
GroupRepertoryPublish = "groupRepertory-publish",
|
|
59
59
|
GroupRepertoryRemove = "groupRepertory-remove",
|
|
60
|
+
GroupRepertoryRate = "groupRepertory-rate",
|
|
60
61
|
GroupSendInvitationEmail = "group-sendInvitationEmail",
|
|
61
62
|
JWTGenerate = "jwt-generate",
|
|
62
63
|
MetricsDaily = "metrics-daily",
|
package/functions/index.js
CHANGED
|
@@ -61,6 +61,7 @@ var FbFunctionName;
|
|
|
61
61
|
FbFunctionName["GroupRepertoryOnUpdate"] = "groupRepertory-onUpdate";
|
|
62
62
|
FbFunctionName["GroupRepertoryPublish"] = "groupRepertory-publish";
|
|
63
63
|
FbFunctionName["GroupRepertoryRemove"] = "groupRepertory-remove";
|
|
64
|
+
FbFunctionName["GroupRepertoryRate"] = "groupRepertory-rate";
|
|
64
65
|
FbFunctionName["GroupSendInvitationEmail"] = "group-sendInvitationEmail";
|
|
65
66
|
FbFunctionName["JWTGenerate"] = "jwt-generate";
|
|
66
67
|
FbFunctionName["MetricsDaily"] = "metrics-daily";
|
package/functions/regions.js
CHANGED
|
@@ -35,6 +35,7 @@ const regionByFunctions = {
|
|
|
35
35
|
[index_1.FbFunctionName.GroupRepertoryPublish]: GCloudRegions.UsCentral1,
|
|
36
36
|
[index_1.FbFunctionName.GroupRepertoryEdit]: GCloudRegions.UsCentral1,
|
|
37
37
|
[index_1.FbFunctionName.GroupRepertoryRemove]: GCloudRegions.UsCentral1,
|
|
38
|
+
[index_1.FbFunctionName.GroupRepertoryRate]: GCloudRegions.EuropeWest6,
|
|
38
39
|
[index_1.FbFunctionName.GroupRepertoryDownloadThemeFiles]: GCloudRegions.UsCentral1,
|
|
39
40
|
[index_1.FbFunctionName.GroupRepertoryIdentifyInstruments]: GCloudRegions.UsCentral1,
|
|
40
41
|
[index_1.FbFunctionName.GroupRepertoryClaimMusicSheet]: GCloudRegions.UsCentral1,
|
package/helpers/rates.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStepRating = exports.rateSteps = void 0;
|
|
4
|
+
exports.rateSteps = [
|
|
5
|
+
{
|
|
6
|
+
id: 'love',
|
|
7
|
+
emoji: '😍',
|
|
8
|
+
value: 4,
|
|
9
|
+
range: [3.25, 4],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: 'like',
|
|
13
|
+
emoji: '🙂',
|
|
14
|
+
value: 3,
|
|
15
|
+
range: [2.5, 3.24],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'neutral',
|
|
19
|
+
emoji: '😕',
|
|
20
|
+
value: 2,
|
|
21
|
+
range: [1.75, 2.49],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'dislike',
|
|
25
|
+
emoji: '😭',
|
|
26
|
+
value: 1,
|
|
27
|
+
range: [1, 1.74],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
const getStepRating = (rating) => exports.rateSteps.find((step) => rating >= step.range[0] && rating <= step.range[1]);
|
|
31
|
+
exports.getStepRating = getStepRating;
|
|
@@ -16,6 +16,7 @@ export default class GroupRepertory extends Theme<GroupRepertoryData> {
|
|
|
16
16
|
}[];
|
|
17
17
|
get mainFilePath(): string | null;
|
|
18
18
|
get votes(): Record<string, number>;
|
|
19
|
+
get votesCount(): number;
|
|
19
20
|
voteByUserId(userId: string): number | null;
|
|
20
21
|
get rating(): number;
|
|
21
22
|
get events(): string[];
|
|
@@ -32,15 +32,17 @@ class GroupRepertory extends basic_1.default {
|
|
|
32
32
|
get votes() {
|
|
33
33
|
return this.data.votes || {};
|
|
34
34
|
}
|
|
35
|
+
get votesCount() {
|
|
36
|
+
return Object.keys(this.votes).length;
|
|
37
|
+
}
|
|
35
38
|
voteByUserId(userId) {
|
|
36
39
|
return this.votes[userId] || null;
|
|
37
40
|
}
|
|
38
41
|
get rating() {
|
|
39
|
-
const numberVotes = Object.keys(this.votes).length;
|
|
40
42
|
const totalVotes = Object.entries(this.votes).reduce((acc, [, value]) => acc + value, 0);
|
|
41
|
-
if (
|
|
43
|
+
if (this.votesCount === 0 || totalVotes === 0)
|
|
42
44
|
return 0;
|
|
43
|
-
return Math.round((
|
|
45
|
+
return Math.round((totalVotes / this.votesCount) * 100) / 100;
|
|
44
46
|
}
|
|
45
47
|
get events() {
|
|
46
48
|
return this.data.events || [];
|