Skip to content

Commit

Permalink
Feature NMH-65: Collect and use statistics on downloads of model
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoodbayeshi committed Feb 24, 2022
1 parent 374ed40 commit 5637cf9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
35 changes: 22 additions & 13 deletions docs/_frontend/src/models/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Combobox from '../Combobox';
import Radio from '../Radio/Radio';
import RadioGroup from '../RadioGroup';
import styles from './Sidebar.module.css';
import Combobox from "../Combobox";
import Radio from "../Radio/Radio";
import RadioGroup from "../RadioGroup";
import styles from "./Sidebar.module.css";

const Sidebar = ({ meta, params, onSubmit }) => {
let tags = [];
Expand All @@ -17,20 +17,20 @@ const Sidebar = ({ meta, params, onSubmit }) => {
<div className={styles.root}>
<div className={styles.control}>
<RadioGroup
value={params.type || ''}
value={params.type || ""}
onChange={(value) => {
onSubmit({ type: value });
}}
>
<Radio value="">All</Radio>
<Radio value="model">Models</Radio>
<Radio value="pipeline">Pipelines</Radio>
<Radio value=''>All</Radio>
<Radio value='model'>Models</Radio>
<Radio value='pipeline'>Pipelines</Radio>
</RadioGroup>
</div>

<div className={styles.control}>
<Combobox
label="Assigned tags"
label='Assigned tags'
items={tags}
initialSelectedItems={params.tags || []}
onChange={(values) => {
Expand All @@ -41,7 +41,7 @@ const Sidebar = ({ meta, params, onSubmit }) => {

<div className={styles.control}>
<Combobox
label="Entities"
label='Entities'
items={predictedEntities}
initialSelectedItems={params.predicted_entities || []}
onChange={(values) => {
Expand All @@ -52,14 +52,23 @@ const Sidebar = ({ meta, params, onSubmit }) => {

<div className={styles.control}>
<RadioGroup
value={params.sort || 'date'}
value={params.sort || "date"}
onChange={(value) => {
onSubmit({ sort: value });
}}
>
<label>Sort By:</label>
<Radio value="date">Date</Radio>
<Radio value="views">Views</Radio>
<div className={styles.radioContainers}>
<Radio value='date' className={styles.radio}>
Date
</Radio>
<Radio value='views' className={styles.radio}>
Views
</Radio>
<Radio value='downloads' className={styles.radio}>
Downloads
</Radio>
</div>
</RadioGroup>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions docs/_frontend/src/models/Sidebar/Sidebar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@
.control:not(:last-child) {
margin-bottom: 20px;
}

.radioContainers {
flex-direction: column;
}

.radioContainers .radio {
display: block;
}
11 changes: 11 additions & 0 deletions docs/_plugins/search_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ def is_latest?(group, model)
},
"url": {
"type": "keyword"
},
"download_link": {
"type": "keyword"
},
"views": {
"type": "integer"
},
"downloads": {
"type": "integer"
}
}
}
Expand Down Expand Up @@ -341,6 +350,8 @@ def is_latest?(group, model)
model[:type] = models_json[model[:url]][:type]
# Add predicted entities to search models
model[:predicted_entities] = models_json[model[:url]][:predicted_entities]
# Add download_link to search models
model[:download_link] = models_json[model[:url]][:download_link]

if client
if force_reindex || uniq_for_indexing.include?(uniq)
Expand Down

0 comments on commit 5637cf9

Please sign in to comment.