~oyvindsk/rss-web-reader

d9d39fb97169e298f04de242f112f1917a10cc31 — Øyvind Skaar 8 months ago 7176f0c master
fix: added index and order by on main article list
3 files changed, 31 insertions(+), 1 deletions(-)

A deployment/push-local-datastore-indexes.sh
A index.yaml
M src/ds.go
A deployment/push-local-datastore-indexes.sh => deployment/push-local-datastore-indexes.sh +12 -0
@@ 0,0 1,12 @@
#!/usr/bin/env bash

# try to stop if something fails, 
# see https://stackoverflow.com/questions/821396/aborting-a-shell-script-if-any-command-returns-a-non-zero-value
set -e 
set -o pipefail

gcloud --project rss-test-281216 datastore indexes create index.yaml

echo -e "\n\nCurrent indexes, to cleanup run:\ngcloud --project rss-test-281216 datastore indexes cleanup index.yaml\n\n"

gcloud --project rss-test-281216 datastore indexes list

A index.yaml => index.yaml +18 -0
@@ 0,0 1,18 @@
indexes:

- kind: "items"
  properties:
  - name: "ShownToUser"
  - name: "FirstSeen"
    direction: asc

# Eiter write this file manually or 
# run the datastore emulator, do the queries and look in:
# ~/.config/gcloud/emulators/datastore/WEB-INF/index.yaml

# Deploy:
# /deployment/push-local-datastore-indexes.sh
#
# See:
# https://cloud.google.com/datastore/docs/concepts/indexes
# https://cloud.google.com/datastore/docs/tools/indexconfig

M src/ds.go => src/ds.go +1 -1
@@ 165,7 165,7 @@ func (d *ds) getAll() ([]Item, error) {

func (d *ds) getUnseen(cnt int) ([]Item, error) {

	q := datastore.NewQuery("items").Filter("ShownToUser =", false).Limit(cnt)
	q := datastore.NewQuery("items").Filter("ShownToUser =", false).Limit(cnt).Order("FirstSeen")

	var items []Item
	_, err := d.client.GetAll(d.ctx, q, &items)