Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp to jsonschema #38

Merged
merged 7 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _tests/test_createJson.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (C) 2022 Noelia Ruiz Martínez, NV Access Limited
# Copyright (C) 2022-2024 Noelia Ruiz Martínez, NV Access Limited
# This file may be used under the terms of the GNU General Public License, version 2 or later.
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -79,6 +79,7 @@ def _assertJsonFilesEqual(self, actualJsonPath: str, expectedJsonPath: str):
del expectedJson["sha256-comment"] # remove explanatory comment
with open(actualJsonPath) as actualFile:
actualJson = json.load(actualFile)
del actualJson["submissionTime"] # remove submission time

self.assertDictEqual(actualJson, expectedJson)

Expand Down
14 changes: 12 additions & 2 deletions _validate/addonVersion_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"description": "erleichtert das Durchführen von xyz"
}
],
"reviewUrl": "https://github.com/nvaccess/addon-datastore/discussions/1942#discussioncomment-7453248"
"reviewUrl": "https://github.com/nvaccess/addon-datastore/discussions/1942#discussioncomment-7453248",
"submissionTime": 1723523492363.093
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
}

],
"title": "Root",
"type": "object",
Expand Down Expand Up @@ -266,6 +266,16 @@
"title": "Discussion comment URL",
"type": "string"
},
"submissionTime": {
"$id": "#/properties/submissionTime",
"default": 0,
"description": "Timestamp in milliseconds, corresponding to the submission time of the add-on",
"examples": [
1723523492363.093
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
],
"title": "Submission time",
"type": "number"
},
"vtScanUrl": {
"$id": "#/properties/vtScanUrl",
"default": "",
Expand Down
8 changes: 7 additions & 1 deletion _validate/createJson.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python

# Copyright (C) 2022-2023 Noelia Ruiz Martínez, NV Access Limited
# Copyright (C) 2022-2024 Noelia Ruiz Martínez, NV Access Limited
# This file may be used under the terms of the GNU General Public License, version 2 or later.
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html
import time
nvdaes marked this conversation as resolved.
Show resolved Hide resolved
import dataclasses
import json
import argparse
Expand Down Expand Up @@ -31,6 +32,10 @@ def getSha256(addonPath: str) -> str:
return sha256Addon


def getCurrentTime() -> float:
return time.time() * 1000 # Milliseconds
nvdaes marked this conversation as resolved.
Show resolved Hide resolved


def generateJsonFile(
manifest: AddonManifest,
addonPath: str,
Expand Down Expand Up @@ -121,6 +126,7 @@ def _createDictMatchingJsonSchema(
addonData["homepage"] = homepage
if licenseUrl:
addonData["licenseURL"] = licenseUrl
addonData["submissionTime"] = getCurrentTime()

addonData["translations"] = []
for langCode, manifest in getAddonManifestLocalizations(manifest):
Expand Down
Loading