-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom review tags (#1527)
Co-authored-by: Vladislav Gerasimov <vladislav.gerasimov@movingimage.com> Co-authored-by: Lisa Gaudette <lisa.gaudette@gmail.com> Co-authored-by: Sherin Thomas <sherin.thomas.m@gmail.com> Co-authored-by: Jonathan de Bruin <jonathandebruinos@gmail.com>
- Loading branch information
1 parent
3a615da
commit 6ef67ab
Showing
27 changed files
with
1,160 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,3 +169,6 @@ sketch | |
notes.md | ||
|
||
flask_config.* | ||
|
||
*.iml | ||
.idea |
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,25 @@ | ||
import sqlite3 | ||
|
||
|
||
def _alter_tag_column(state): | ||
"""Add a tag column to the results table. | ||
Introduced in state version 1.1. | ||
""" | ||
con: sqlite3.Connection = state.connect_to_sql_wr() | ||
con.execute("ALTER TABLE results ADD COLUMN custom_metadata_json TEXT") | ||
|
||
|
||
def check_and_update_version(current_version, new_version, state): | ||
|
||
if current_version == new_version: | ||
return current_version | ||
|
||
if current_version in ["1.0", "1", 1] and new_version == "1.1": | ||
_alter_tag_column(state) | ||
return "1.1" | ||
|
||
raise ValueError( | ||
f"Migration script from version {current_version} " | ||
f"to {new_version} doesn't exist" | ||
) |
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,35 @@ | ||
# Copyright 2019-2023 The ASReview Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import json | ||
|
||
|
||
def convert_to_custom_metadata_str(tags=None): | ||
return json.dumps({"tags": tags}) | ||
|
||
|
||
def extract_tags(custom_metadata_str): | ||
if not isinstance(custom_metadata_str, str): | ||
return None | ||
|
||
obj = json.loads(custom_metadata_str) | ||
|
||
if "tags" in obj: | ||
return obj["tags"] | ||
else: | ||
return None | ||
|
||
|
||
def get_tag_composite_id(group_id, tag_id): | ||
return f"{group_id}:{tag_id}" |
Oops, something went wrong.