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 all 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
}

],
"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
],
"title": "Submission time",
"type": "number"
},
"vtScanUrl": {
"$id": "#/properties/vtScanUrl",
"default": "",
Expand Down
9 changes: 8 additions & 1 deletion _validate/createJson.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/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

from time import gmtime, mktime
import dataclasses
import json
import argparse
Expand Down Expand Up @@ -31,6 +33,10 @@ def getSha256(addonPath: str) -> str:
return sha256Addon


def getCurrentTime() -> int:
return int(mktime(gmtime()) * 1000) # Milliseconds


def generateJsonFile(
manifest: AddonManifest,
addonPath: str,
Expand Down Expand Up @@ -121,6 +127,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