Skip to content

Commit

Permalink
Update database schema, queries
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsier committed Jan 23, 2024
1 parent a6e361b commit 5f29daf
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 82 deletions.
4 changes: 1 addition & 3 deletions client/src/components/Search/MapViewerV4.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ function useImageKey({ searchCoordinates, searchYears }) {
const bbox = turf.bbox(buffered)

// calculate start and end for searching
const allSearchYears = searchYears
.map((year) => Number(year.praxisyear))
.sort()
const allSearchYears = searchYears.map((year) => Number(year.year)).sort()

// create ISO strings
const start_captured_at = new Date(allSearchYears[0], 0, 1).toISOString()
Expand Down
10 changes: 4 additions & 6 deletions client/src/components/Search/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import PrimaryResultsContainer from "./PrimarySearchResults"
import searchIcon from "../../assets/img/search.png"
import { ppRose } from "../../utils/colors"
import { DEFAULT_YEAR } from "../../utils/constants"

class SearchBar extends Component {
_inputRef = React.createRef()
Expand Down Expand Up @@ -247,7 +248,7 @@ class SearchBar extends Component {
searchTerm: "",
searchType: "all",
searchCoordinates: null,
searchYear: "2020", //this is hardcoded and can be more dynamic
searchYear: DEFAULT_YEAR, //this is hardcoded and can be more dynamic
})
}
}
Expand Down Expand Up @@ -300,11 +301,8 @@ class SearchBar extends Component {
>
{searchYears.map((result) => {
return (
<option
key={result.praxisyear}
value={result.praxisyear.toString()}
>
{result.praxisyear}
<option key={result.year} value={result.year.toString()}>
{result.year}
</option>
)
})}
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Search/TimeGraph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function TimeGraph({ ownid }) {
const graph_data = data
.map((record) => {
// cast data
const { praxisyear, count } = record
const { year, count } = record
return {
year: new Date(praxisyear, 1, 1),
year: new Date(year, 1, 1),
count: Number(count),
}
})
Expand Down
3 changes: 2 additions & 1 deletion client/src/reducers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import {
UPDATE_DETAILED_SEARCH,
UPDATE_SEARCH_BAR,
} from "../actions/search"
import { DEFAULT_YEAR } from "../utils/constants"

const initialSearchState = {
searchBar: {
searchYears: null,
},
searchParams: {
searchType: "all",
searchYear: "2020",
searchYear: DEFAULT_YEAR,
searchTerm: "",
searchCoordinates: null,
},
Expand Down
1 change: 1 addition & 0 deletions client/src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DEFAULT_YEAR = "2021"
2 changes: 1 addition & 1 deletion server/routes/detailedSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ router.get("/", async (req, res) => {
const years = await queries.queryPGDB({
PGDBQueryType: queries.AVAILABLE_PRAXIS_YEARS,
})
const searchYears = years.data.map((record) => record.praxisyear)
const searchYears = years.data.map((record) => record.year)
// .filter((pyear) => Number(pyear) !== Number(year)); //filter the current year

const { data } = await queries.queryPGDB({
Expand Down
2 changes: 1 addition & 1 deletion server/routes/geojsonSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ router.get("/", async (req, res) => {
code = null,
place = null,
coordinates = null,
year = "2020",
year = "2021",
} = req.query

let pgData, geoJSON, clientData, praxisDataType
Expand Down
Loading

0 comments on commit 5f29daf

Please sign in to comment.