mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 06:24:19 +00:00
Merge branch 'main' into refactor
# Conflicts: # nest_frontend/components/interactive/BoxFilterHashtag.js # nest_frontend/components/interactive/BoxFilters.js
This commit is contained in:
commit
96069ee8b5
4 changed files with 47 additions and 21 deletions
|
@ -53,7 +53,7 @@ def search_repo_conditions(repository_id):
|
||||||
if ConditionType.coordinates in conditions_type.keys():
|
if ConditionType.coordinates in conditions_type.keys():
|
||||||
if evaluation_mode == ConditionMode.all_and:
|
if evaluation_mode == ConditionMode.all_and:
|
||||||
if len(conditions_type[ConditionType.coordinates]) == 1:
|
if len(conditions_type[ConditionType.coordinates]) == 1:
|
||||||
coordinates_tweet = conditions_type[ConditionType.coordinates][0].split()
|
coordinates_tweet = conditions_type[ConditionType.coordinates][0].content.split()
|
||||||
coordinates_string = coordinates_tweet[2] + "," + coordinates_tweet[3] + "," + str(float(coordinates_tweet[1])/1000) + "km"
|
coordinates_string = coordinates_tweet[2] + "," + coordinates_tweet[3] + "," + str(float(coordinates_tweet[1])/1000) + "km"
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@ -64,11 +64,19 @@ def search_repo_conditions(repository_id):
|
||||||
print(coordinates_string)
|
print(coordinates_string)
|
||||||
for tweet in tw.Cursor(method=api.search, q="", geocode=coordinates_string).items(10):
|
for tweet in tw.Cursor(method=api.search, q="", geocode=coordinates_string).items(10):
|
||||||
if not Tweet.query.filter_by(snowflake=str(tweet.id)).all():
|
if not Tweet.query.filter_by(snowflake=str(tweet.id)).all():
|
||||||
|
image_url_list = ''
|
||||||
|
if 'media' in tweet.entities.keys():
|
||||||
|
for url in tweet.entities['media']:
|
||||||
|
image_url_list += (url['media_url_https'] + '|')
|
||||||
|
image_url_list = image_url_list[:-1]
|
||||||
|
else:
|
||||||
|
image_url_list = None
|
||||||
|
|
||||||
tweetDB = Tweet(snowflake=tweet.id, content=tweet.text,
|
tweetDB = Tweet(snowflake=tweet.id, content=tweet.text,
|
||||||
location=tweet.geo['coordinates'] if tweet.geo is not None else None,
|
location=tweet.geo['coordinates'] if tweet.geo is not None else None,
|
||||||
place=tweet.place.full_name if tweet.place is not None else None,
|
place=tweet.place.full_name if tweet.place is not None else None,
|
||||||
insert_time=str(datetime.now()),
|
insert_time=str(datetime.now()),
|
||||||
poster=tweet.author.screen_name)
|
poster=tweet.author.screen_name, post_time=str(tweet.created_at), image_url=image_url_list)
|
||||||
ext.session.add(tweetDB)
|
ext.session.add(tweetDB)
|
||||||
ext.session.commit()
|
ext.session.commit()
|
||||||
if not Contains.query.filter_by(snowflake=str(tweet.id), cid=condition_content.id).all():
|
if not Contains.query.filter_by(snowflake=str(tweet.id), cid=condition_content.id).all():
|
||||||
|
@ -94,50 +102,61 @@ def search_repo_conditions(repository_id):
|
||||||
if queryString != "":
|
if queryString != "":
|
||||||
for tweet in tw.Cursor(method=api.search, q=queryString).items(10):
|
for tweet in tw.Cursor(method=api.search, q=queryString).items(10):
|
||||||
tweetsFound.append(tweet)
|
tweetsFound.append(tweet)
|
||||||
print(tweet.user.name + ' : ' + tweet.text + ' : ' + tweet.geo)
|
print(tweet.user.name + ' : ' + tweet.text + ' : ' + tweet.geo if tweet.geo is not None else '')
|
||||||
elif evaluation_mode == ConditionMode.all_and:
|
elif evaluation_mode == ConditionMode.all_and:
|
||||||
for tweet in tw.Cursor(method=api.search, q=queryString, geocode=coordinates_string).items(10):
|
for tweet in tw.Cursor(method=api.search, q=queryString, geocode=coordinates_string).items(10):
|
||||||
tweetsFound.append(tweet)
|
tweetsFound.append(tweet)
|
||||||
print(tweet.user.name + ' : ' + tweet.text + ' : ' + str(tweet.geo))
|
print(tweet.user.name + ' : ' + tweet.text + ' : ' + str(tweet.geo))
|
||||||
for tweet in tweetsFound:
|
for tweet in tweetsFound:
|
||||||
if not Tweet.query.filter_by(snowflake=str(tweet.id)).all():
|
if not Tweet.query.filter_by(snowflake=str(tweet.id)).all():
|
||||||
|
image_url_list = ''
|
||||||
|
if 'media' in tweet.entities.keys():
|
||||||
|
for url in tweet.entities['media']:
|
||||||
|
image_url_list += (url['media_url_https'] + '|')
|
||||||
|
image_url_list = image_url_list[:-1]
|
||||||
|
else:
|
||||||
|
image_url_list = None
|
||||||
tweetDB = Tweet(snowflake=tweet.id, content=tweet.text,
|
tweetDB = Tweet(snowflake=tweet.id, content=tweet.text,
|
||||||
location=tweet.geo['coordinates'] if tweet.geo is not None else None,
|
location=tweet.geo['coordinates'] if tweet.geo is not None else None,
|
||||||
place=tweet.place.full_name if tweet.place is not None else None,
|
place=tweet.place.full_name if tweet.place is not None else None,
|
||||||
insert_time=str(datetime.now()),
|
insert_time=str(datetime.now()),
|
||||||
poster=tweet.author.screen_name)
|
poster=tweet.author.screen_name, post_time=str(tweet.created_at), image_url=image_url_list)
|
||||||
ext.session.add(tweetDB)
|
ext.session.add(tweetDB)
|
||||||
ext.session.commit()
|
ext.session.commit()
|
||||||
if evaluation_mode == ConditionMode.all_or:
|
if evaluation_mode == ConditionMode.all_or:
|
||||||
if ConditionType.hashtag in conditions_type.keys():
|
if ConditionType.hashtag in conditions_type.keys():
|
||||||
for condition_content in conditions_type[ConditionType.hashtag]:
|
for condition_content in conditions_type[ConditionType.hashtag]:
|
||||||
if condition_content.content in [hashtag['text'] for hashtag in tweet.entities['hashtags']]:
|
if condition_content.content in [hashtag['text'] for hashtag in tweet.entities['hashtags']]:
|
||||||
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
if not Contains.query.filter_by(snowflake=str(tweet.id), cid=condition_content.id).all():
|
||||||
ext.session.add(condition_associated)
|
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
||||||
ext.session.commit()
|
ext.session.add(condition_associated)
|
||||||
|
ext.session.commit()
|
||||||
if ConditionType.user in conditions_type.keys():
|
if ConditionType.user in conditions_type.keys():
|
||||||
for condition_content in conditions_type[ConditionType.user]:
|
for condition_content in conditions_type[ConditionType.user]:
|
||||||
if condition_content.content == tweet.author.screen_name:
|
if condition_content.content == tweet.author.screen_name:
|
||||||
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
if not Contains.query.filter_by(snowflake=str(tweet.id), cid=condition_content.id).all():
|
||||||
ext.session.add(condition_associated)
|
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
||||||
ext.session.commit()
|
ext.session.add(condition_associated)
|
||||||
|
ext.session.commit()
|
||||||
|
|
||||||
if ConditionType.time in conditions_type.keys():
|
if ConditionType.time in conditions_type.keys():
|
||||||
for condition_content in conditions_type[ConditionType.time]:
|
for condition_content in conditions_type[ConditionType.time]:
|
||||||
condition_date_time = datetime.fromisoformat(condition_content.content[2:])
|
condition_date_time = datetime.fromisoformat(condition_content.content[2:])
|
||||||
if condition_content.content[0] == '<':
|
if condition_content.content[0] == '<':
|
||||||
if tweet.created_at < condition_date_time:
|
if tweet.created_at < condition_date_time:
|
||||||
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
if not Contains.query.filter_by(snowflake=str(tweet.id), cid=condition_content.id).all():
|
||||||
ext.session.add(condition_associated)
|
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
||||||
ext.session.commit()
|
ext.session.add(condition_associated)
|
||||||
|
ext.session.commit()
|
||||||
elif condition_content.content[0] == '>':
|
elif condition_content.content[0] == '>':
|
||||||
if tweet.created_at > condition_date_time:
|
if tweet.created_at > condition_date_time:
|
||||||
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
if not Contains.query.filter_by(snowflake=str(tweet.id), cid=condition_content.id).all():
|
||||||
ext.session.add(condition_associated)
|
condition_associated = Contains(cid=condition_content.id, snowflake=tweet.id)
|
||||||
ext.session.commit()
|
ext.session.add(condition_associated)
|
||||||
|
ext.session.commit()
|
||||||
elif evaluation_mode == ConditionMode.all_and:
|
elif evaluation_mode == ConditionMode.all_and:
|
||||||
for condition in conditions:
|
for condition in conditions:
|
||||||
if Contains.query.filter_by(snowflake=str(tweet.id), cid=condition.id).all():
|
if not Contains.query.filter_by(snowflake=str(tweet.id), cid=condition.id).all():
|
||||||
condition_associated = Contains(cid=condition.id, snowflake=tweet.id)
|
condition_associated = Contains(cid=condition.id, snowflake=tweet.id)
|
||||||
ext.session.add(condition_associated)
|
ext.session.add(condition_associated)
|
||||||
ext.session.commit()
|
ext.session.commit()
|
||||||
|
|
|
@ -29,6 +29,8 @@ export default {
|
||||||
byHashtag: "hashtag",
|
byHashtag: "hashtag",
|
||||||
byUser: "utente",
|
byUser: "utente",
|
||||||
byTimePeriod: "arco di tempo",
|
byTimePeriod: "arco di tempo",
|
||||||
|
byContents: "contenuti",
|
||||||
|
byHasPlace: "localizzazione attiva?",
|
||||||
timeBefore: "Prima",
|
timeBefore: "Prima",
|
||||||
timeAfter: "Dopo",
|
timeAfter: "Dopo",
|
||||||
conditions: "Condizioni",
|
conditions: "Condizioni",
|
||||||
|
@ -99,6 +101,7 @@ export default {
|
||||||
imgTweetsPerc: "% di tweet con immagine",
|
imgTweetsPerc: "% di tweet con immagine",
|
||||||
postUniq: "Totale utenti che hanno postato",
|
postUniq: "Totale utenti che hanno postato",
|
||||||
postPop: "Utente più attivo",
|
postPop: "Utente più attivo",
|
||||||
|
filters: "Filtri",
|
||||||
},
|
},
|
||||||
// 🇬🇧
|
// 🇬🇧
|
||||||
en: {
|
en: {
|
||||||
|
@ -119,6 +122,8 @@ export default {
|
||||||
byHashtag: "hashtag",
|
byHashtag: "hashtag",
|
||||||
byUser: "user",
|
byUser: "user",
|
||||||
byTimePeriod: "time period",
|
byTimePeriod: "time period",
|
||||||
|
byContents: "contents",
|
||||||
|
byHasPlace: "is localized?",
|
||||||
timeBefore: "Before",
|
timeBefore: "Before",
|
||||||
timeAfter: "After",
|
timeAfter: "After",
|
||||||
conditions: "Conditions",
|
conditions: "Conditions",
|
||||||
|
@ -189,6 +194,7 @@ export default {
|
||||||
imgTweetsPerc: "% of tweets with image",
|
imgTweetsPerc: "% of tweets with image",
|
||||||
postUniq: "Unique posters",
|
postUniq: "Unique posters",
|
||||||
postPop: "Most active poster",
|
postPop: "Most active poster",
|
||||||
|
filters: "Filters",
|
||||||
},
|
},
|
||||||
// 🇫🇮
|
// 🇫🇮
|
||||||
fi: {
|
fi: {
|
||||||
|
@ -209,6 +215,8 @@ export default {
|
||||||
byHashtag: "hashtagin mukaan",
|
byHashtag: "hashtagin mukaan",
|
||||||
byUser: "käyttäjän mukaan",
|
byUser: "käyttäjän mukaan",
|
||||||
byTimePeriod: "aikajakson mukaan",
|
byTimePeriod: "aikajakson mukaan",
|
||||||
|
byContents: "sisältö",
|
||||||
|
byHasPlace: "on paikallistettu?",
|
||||||
timeBefore: "Ennen",
|
timeBefore: "Ennen",
|
||||||
timeAfter: "Jälkeen",
|
timeAfter: "Jälkeen",
|
||||||
conditions: "Ehdot",
|
conditions: "Ehdot",
|
||||||
|
@ -279,5 +287,6 @@ export default {
|
||||||
imgTweetsPerc: "% twiiteistä, joissa on kuva",
|
imgTweetsPerc: "% twiiteistä, joissa on kuva",
|
||||||
postUniq: "Ainutkertaiset käyttäjät",
|
postUniq: "Ainutkertaiset käyttäjät",
|
||||||
postPop: "Aktiivisimmat käyttäjät",
|
postPop: "Aktiivisimmat käyttäjät",
|
||||||
|
filters: "Suodattimet",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import BoxFull from "../base/BoxFull"
|
import BoxFull from "../base/BoxFull"
|
||||||
import { faClock, faHashtag } from "@fortawesome/free-solid-svg-icons"
|
import { faHashtag } from "@fortawesome/free-solid-svg-icons"
|
||||||
import useRepositoryViewer from "../../hooks/useRepositoryViewer"
|
import useRepositoryViewer from "../../hooks/useRepositoryViewer"
|
||||||
import useStrings from "../../hooks/useStrings"
|
import useStrings from "../../hooks/useStrings"
|
||||||
import { FilterHashtag } from "../../objects/Filter"
|
import { FilterHashtag } from "../../objects/Filter"
|
||||||
|
|
|
@ -18,10 +18,8 @@ export default function BoxFilters({ ...props }) {
|
||||||
|
|
||||||
const badges = filters.map((filter, pos) => <BadgeFilter key={pos} filter={filter}/>)
|
const badges = filters.map((filter, pos) => <BadgeFilter key={pos} filter={filter}/>)
|
||||||
|
|
||||||
// TODO: localize this
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={"Filters"} {...props}>
|
<BoxFull header={strings.filters} {...props}>
|
||||||
{badges}
|
{badges}
|
||||||
</BoxFull>
|
</BoxFull>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue