Skip to content

Commit

Permalink
fixed frames values
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliaProkopovych committed Apr 9, 2024
1 parent 61b8e67 commit c4e9d99
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
40 changes: 34 additions & 6 deletions module/move/unitore/src/entity/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,21 @@ impl From< ( feed_rs::model::Entry, String ) > for Frame
stored_time : entry.updated,
authors: ( !authors.is_empty() ).then( || authors ),
// qqq : why join?
// aaa : fixed, saved as list
content,
links: ( !links.is_empty() ).then( || links ),
// qqq : why join?
// aaa : fixed, saved as list
summary : entry.summary.map( | c | c.content ).clone(),
categories: ( !categories.is_empty() ).then( || categories ),
// qqq : why join?
// aaa : fixed, saved as list
published : entry.published.clone(),
source : entry.source.clone(),
rights : entry.rights.map( | r | r.content ).clone(),
media: ( !media.is_empty() ).then( || media ),
// qqq : why join?
// aaa : fixed, saved as list
language : entry.language.clone(),
feed_link,
}
Expand Down Expand Up @@ -132,27 +136,46 @@ impl From< Frame > for Vec< ExprNode< 'static > >
;

let authors = entry.authors
.map( | authors | text(authors[0].clone()))
.map( | authors |
text
(
format!( "[{}]", authors.into_iter().map( | a | format!( "\"{}\"", a ) ).collect::< Vec< _ > >().join( ", " ) )
)
)
.unwrap_or( null() )
;

let content = entry.content
.map( | content | text ( content ) )
.map( | content | text( content ) )
.unwrap_or( null() )
;

let links = entry.links
.map( | links | text ( links.join(", ") ) )
.map( | links |
text
(
format!( "[{}]", links.into_iter().map( | link | format!( "\"{}\"", link ) ).collect::< Vec< _ > >().join( ", " ) )
)
)
.unwrap_or( null() )
;

let summary = entry.summary
.map( | summary | text ( summary ) )
.map( | summary | text( summary ) )
.unwrap_or( null() )
;

let categories = entry.categories
.map( | categories | text ( categories.join(", ") ) )
.map( | categories |
text
(
format!
(
"[{}]",
categories.into_iter().map( | category | format!( "\"{}\"", category ) ).collect::< Vec< _ > >().join( ", " ),
)
)
)
.unwrap_or( null() )
;

Expand All @@ -164,7 +187,12 @@ impl From< Frame > for Vec< ExprNode< 'static > >
let source = entry.source.map( | s | text( s ) ).unwrap_or( null() );
let rights = entry.rights.map( | r | text( r ) ).unwrap_or( null() );
let media = entry.media
.map( | media | text( media.join(", ") ) )
.map( | media |
text
(
format!( "[{}]", media.into_iter().map( | media | format!( "\"{}\"", media ) ).collect::< Vec< _ > >().join( ", " ) )
)
)
.unwrap_or( null() )
;

Expand Down
8 changes: 4 additions & 4 deletions module/move/unitore/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ impl FeedStorage< SledStorage >
[ "id", "TEXT", "A unique identifier for this frame in the feed. " ],
[ "title", "TEXT", "Title of the frame" ],
[ "stored_time", "TIMESTAMP", "Time at which this item was fetched from source." ],
[ "authors", "TEXT", "List of authors of the frame, optional." ],
[ "authors", "LIST", "List of authors of the frame, optional." ],
[ "content", "TEXT", "The content of the frame in html or plain text, optional." ],
[ "links", "TEXT", "List of links associated with this item of related Web page and attachments." ],
[ "links", "LIST", "List of links associated with this item of related Web page and attachments." ],
[ "summary", "TEXT", "Short summary, abstract, or excerpt of the frame item, optional." ],
[ "categories", "TEXT", "Specifies a list of categories that the item belongs to." ],
[ "categories", "LIST", "Specifies a list of categories that the item belongs to." ],
[ "published", "TIMESTAMP", "Time at which this item was first published or updated." ],
[ "source", "TEXT", "Specifies the source feed if the frame was copied from one feed into another feed, optional." ],
[ "rights", "TEXT", "Conveys information about copyrights over the feed, optional." ],
[ "media", "TEXT", "List of media oblects, encountered in the frame, optional." ],
[ "media", "LIST", "List of media oblects, encountered in the frame, optional." ],
[ "language", "TEXT", "The language specified on the item, optional." ],
[ "feed_link", "TEXT", "Link of feed that contains this frame." ],
];
Expand Down

0 comments on commit c4e9d99

Please sign in to comment.