Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit d89af46

Browse files
author
Julien Jomier
committed
BUG: 9689: Migrate MIDAS2 stats into MIDAS3
1 parent a7de154 commit d89af46

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

core/controllers/components/MIDAS2MigrationComponent.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ private function _createFolderForItem($collectionId, $parentFolderid)
144144

145145
$itemdao = new ItemDao;
146146
$itemdao->setName($filename);
147+
148+
// Get the number of downloads and set it
149+
$itemstatsquery = pg_query("SELECT downloads from midas_resourcelog WHERE
150+
resource_id_type=".MIDAS2_RESOURCE_ITEM." AND resource_id=".$item_id);
151+
if($itemstats_array = pg_fetch_array($itemstatsquery))
152+
{
153+
$itemdao->setView($itemstats_array['downloads']);
154+
$itemdao->setDownload($itemstats_array['downloads']);
155+
}
156+
147157
$Item->save($itemdao);
148158

149159
// Just check if the group anonymous can access the item
@@ -189,7 +199,7 @@ private function _createFolderForItem($collectionId, $parentFolderid)
189199

190200
// Create a revision for the item
191201
$itemRevisionDao = new ItemRevisionDao;
192-
$itemRevisionDao->setChanges('Initial revision');
202+
$itemRevisionDao->setChanges('Initial revision');
193203
$itemRevisionDao->setUser_id($this->userId);
194204
$Item->addRevision($itemdao, $itemRevisionDao);
195205

@@ -581,8 +591,6 @@ function migrate($userid)
581591

582592
// Close the database connection
583593
pg_close($pgdb);
584-
585-
echo "Migration done. Enjoy MIDAS3!";
586594
} // end function migrate()
587595

588596
} // end class

core/public/css/item/item.view.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ table#metadataTable{
1515
display: table!important;
1616
}
1717

18+
div.genericInfo {
19+
position: relative;
20+
}
21+
1822
div.genericInfo .genericCompany {
1923
font-size: 10px;
2024
}
25+
26+
#browseTable {
27+
margin-top:0px;
28+
}
29+
30+
.itemStats {
31+
clear:both;
32+
position: relative;
33+
float: right;
34+
font-size: 10px;
35+
color: #777777;
36+
top: -32px;
37+
margin: 0px;
38+
width: 130px;
39+
height: 10px;
40+
text-align: right;
41+
}

core/views/item/view.phtml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view.
2626
<div class="genericInfo">
2727
<div class="genericName"><?php echo $this->slicename($this->itemDao->getName(),50); ?></div>
2828
<div class="genericCompany"><?php echo $this->itemSize;?></div>
29+
<div class="itemStats"><?php echo $this->itemDao->getView()?> <?php echo $this->t('views'); ?>,
30+
<?php echo $this->itemDao->getDownload()?> <?php echo $this->t('downloads');?></div>
2931
</div>
3032

31-
3233
<table id="browseTable" class="midasTree">
3334
<thead>
3435
<tr>
@@ -179,9 +180,9 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view.
179180
<tr>
180181
<td>Revision</td>
181182
<td><?php echo $this->itemDao->lastrevision->getRevision()?></td>
182-
</tr>
183+
</tr>
183184
<tr>
184-
<td><?php echo $this->t('# files');?></td>
185+
<td><?php echo $this->t('Files');?></td>
185186
<td><?php echo count($this->itemDao->lastrevision->getBitstreams())?></td>
186187
</tr>
187188
</tbody>

0 commit comments

Comments
 (0)