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

Fix bug dataset image not showing #969

Merged
merged 28 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5283a49
Update url in dev dataset
kencho51 Feb 18, 2022
1611283
Remove // at the begining of the url
kencho51 Feb 18, 2022
a736818
Create migration script form tbl image url
kencho51 Feb 18, 2022
49e5970
Update migration script
kencho51 Feb 18, 2022
8de90ba
Update script to deal with no image row
kencho51 Feb 18, 2022
8fb4c63
Update test for dataset image path
kencho51 Feb 21, 2022
0771ea8
Revert "Remove // at the begining of the url"
kencho51 Feb 21, 2022
336dc19
Update to https
kencho51 Feb 21, 2022
32e749a
Update script to replace url where url is empty
kencho51 Feb 21, 2022
5b130d0
Revert "Update url in dev dataset"
kencho51 Feb 23, 2022
e2bfc05
Remove extra if block
kencho51 Feb 23, 2022
5801abd
Remove duplicate test method
kencho51 Feb 24, 2022
b398ec1
Remove the wip tag
kencho51 Feb 24, 2022
fda3457
Create test dataset with no image associated
kencho51 Mar 1, 2022
c8e7351
Create test for no image dataset
kencho51 Mar 1, 2022
f62d483
Replace null to empty and pass the test
kencho51 Mar 1, 2022
c49bf79
Leave comment for why changing null back to empty
kencho51 Mar 1, 2022
3c45903
Update comment
kencho51 Mar 1, 2022
88aa2bc
Update cdn url path for projects and datasets
kencho51 Mar 3, 2022
eafed63
Update image url in feature file
kencho51 Mar 3, 2022
38895d7
Apply patch for dealing empty to null when setting up db from csv
kencho51 Mar 3, 2022
c47fa1f
Update url for no image dataset
kencho51 Mar 3, 2022
b9dac8b
Remove update null to empty step in migration script
kencho51 Mar 3, 2022
0463c37
Include fix_import migration scripts for local dev
kencho51 Mar 3, 2022
7cc36fa
To fix value too long for type character varying(128) during gigadb_t…
kencho51 Mar 4, 2022
43c9ec3
To make script work for set up gigadb_testdata
kencho51 Mar 4, 2022
3f098f4
To fix gitlab runner non existence dir problem
kencho51 Mar 6, 2022
e8453ab
Replace like operator
kencho51 Mar 6, 2022
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
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ variables:
# so it doesn't try to access
GIGADB_ENV: CI
# .env is only for dev, elsewhere we just list the variables here
APPLICATION: "/builds/$CI_PROJECT_PATH"
APPLICATION: "$CI_PROJECT_DIR"
YII_PATH: "/var/www/vendor/yiisoft/yii"
YII2_PATH: "/var/www/vendor/yiisoft/yii2"
DATA_SAVE_PATH: "/builds/$CI_PROJECT_PATH/containers-data"
Expand Down
3 changes: 2 additions & 1 deletion data/dev/dataset.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ The assembled scaffolds of high quality sequences total 1.23 Gb, with the contig
144,163,147,100094,Data and software to accompany the paper: Applying compressed sensing to genome-wide association studies.,"The aim of a genome-wide association study (GWAS) is to isolate DNA markers for variants affecting phenotypes of interest. Linear regression is employed for this purpose, and in recent years a signal-processing paradigm known as compressed sensing (CS) has coalesced around a particular class of regression techniques. CS is not a method in its own right, but rather a body of theory regarding signal recovery when the number of predictor variables (i.e., genotyped markers) exceeds the sample size. The paper shows the applicability of compressed sensing (CS) theory to genome-wide association studies (GWAS), where the purpose is to find trait-associated tagging markers (genetic variants). Analysis scripts are contained in the compressed CS file. Mock data and scripts are found in the compressed GD file. The example scripts found in the CS repository require the GD files to be unpacked in a separate folder. Please look at accompanying readme pdfs for both repositories and annotations in the example scripts before using.",171860992,ftp://parrot.genomics.cn/gigadb/pub/10.5524/100001_101000/100094,Published,,,2014-06-06,,1,AWLGPriZKd41XEaS,,,,
200,336,212,100142,"Supporting scripts and data for ""Investigation into the annotation of protocol sequencing steps in the Sequence Read Archive"".","The workflow for the production of high-throughput sequencing data from nucleic acid samples is complex. There are a series of protocol steps to be followed in the preparation of samples for next-generation sequencing. The quantification of bias in a number of protocol steps, namely DNA fractionation, blunting, phosphorylation, adapter ligation and library enrichment, remains to be determined.
We examined the experimental metadata of the public repository Sequence Read Archive (SRA) in order to ascertain the level of annotation of important sequencing steps in submissions to the database. ",384263168,ftp://parrot.genomics.cn/gigadb/pub/10.5524/100001_101000/100142/,Published,100142newversion.xls,a98f1c13a46501707fb3fba270deb6e3,2015-05-11,,3,eG8EFsRibZQzrtNw,,,,
668,38,669,200070,supporting data for nothing in particular,"well now, how to describe nothing in particular?",32,https://ftp.cngb.org/pub/gigadb/pub,Private,,,,,1,ImP3Bbu7ytRSfYFh,,38,none,
668,38,669,200070,supporting data for nothing in particular,"well now, how to describe nothing in particular?",32,https://ftp.cngb.org/pub/gigadb/pub,Private,,,,,1,ImP3Bbu7ytRSfYFh,,38,none,
700,14,700,300070,test dataset,"test generic image will be display for no image dataset",32,https://ftp.cngb.org/pub/gigadb/pub,Published,,,,,1,,,38,none,
1 change: 1 addition & 0 deletions data/dev/image.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ id,location,tag,url,license,photographer,source
147,"",CS icon1,"",public domain,Shashaank Vattikuti ,Gigascience
212,100142.jpg,Overlap between different protocol search terms,http://gigadb.org/images/data/cropped/100142.jpg,CC0,Alnasir and Shanahan 2015,Alnasir and Shanahan 2015
669,"",no image icon,var/www/hosts/localhost/htdocs/images/uploads/image_upload/Images_1885.png,Public domain,GigaDB,GigaDB
700,no_image.png,no image icon,"",Public domain,GigaDB,GigaDB
2 changes: 1 addition & 1 deletion ops/configuration/yii-conf/migration.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class {{ class_name }} extends CDbMigration
{{#each safeup_data}}
$this->insert('{{ ../table_name }}', array(
{{#each this}}
{{#if this}}
{{#if (isdefined @key this) }}
'{{@key}}' => '{{this}}',
{{/if}}
{{/each}}
Expand Down
7 changes: 7 additions & 0 deletions ops/scripts/csv_yii_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ for(let a = 0; a < files.length; a ++) {
safeup_data: parsed.data,
safedown_data: filtered_ids
};
// Register sub expression to decide whether a value is defined based on its key
handlebars.registerHelper('isdefined', function (key, value) {
if (key == 'url') {
return value !== undefined;
}
return !handlebars.Utils.isEmpty(value);
});
// Read handlebars template as string
let template = fs.readFileSync(HANDLEBARS_TEMPLATE_FILE, "utf8");
const templateScript = handlebars.compile(template);
Expand Down
3 changes: 3 additions & 0 deletions ops/scripts/setup_devdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ docker-compose run --rm test psql -h database -U gigadb < protected/runtime/drop
# Perform data migrations
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=db --migrationPath=application.migrations.data.$dbSet --interactive=0

# update the url for project images and dataset images
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=db --migrationPath=application.migrations.fix_import --interactive=0

# Restore constraints, indexes and triggers
docker-compose run --rm test psql -h database -U gigadb < protected/runtime/addConstraintsQuery.sql
docker-compose run --rm test psql -h database -U gigadb < protected/runtime/addIndexQuery.sql
Expand Down
4 changes: 4 additions & 0 deletions ops/scripts/setup_testdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ $DOCKER_COMPOSE run --rm application ./protected/yiic migrate to 300000_000000
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate mark 000000_000000 --connectionID=testdb --interactive=0
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.schema --interactive=0
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.data.$dbSet --interactive=0

# update the url for project images and dataset images
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.fix_import --interactive=0

# export a binary dump
$DOCKER_COMPOSE run --rm test bash -c "pg_dump --no-owner -U gigadb -h database -p 5432 -F custom -d $dbSet -f /var/www/sql/$dbSet.pgdmp"
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public function safeUp()
Yii::app()->db->createCommand("update project set image_location = replace(image_location,'http://hpc-bioinformatics.cineca.it/fusion/imgs','');")->execute();
Yii::app()->db->createCommand("update project set image_location = replace(image_location,'https://bioinfotraining.bio.cam.ac.uk/images','');")->execute();
Yii::app()->db->createCommand("update project set image_location = replace(image_location,'http://gigadb.org/images/data/cropped','');")->execute();
Yii::app()->db->createCommand("ALTER TABLE project ALTER COLUMN image_location TYPE character varying(128);")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', lower(replace(replace(replace(name, ' ','_'),'_-_','_'),',','')), image_location) where image_location != '' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%' and name not like 'LiGeA%' and name != 'https://www.carmen.org.uk';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', replace(name, 'LiGeA: a comprehensive database of human gene fusion events', 'ligea'), image_location) where name like 'LiGeA%' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', replace(name, 'https://www.carmen.org.uk', 'carmen'), image_location) where name = 'https://www.carmen.org.uk' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
Yii::app()->db->createCommand("ALTER TABLE project ALTER COLUMN image_location TYPE character varying(255);")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', lower(replace(replace(replace(name, ' ','_'),'_-_','_'),',','')), image_location) where image_location != '' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%' and name not like 'LiGeA%' and name != 'https://www.carmen.org.uk';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', replace(name, 'LiGeA: a comprehensive database of human gene fusion events', 'ligea'), image_location) where name like 'LiGeA%' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', replace(name, 'https://www.carmen.org.uk', 'carmen'), image_location) where name = 'https://www.carmen.org.uk' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
}

public function safeDown()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

class m220218_062834_update_url_image_tab extends CDbMigration
{
public function safeUp()
{
Yii::app()->db->createCommand("update image set url = replace(url, 'http://gigadb.org/','https://assets.gigadb-cdn.net/live/images/datasets/') where url like 'http://gigadb.org/%';")->execute();
Yii::app()->db->createCommand("update image set url = 'https://assets.gigadb-cdn.net/live/images/datasets/no_image.png' where url='' and location like 'no_image%';")->execute();
}

public function safeDown()
{
}
}
7 changes: 0 additions & 7 deletions protected/models/Dataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,6 @@ public function getDatasetTypes(){
public function getImageUrl($default='') {
if ($this->image) {
$url = $this->image->url;
if ($url) {
if (!strstr($url , 'http://')) {
$url = '//' . $url;
}
} else {
$url = $this->image->image('image_upload');
}
return $url;
}
return $default;
Expand Down
17 changes: 14 additions & 3 deletions tests/acceptance/DatasetView.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,21 @@ Feature: a user visit the dataset page
Then I should see "well now, how to describe nothing in particular?"
And I should not see "The DOI 200070 cannot be displayed."

@ok
Scenario: Dataset with image associated will show dataset image
Given I have not signed in
When I am on "dataset/100006"
Then I should see an image located in "https://assets.gigadb-cdn.net/live/images/datasets/images/data/cropped/100006_Pygoscelis_adeliae.jpg"

@ok
Scenario: Dataset with no image associated will show generic image
Given I have not signed in
When I am on "dataset/300070"
Then I should see an image located in "https://assets.gigadb-cdn.net/live/images/datasets/no_image.png"

@ok @issue-895
Scenario: Project image with links
Given I have not signed in
When I am on "/dataset/100006"
Then I should see an image "https://assets.gigadb-cdn.net/images/projects/genome_10k/G10Klogo.jpg" is linked to "http://www.genome10k.org/"
And I should see an image "https://assets.gigadb-cdn.net/images/projects/the_avian_phylogenomic_project/phylogenomiclogo.png" is linked to "http://avian.genomics.cn/en/index.html"

Then I should see an image "https://assets.gigadb-cdn.net/live/images/projects/genome_10k/G10Klogo.jpg" is linked to "http://www.genome10k.org/"
And I should see an image "https://assets.gigadb-cdn.net/live/images/projects/the_avian_phylogenomic_project/phylogenomiclogo.png" is linked to "http://avian.genomics.cn/en/index.html"