Skip to content

Commit

Permalink
feat: ✨ supports simple query
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Mar 13, 2022
1 parent d3b3e5f commit a65131f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/QueryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const QueryModal: React.FC<Partial<{
<Row gutter={16}>
<Col span={12}>
<Form.Item label="script" name={[field.name, 'script']} labelCol={{ span: 4 }}>
<Input.TextArea rows={8} />
<Input.TextArea rows={10} />
</Form.Item>
</Col>
<Col span={12}>
Expand Down
12 changes: 8 additions & 4 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import dayjs from 'dayjs'
import { flattenDeep, get } from 'lodash'
import en from 'dayjs/locale/en'
import { ISchedule } from 'tui-calendar'
import { DAILY_LOG_CONFIG, DEFAULT_BLOCK_DEADLINE_DATE_FORMAT, DEFAULT_JOURNAL_FORMAT, DEFAULT_SETTINGS, SHOW_DATE_FORMAT } from './constants'
import { DEFAULT_BLOCK_DEADLINE_DATE_FORMAT, DEFAULT_JOURNAL_FORMAT, DEFAULT_SETTINGS, SHOW_DATE_FORMAT } from './constants'
import axios from 'axios'
import ical from 'ical.js'
// import ical from 'node-ical'

dayjs.locale({
...en,
Expand Down Expand Up @@ -86,8 +85,13 @@ export const getSchedules = async () => {

const queryPromiseList = scheduleQueryList.map(async queryWithCalendar => {
const { calendarConfig, query } = queryWithCalendar
const { script = '', scheduleStart = '', scheduleEnd = '', dateFormatter, isMilestone } = query
const blocks = await logseq.DB.datascriptQuery(script)
const { script = '', scheduleStart = '', scheduleEnd = '', dateFormatter, isMilestone, queryType } = query
let blocks: any[] = []
if (queryType === 'query') {
blocks = await logseq.DB.q(script) || []
} else {
blocks = await logseq.DB.datascriptQuery(script)
}
console.log('[faiz:] === search blocks by query: ', script, blocks)

return flattenDeep(blocks).map(block => {
Expand Down

0 comments on commit a65131f

Please sign in to comment.