Skip to content

Commit d410a4b

Browse files
github-actions[bot]slaveeksDobruniae11sy
authored
Update prod (#461)
* chore: added try-catch for sending report (#457) * chore: added try-catch for sending report * added res log * chore(license): adopt BSL 1.1 (#460) * chore: update license to BUSL-1.1 in package.json and README.md * chore: update licensed work reference in LICENSE file * imp(): get rid of duplicated releases (#462) * imp(): get rid of duplicated releases * chore(): eslint fix --------- Co-authored-by: Vyacheslav Chernyshev <81693471+slaveeks@users.noreply.github.com> Co-authored-by: Dobrunia Kostrigin <48620984+Dobrunia@users.noreply.github.com> Co-authored-by: e11sy <130844513+e11sy@users.noreply.github.com>
1 parent 2e27f56 commit d410a4b

File tree

5 files changed

+291
-77
lines changed

5 files changed

+291
-77
lines changed

LICENSE

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Business Source License 1.1
2+
3+
Parameters
4+
5+
Licensor: CodeX (Hawk)
6+
Licensed Work: hawk.workers (https://github.com/codex-team/hawk.workers)
7+
The Licensed Work is © 2025 CodeX
8+
Additional Use Grant: Self-hosted use for own/internal needs and research/evaluation is permitted.
9+
Using this code to provide a competing error-tracking SaaS or commercial
10+
hosted service without the Licensor’s prior permission is prohibited.
11+
12+
Change Date: 2030-01-01
13+
14+
Change License: AGPL-3.0
15+
16+
-------------------------------------------------------------------------------
17+
18+
License text copyright © 2024 MariaDB plc, All Rights Reserved.
19+
“Business Source License” is a trademark of MariaDB plc.
20+
21+
Terms
22+
23+
The Licensor hereby grants you the right to copy, modify, create derivative
24+
works, redistribute, and make non-production use of the Licensed Work. The
25+
Licensor may make an Additional Use Grant, above, permitting limited
26+
production use.
27+
28+
Effective on the Change Date, or the fourth anniversary of the first publicly
29+
available distribution of a specific version of the Licensed Work under this
30+
License, whichever comes first, the Licensor hereby grants you rights under
31+
the terms of the Change License, and the rights granted in the paragraph
32+
above terminate.
33+
34+
If your use of the Licensed Work does not comply with the requirements
35+
currently in effect as described in this License, you must purchase a
36+
commercial license from the Licensor, its affiliated entities, or authorized
37+
resellers, or you must refrain from using the Licensed Work.
38+
39+
All copies of the original and modified Licensed Work, and derivative works
40+
of the Licensed Work, are subject to this License. This License applies
41+
separately for each version of the Licensed Work and the Change Date may vary
42+
for each version of the Licensed Work released by Licensor.
43+
44+
You must conspicuously display this License on each original or modified copy
45+
of the Licensed Work. If you receive the Licensed Work in original or
46+
modified form from a third party, the terms and conditions set forth in this
47+
License apply to your use of that work.
48+
49+
Any use of the Licensed Work in violation of this License will automatically
50+
terminate your rights under this License for the current and all other
51+
versions of the Licensed Work.
52+
53+
This License does not grant you any right in any trademark or logo of
54+
Licensor or its affiliates (provided that you may use a trademark or logo of
55+
Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY
56+
APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN “AS IS” BASIS. LICENSOR
57+
HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING
58+
(WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
59+
PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to
60+
use this License’s text to license your works, and to refer to it using the
61+
trademark “Business Source License”, as long as you comply with the Covenants
62+
of Licensor below.
63+
64+
Covenants of Licensor
65+
66+
In consideration of the right to use this License’s text and the “Business
67+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
68+
other recipients of the licensed work to be provided by Licensor:
69+
70+
1. To specify as the Change License the GPL Version 2.0 or any later version,
71+
or a license that is compatible with GPL Version 2.0 or a later version,
72+
where “compatible” means that software provided under the Change License can
73+
be included in a program with software provided under GPL Version 2.0 or a
74+
later version. Licensor may specify additional Change Licenses without
75+
limitation.
76+
77+
2. To either: (a) specify an additional grant of rights to use that does not
78+
impose any additional restriction on the right granted in this License, as
79+
the Additional Use Grant; or (b) insert the text “None”.
80+
81+
3. To specify a Change Date not later than the fourth anniversary of the first
82+
publicly available distribution of a specific version of the Licensed Work
83+
under this License.
84+
85+
4. Not to modify this License in any other way.
86+
87+
Notice
88+
89+
The Business Source License (this document, or the “License”) is not an Open
90+
Source license. However, the Licensed Work will eventually be made available
91+
under an Open Source License, as stated in this License.
92+
93+
For more information on the use of the Business Source License for MariaDB
94+
products, please visit the MariaDB Business Source License FAQ.
95+
For more information on the use of the Business Source License generally,
96+
please visit the Adopting and Developing Business Source License FAQ.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# Hawk Workers
44

5+
![License](https://img.shields.io/badge/license-BSL--1.1-orange)
6+
57
Workers are services for processing hawk's background tasks
68

79

@@ -219,3 +221,8 @@ yarn migrate
219221
Refactor mongo-migrate commands to have an opportunity to create or rollback
220222

221223
[More details](https://www.npmjs.com/package/migrate-mongo)
224+
225+
## License
226+
227+
Source code is available under **Business Source License 1.1 (BSL 1.1)**.
228+
See [`LICENSE`](./LICENSE) for terms, including:
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
const indexName = 'projectId_release_unique_idx';
2+
const collectionName = 'releases';
3+
4+
module.exports = {
5+
async up(db) {
6+
const pairs = await db.collection(collectionName).aggregate([
7+
{
8+
$group: {
9+
_id: { projectId: '$projectId', release: '$release' },
10+
count: { $sum: 1 },
11+
},
12+
},
13+
{ $project: { _id: 0, projectId: '$_id.projectId', release: '$_id.release', count: 1 } },
14+
]).toArray();
15+
16+
console.log(`Found ${pairs.length} unique (projectId, release) pairs to process.`);
17+
18+
let processed = 0;
19+
20+
for (const { projectId, release, count } of pairs) {
21+
processed += 1;
22+
console.log(`[${processed}/${pairs.length}] Processing projectId=${projectId}, release=${release} (docs: ${count})`);
23+
24+
try {
25+
const docs = await db.collection(collectionName)
26+
.find({ projectId, release }, { projection: { files: 1, commits: 1 } })
27+
.toArray();
28+
29+
const filesByName = new Map();
30+
const commitsByHash = new Map();
31+
32+
for (const doc of docs) {
33+
if (Array.isArray(doc.files)) {
34+
for (const file of doc.files) {
35+
/**
36+
* Keep first occurrence if duplicates conflict
37+
*/
38+
if (file && typeof file === 'object' && file.mapFileName && !filesByName.has(file.mapFileName)) {
39+
filesByName.set(file.mapFileName, file);
40+
}
41+
}
42+
}
43+
if (Array.isArray(doc.commits)) {
44+
for (const commit of doc.commits) {
45+
if (commit && typeof commit === 'object' && commit.hash && !commitsByHash.has(commit.hash)) {
46+
commitsByHash.set(commit.hash, commit);
47+
}
48+
}
49+
}
50+
}
51+
52+
const mergedFiles = Array.from(filesByName.values());
53+
const mergedCommits = Array.from(commitsByHash.values());
54+
55+
/**
56+
* Replace all docs for this pair with a single consolidated doc
57+
*/
58+
const ops = [
59+
{ deleteMany: { filter: { projectId, release } } },
60+
{ insertOne: { document: { projectId, release, files: mergedFiles, commits: mergedCommits } } },
61+
];
62+
63+
await db.collection(collectionName).bulkWrite(ops, { ordered: true });
64+
console.log(`Consolidated projectId=${projectId}, release=${release}: files=${mergedFiles.length}, commits=${mergedCommits.length}`);
65+
} catch (err) {
66+
console.error(`Error consolidating projectId=${projectId}, release=${release}:`, err);
67+
}
68+
}
69+
70+
/**
71+
* Create the unique compound index
72+
*/
73+
try {
74+
const hasIndex = await db.collection(collectionName).indexExists(indexName);
75+
if (!hasIndex) {
76+
await db.collection(collectionName).createIndex(
77+
{ projectId: 1, release: 1 },
78+
{ name: indexName, unique: true, background: true }
79+
);
80+
console.log(`Index ${indexName} created on ${collectionName} (projectId, release unique).`);
81+
} else {
82+
console.log(`Index ${indexName} already exists on ${collectionName}.`);
83+
}
84+
} catch (err) {
85+
console.error(`Error creating index ${indexName} on ${collectionName}:`, err);
86+
}
87+
88+
},
89+
90+
async down(db) {
91+
console.log(`Dropping index ${indexName} from ${collectionName}...`);
92+
try {
93+
const hasIndex = await db.collection(collectionName).indexExists(indexName);
94+
if (hasIndex) {
95+
await db.collection(collectionName).dropIndex(indexName);
96+
console.log(`Index ${indexName} dropped from ${collectionName}.`);
97+
} else {
98+
console.log(`Index ${indexName} does not exist on ${collectionName}, skipping drop.`);
99+
}
100+
} catch (err) {
101+
console.error(`Error dropping index ${indexName} from ${collectionName}:`, err);
102+
}
103+
console.log('Down migration completed (data changes are not reverted).');
104+
},
105+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.1",
55
"description": "Hawk workers",
66
"repository": "git@github.com:codex-team/hawk.workers.git",
7-
"license": "UNLICENSED",
7+
"license": "BUSL-1.1",
88
"workspaces": [
99
"workers/*"
1010
],

0 commit comments

Comments
 (0)